Fast Triggering with Python

Applications, development tools, FPGA, C, WEB
Post Reply
MaximePESCHE
Posts: 1
Joined: Wed Jun 15, 2022 10:09 am

Fast Triggering with Python

Post by MaximePESCHE » Wed Jun 15, 2022 10:39 am

Hello everyone!

I'm starting to work with my redpitaya, and so far, everything is looking great. For the begining, I'm trying to send a signal on an analog output with an external trig. This is inspired by this example from the main page.

https://redpitaya.readthedocs.io/en/lat ... -exm3.html

All is neat and clean until I ramp up the trigger frequenc. At 5Hz, the redpitaya don't follow all the trig. 5Hz seems quite a low frequency so Im quite sure this is my way of commanding the board that is wrong.

Here is my python code.

Code: Select all

import redpitaya_scpi as scpi
import sys

wave_form = 'sine'
freq = 100
ampl = 1


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

rp_s.tx_txt('ACQ:DEC 1')
rp_s.tx_txt('ACQ:TRIG:LEVEL 1000')
rp_s.tx_txt('ACQ:START')

rp_s.tx_txt('GEN:RST')

rp_s.tx_txt('SOUR1:FUNC ' + str(wave_form).upper())
rp_s.tx_txt('SOUR1:FREQ:FIX ' + str(freq))
rp_s.tx_txt('SOUR1:VOLT ' + str(ampl))

rp_s.tx_txt('OUTPUT1:STATE ON')

while 1:
    rp_s.tx_txt('SOUR1:BURS:NCYC 2')
    rp_s.tx_txt('SOUR1:BURS:STAT BURST')
    rp_s.tx_txt('SOUR1:TRIG:SOUR EXT_PE')

    rp_s.tx_txt('ACQ:START')
    rp_s.tx_txt('ACQ:TRIG EXT_NE')
    while 1:
        rp_s.tx_txt('ACQ:TRIG:STAT?')

        status = rp_s.rx_txt()
        if status == 'TD':
            break
Im pretty sure than this line is a key element:

Code: Select all

status = rp_s.rx_txt()
It take around 80ms to compute. But I don't know what is a better way of writing this. Could you help me out?

User avatar
M0JPI
Posts: 19
Joined: Wed Jun 15, 2022 8:06 pm
Location: Cumbria, UK

Re: Fast Triggering with Python

Post by M0JPI » Sun Jun 19, 2022 3:45 pm

I'm still learning new things about test & measurement and the Red Pitaya all the time, so I may have misunderstood. There are a few things that I think may help you.

Firstly I think only the SIGNALlab 250-12 supports setting an external trigger voltage, the other boards have a digital external trigger on pin 3 of Extension connector E1, or can use an internal trigger.

Second, the Red Pitaya's signal processing is better when most of the project run in the FPGA. The SCPI server changes the FPGA design's status registers so you can set the parameters. Waiting for the trigger to happen inside a Python while loop slowing down your project's performance. I think the following example will setup the FPGA design with your signal generator parameters and should trigger every time it gets an external positive edge without using a loop at all. The Python program exits once the parameters are set, but they remain active in the FPGA memory.

Code: Select all

import redpitaya_scpi as scpi
import sys

wave_form = 'sine'
freq = 100
ampl = 1

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

rp_s.tx_txt('GEN:RST')

rp_s.tx_txt('SOUR1:FUNC ' + str(wave_form).upper())
rp_s.tx_txt('SOUR1:FREQ:FIX ' + str(freq))
rp_s.tx_txt('SOUR1:VOLT ' + str(ampl))

rp_s.tx_txt('OUTPUT1:STATE ON')

rp_s.tx_txt('SOUR1:BURS:NCYC 2')
rp_s.tx_txt('SOUR1:BURS:STAT BURST')
rp_s.tx_txt('SOUR1:TRIG:SOUR EXT_PE')
The signal generator trigger, and the acquisition trigger can come from the same source, but they go to different parts of the FPGA design, and are controlled with different SCPI commands.

The FPGA fabric of the Zynq chip will run even after Linux has halted the CPUs.

The redpitaya_scpi.py file has to be in the Python module search path, the easiest location is the same folder as the Python file. I have submitted a pull request to add it to the Jupyter home folder, as that is in the Python module search path.

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 16 guests