Output a signal with every rising edge of an external trigger or RF-input signal

Just about everything about Red Pitaya
Post Reply
Yazeed
Posts: 2
Joined: Tue Jan 30, 2024 6:22 pm

Output a signal with every rising edge of an external trigger or RF-input signal

Post by Yazeed » Wed Jan 31, 2024 5:25 pm

Hi everyone, I am new to the RedPitaya so sorry in advance if the issue is simple or too generic.
My goal is to input the RedPitaya a periodic signal (about 1 MHz, to be used as a clock or as a trigger) and output high or low DC voltages according to a predefined bitstream (zeros and ones) with every rising edge of the input signal.
So, the pseudocode is the following:
####
Receive input signal
If input signal voltage > some threshold voltage:
If bitstream == '1': Output DC_voltage_level = 1.0
else: Output DC_voltage_level = 0
###
As a first approach I thought about using python to generate the random bit string, waiting for the RedPitaya to be trigerred (both from the external trigger pins and from the RF input) and output a DC voltage corresponding to the bitstream, either 0 or 1 volts.
The core of my code was the following:
########
rp_s.tx_txt('SOUR1:TRIG:SOUR EXT_PE')
rp_s.tx_txt('SOUR:TRIG:EXT :DEBouncerUs 1')
rp_s.tx_txt(f"SOUR1:FUNC DC")
rp_s.tx_txt('OUTPUT:STATE ON')
try:
while 1:
rp_s.tx_txt('ACQ:TRIG:STAT?')
rp_s.tx_txt('SOUR1:TRIG:STAT?')
if rp_s.rx_txt() == 'TD':
voltage_level = 1.0 if bitstream == '1' else 0.0
rp_s.tx_txt(f"SOUR1:VOLT {voltage_level}")
i+=1
i %= len(bitstream)
rp_s.tx_txt('ACQ:RST')

except KeyboardInterrupt: print("You stopped the code")
########

This approach does not work as the triggering condition is not met on every rising edge. We also tried another approach where we received the input signal from the fast RF input (IN1) instead of the external trigger (EXT_PE) and tried to acquire every sample of the signal and use it to compare with the threshold, but that didn’t work either.

Could you please help me or indicate a possible approach to follow?

Thanks

User avatar
redpitaya
Site Admin
Posts: 912
Joined: Wed Mar 26, 2014 7:04 pm

Re: Output a signal with every rising edge of an external trigger or RF-input signal

Post by redpitaya » Thu Feb 01, 2024 11:43 am

Hello Yazeed,

Thank you for writing on the forum.

The external trigger and SCPI commands are not going to cut it here. You might be able to get away with it using the Python API or C API commands (running on the Red Pitaya board), but the code might be too slow to catch every trigger edge to generate the desired signal.

The best way to do this would be to modify the v0.94 FPGA image to achieve the desired result. Here are some resources that can help you:
- Red Pitaya v0.94 and Data Sampling projects: https://lniv.fe.uni-lj.si/redpitaya/
- LED counter tutorial: https://redpitaya-knowledge-base.readth ... ed-counter
- How to connect GPIO ports: viewtopic.php?f=15&t=25298

Use LED counter tutorial to setup a base project, and connect the GPIO ports, using the forum topic. Then you can reuse some of the code from the Data Sampling project to make it work as you want (the oscilloscope trigger).

You can store the predefined bitstreams into arrays and can then change them through a C program running on the Red Pitaya board.

I hope this helps. If you have any questions, please let me know.

Post Reply
jadalnie klasyczne ekskluzywne meble wypoczynkowe do salonu ekskluzywne meble tapicerowane ekskluzywne meble do sypialni ekskluzywne meble włoskie

Who is online

Users browsing this forum: No registered users and 126 guests