burst acquire trouble

Applications, development tools, FPGA, C, WEB
Post Reply
c3018911
Posts: 2
Joined: Fri Aug 21, 2015 10:12 am

burst acquire trouble

Post by c3018911 » Tue Feb 07, 2017 5:14 am

Hi - I'd like to see if anyone can point me in the right direction with this.

Basically, I would like to replace a standard function generator and oscilloscope with the RP. On "OUT1" I'd like to generate sine bursts with a frequency of around 10kHz and direct this to "IN1", while at the same time the signal is passed through a sample and then directed to "IN2". An example of this is shown in the attached PDF. I need to measure the time lag between the first arrival of the input signal, and various points on the output signal.

I've been able to generate and acquire the signal on IN1, but I am having trouble adjusting the delay, so that the acquire starts just before the sine burst (see also attached). How could this be achieved?

Also, will it be possible to syncronise the acquire of both IN1 and IN2?

All of this I am hoping to achieve with python as below.

Thanks in advance!
Glen

Code: Select all

#!/usr/bin/python

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


#connect to the RP
rp_s = scpi.scpi('10.42.0.215')

wave_form='SINE'
freq_in=[10000,20000]
ampl=.95
num_bursts=1 #NCYC
burst_repeats=2 #NOR

dec=8
delay=8150

dec_op=[1,8,64,1024,8192,65563]
t_int_op=[131.072,1.049*1000,8.389*1000,134.218*1000,8509*1000]

t_int=t_int_op[dec_op.index(dec)]

per_in=[300]
for i in xrange(0,len(freq_in)):
		
	rp_s.tx_txt('DIG:PIN LED1,1')
	time.sleep(0.1)	
	rp_s.tx_txt('DIG:PIN LED1,0')
	
	freq=freq_in[i]
	per=per_in[0]	
	'''
	translated matlab code from here
	http://blog.redpitaya.com/examples-new/synchronized-one-pulse-generating-and-acquiring/
	'''
	rp_s.tx_txt('ACQ:RST')
	rp_s.tx_txt('GEN:RST')


	rp_s.tx_txt('ACQ:DEC '+str(dec))		
	rp_s.tx_txt('ACQ:TRIG:LEV 0 mV')
	rp_s.tx_txt('ACQ:TRIG:DLY '+str(delay))

	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('SOUR1:VOLT:OFFS 0.')

	rp_s.tx_txt('SOUR1:BURS:STAT ON')
	rp_s.tx_txt('SOUR1:BURS:NCYC '+str(num_bursts))
#	rp_s.tx_txt('SOUR1:BURS:INT:PER '+str(per))
	#rp_s.tx_txt('SOUR1:BURS:NOR '+str(burst_repeats))
	rp_s.tx_txt('OUTPUT1:STATE ON')

	rp_s.tx_txt('SOUR1:TRIG:SOUR INT')

	rp_s.tx_txt('ACQ:START')
	rp_s.tx_txt('ACQ:TRIG AWG_PE')
	time.sleep(1)
	rp_s.tx_txt('SOUR1:TRIG:IMM')	
	
	while 1:
		rp_s.tx_txt('ACQ:TRIG:STAT?')
		if rp_s.rx_txt() == 'TD':
		    break

	rp_s.tx_txt('ACQ:SOUR1:DATA?')
	buff_string = rp_s.rx_txt()
	buff_string = buff_string.strip('{}\n\r').replace("  ", "").split(',')
	buff=list(map(float,buff_string))
	ts = np.linspace(0,t_int,len(buff_string))
	buff=np.array(buff)
	#add vertical shift for plot
	buff+=i/5.	
	plt.plot(ts,buff,label=str(freq))

	file_name=time.strftime("%Y-%m-%d %H:%M:%S",time.localtime())
	buff_file=open(file_name+'.txt',"a")

	for i in xrange(0,len(buff_string)):
		buff_file.write(str(ts[i])+","+buff_string[i]+"\n")

	buff_file.close()
	
	time.sleep(1)


rp_s.close()
plt.ylabel('Voltage (V)')
plt.xlabel(r'Time (us)') #microseconds
plt.legend()
plt.savefig(file_name+'_RP_test.png')	
plt.show()
You do not have the required permissions to view the files attached to this post.

Nils Roos
Posts: 1441
Joined: Sat Jun 07, 2014 12:49 pm
Location: Königswinter

Re: burst acquire trouble

Post by Nils Roos » Sat Feb 11, 2017 9:24 pm

I've been able to generate and acquire the signal on IN1, but I am having trouble adjusting the delay, so that the acquire starts just before the sine burst (see also attached). How could this be achieved?
What kind of trouble do you have? I'd have thought that using "ACQ:TRIG:DLY" is what you need.
Also, will it be possible to syncronise the acquire of both IN1 and IN2?
The two inputs always record synchronously. With the original logic you can not operate them unsynchronized.

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: Google [Bot] and 80 guests