Red Pitaya from Command Line and Shell Scripts.


Intro.

Hi, In this webpage I will show you how you can use the your Red Pitaya from the command line and how to write simple Bash Scripts to do some tasks over LEDs, Slow Analog to Digital Converters, Slow Digital to Analog Converters and Digital Input/Outputs.

To start, here do you have some examples for the use of monitor to access the system registers:

Open a terminal and connect to the Red Pitaya by shh:

ssh root@your_red_pitaya_ip

Here we can use monitor to read and write the Red Pitaya system registers.

redpitaya> monitor

That reply something like this help data:

monitor version 0.92-378-d3751f9

Use:

read addr: address
write addr: address value
read analog mixed signals: -ams
set slow DAC: -sdac AO0 AO1 AO2 AO3 [V]

Analog Mixer Signals (Analog Input/Out).

Now, get analog signals from Analog to Digital (Analog Inputs, AIx) and Digital to Analog (Analog Output, AOx) Converters:

redpitaya> monitor -ams

#ID	Desc		Raw	Val
0	Temp(0C-85C)	aba	64.802
1	AI0(0-3.5V)	ff6	0.000
2	AI1(0-3.5V)	8	0.014
3	AI2(0-3.5V)	ff7	0.000
4	AI3(0-3.5V)	ff7	0.000
5	AI4(5V0)	638	4.752
6	VCCPINT(1V0)	556	1.001
7	VCCPAUX(1V8)	9a1	1.806
8	VCCBRAM(1V0)	556	1.001
9	VCCINT(1V0)	557	1.001
10	VCCAUX(1V8)	9a1	1.806
11	VCCDDR(1V5)	802	1.502
12	AO0(0-1.8V)	f0000	0.173
13	AO1(0-1.8V)	4e0000	0.900
14	AO2(0-1.8V)	750000	1.350
15	AO3(0-1.8V)	9c0000	1.800

If you are only interested in one input or output, type this:

redpitaya> monitor -ams | grep AO1
13	AO1(0-1.8V)	4e0000	0.900

To write the data on a file:

redpitaya> monitor -ams | grep AO1 > test.dat
redpitaya> ls
test.dat

You can find this file in the Red Pitaya root directory.

To get the Analog IO data updated each 2 seconds, you can do this:

redpitaya> watch monitor -ams

Now. We can change the Analog Outputs. Some examples:

redpitaya> monitor -sdac 0.5
redpitaya> monitor -sdac 0.5 1.5
redpitaya> monitor -sdac 0.5 0.25 1.3 1.7

Run monitor -ams to see the output changes, or test it with your voltmeter to the Red Potaya.

LEDs.

Read LEDs state.

redpitaya> monitor 0x40000030
0x00000000

If you see all zeros, this is indicating that all LEDs are off.

To turn on the Diode3, calculate, 2**3=8, and then.

redpitaya> monitor 0x40000030 0x08

This command turns ON the LED3 and turns OFF the rest.


LED01234567
Calc.2**02**12**22**32**42**52**62**7
Value1248163264128
Hex.0x010x020x040x080x100x200x400x80

If you want more than on LED ON. You need to sum theis Hexadecimal values.

redpitaya> monitor 0x40000030 0x44

Turns ON LED 2 and 6. The others turns OFF.

Digital Inputs/Outputs.

This works with a very similar maner to the LEDs, but you need to configure the pins for Input or Output.

To read P Outputs:

redpitaya> monitor 0x40000018

To read N Outputs:

redpitaya> monitor 0x4000001C

To read P Inputs:

redpitaya> monitor 0x40000020

To read N Inputs:

redpitaya> monitor 0x40000024

Configuring the Digital Inputs and Outputs.

P Output 1 as Output, the others as Input.

redpitaya> monitor 0x40000010 0x02

N Output 0 and 1 as Output, the othres as Input.

redpitaya> monitor 0x40000014 0x03

Changing the Outputs state.

Output 1, DIO1, turn ON, others in OFF.

redpitaya> monitor 0x40000018 0x02



Copyright (C) 2023 SEUTec, All Rights Reserved.