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