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_ipHere we can use monitor to read and write the Red Pitaya system registers.
redpitaya> monitorThat reply something like this help data:
monitor version 0.92-378-d3751f9Use:
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.800If you are only interested in one input or output, type this:
redpitaya> monitor -ams | grep AO1 13 AO1(0-1.8V) 4e0000 0.900To write the data on a file:
redpitaya> monitor -ams | grep AO1 > test.dat redpitaya> ls test.datYou 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 -amsNow. 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.7Run
monitor -amsto see the output changes, or test it with your voltmeter to the Red Potaya.
LEDs.
Read LEDs state.
redpitaya> monitor 0x40000030 0x00000000If 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 0x08This command turns ON the LED3 and turns OFF the rest.
LED 0 1 2 3 4 5 6 7 Calc. 2**0 2**1 2**2 2**3 2**4 2**5 2**6 2**7 Value 1 2 4 8 16 32 64 128 Hex. 0x01 0x02 0x04 0x08 0x10 0x20 0x40 0x80
If you want more than on LED ON. You need to sum theis Hexadecimal values.
redpitaya> monitor 0x40000030 0x44Turns 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 0x40000018To read N Outputs:
redpitaya> monitor 0x4000001CTo read P Inputs:
redpitaya> monitor 0x40000020To read N Inputs:
redpitaya> monitor 0x40000024Configuring the Digital Inputs and Outputs.
P Output 1 as Output, the others as Input.
redpitaya> monitor 0x40000010 0x02N Output 0 and 1 as Output, the othres as Input.
redpitaya> monitor 0x40000014 0x03Changing the Outputs state.
Output 1, DIO1, turn ON, others in OFF.
redpitaya> monitor 0x40000018 0x02
Copyright (C) 2023 SEUTec, All Rights Reserved.