Page 1 of 1

External trigger pin DIO0_P

Posted: Tue May 23, 2023 1:50 pm
by samiranooshnab
Hi guys,
I would be happy if you help me with this problem. I want to trigger and synchronised the Output1 triangle pulse with 20hz frequency by the external trigger in STEAMlab125_10(14). So, I chose the external trigger positive edge Mose for my output1 in rigger section, then I connected the pin3 (DIO0_P) pin to the function generator that makes a square pulse in 1Khz with almost 3 volt amplitude and 9 micro second pulse width. I wrote the below code ignorer to synchronise them but it did not work. Could you please help me to solve it.
Thanks
import redpitaya_scpi as scpi
import sys


rp_s = scpi.scpi(sys.argv[1])

rp_s.tx_txt('GEN:RST')


rp_s.tx_txt('DIG:PIN:DIR IN,DIO0_P')
rp_s.tx_txt('ACQ:TRIG:DIO:EDGE DIO0_P,EXT_PE')


rp_s.tx_txt('SOUR1:FUNC TRIANGLE')
rp_s.tx_txt('SOUR1:FREQ:FIX 500')
rp_s.tx_txt('SOUR1:VOLT 1')

rp_s.tx_txt('OUTPUT1:STATE ON')
rp_s.tx_txt('SOUR1:TRIG EXT_PE')


pulse_count = 0

while True:
# Check GPIO status
gpio_status = rp_s.tx_txt('DIG:PIN? DIO0_P')
print("GPIO Status:", gpio_status)

trigger_status = rp_s.tx_txt('ACQ:TRIG:STAT?')
print("Trigger Status:", trigger_status)
# Check if trigger occurred
if gpio_status == '1':
pulse_count += 1
if pulse_count >= 50:
pulse_count = 0

rp_s.tx_txt('SOUR1:BURS:NCYC 1')
rp_s.tx_txt('SOUR1:BURS:STAT BURST')
rp_s.close()

Re: External trigger pin DIO0_P

Posted: Wed May 31, 2023 12:59 am
by f_sat
I don't know if my idea works for you, but I also required an external sensor to dictate the behavior of the pitaya network, and since I couldn't use interruptions, I chose to use threads in C, one was directly in charge of sensing the pin and when it received something it modified a variable that was read by another thread thus simulating an interruption.

I don't have much experience with this but I hope it helps you.

Re: External trigger pin DIO0_P

Posted: Fri Jun 02, 2023 10:31 am
by redpitaya
First of all, these commands are not included in our documentation. Could you please tell us where/how you found them:
  • rp_s.tx_txt('ACQ:TRIG:DIO:DIR DIO0_P,I')
  • rp_s.tx_txt('ACQ:TRIG:DIO:EDGE DIO0_P,EXT_PE')
Secondly, please take a look at the code examples provided here:
https://redpitaya.readthedocs.io/en/lat ... l#examples

On the link above, you will also find the list of all available SCPI commands.

Counting the trigger cycles using the following code is not going to work:
while True:
rp_s.tx_txt('ACQ:TRIG:STAT?')
if rp_s.rx_txt() == 'TD':
pulse_count += 1

Red Pitaya's SCPI commands use buffered acquisition - once the data has been acquired, the acquisition will stop (there is no continuous acquisition using the SCPI commands). In order to start it again, you need to run ACQ:START command. (the 'ACQ:TRIG:STAT?' will always return TD if the acquisition is not restarted).

Please also note that you need to specify the trigger source for the output:
SOUR<n>:TRIG:SOUR <trigger> (SOUR:TRIG EXT_PE is an invalid command)

And if you use the default internal trigger (trigger it manually):
SOUR:TRIG:INT

Red Pitaya currently does not support counting trigger conditions. One possible solution to achieve this functionality would be to reprogram the FPGA.

Please note that there is a delay between the commands being sent from your computer and executed on your Red Pitaya (if you are looking for precise signal manipulation I would recommend having as few SCPI commands in while loops as possible).