Signal generator frequency

Tell us how your experiment is running with Red Pitaya
Post Reply
r.c.h.
Posts: 1
Joined: Mon Jul 19, 2021 2:43 pm

Signal generator frequency

Post by r.c.h. » Tue Jul 20, 2021 9:18 am

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 :)

Code:

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]
else:
tn = 1
rn = 1
ampl = 0.1
output_time_step = 0.005

rp_s = scpi.scpi("169.254.121.22")

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
half_point=int(BUFF_SIZE/2)

data1=pd.read_csv(f'ape_data/ape_target{tn}_rolloffset_{rn}.csv', header=None)
arr1=np.array(data1[0])

#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))
y1[0:half_point]=arr1[0:half_point]
y1[half_point:]=np.flipud(arr1[0:half_point])

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):
time.sleep(output_time_step)
rp_s.tx_txt('SOUR1:VOLT:OFFS ' + str(scaled_y1.round(5)))

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