Page 1 of 1

Signal generator frequency

Posted: Tue Jul 20, 2021 9:18 am
by r.c.h.
We're running an experiment at the moment using a Red Pitaya to control a steerable mirror. We're using Python/SCPI. We'd like to be able to output a custom waveform at a known frequency from the Red Pitaya, at the moment we're doing this by changing the offset every few milliseconds, but the timing on this isn't very reliable. Any advice on how we might be able to output a custom waveform at a (relatively slow) known frequency? Thanks :)


import sys
import matplotlib.pyplot as plt
import time
import numpy as np
import pandas as pd
import redpitaya_scpi as scpi

if (len(sys.argv) > 2):
tn = sys.argv[1]
rn = sys.argv[2]
ampl = sys.argv[3]
output_time_step = sys.argv[4]
tn = 1
rn = 1
ampl = 0.1
output_time_step = 0.005

rp_s = scpi.scpi("")

rp_s.tx_txt('ACQ:BUF:SIZE?') # get buffer size from Red Pitaya
BUFF_SIZE = int(rp_s.rx_txt()) # set variable for buffer size

data1=pd.read_csv(f'ape_data/ape_target{tn}_rolloffset_{rn}.csv', header=None)

#only use some of the data from the waveform and mirror it to avoid large jumps at the end of the data
y1 = np.zeros((BUFF_SIZE))

scaled_y1 = y1/np.max(abs(y1))*ampl

freq = 1.0
wave_form = 'DC'

rp_s.tx_txt('GEN:RST') # Reset to default settings

rp_s.tx_txt('SOUR1:FUNC ' + str(wave_form).upper()) # Set function of output signal
rp_s.tx_txt('SOUR1:FREQ:FIX ' + str(freq)) # set frequency of fast analog output
rp_s.tx_txt('SOUR1:VOLT 0.0') # set amplitude voltage of fast analog outputs. Max output is +/- 1V

#Enable output
rp_s.tx_txt('OUTPUT1:STATE ON')

for i in range(BUFF_SIZE):
rp_s.tx_txt('SOUR1:VOLT:OFFS ' + str(scaled_y1.round(5)))