Stitching sequential buffer reads to form one continuous ADC

Applications, development tools, FPGA, C, WEB
Post Reply
albertryou2
Posts: 19
Joined: Thu Jun 23, 2016 8:20 pm

Stitching sequential buffer reads to form one continuous ADC

Post by albertryou2 » Tue Jun 28, 2016 11:58 pm

Hey guys,

For continuous ADC, I know that repeatedly reading the buffer via simply looping the acquire function is too slow for everyone, but I wanted to still see just how slow it is.

I am testing the "continuous ADC through looping" idea by measuring a sine wave with frequency = 5 Hz on Channel 1, while triggering on a different sine wave with frequency = 1 Hz on Channel 2. The idea is that 1 Hz should be slow enough that I should be able to read at the triggering frequency without worrying about time lost to reading (that is, polling and saving data).

But the result of "stitching" the data files looks wrong. See attached. The different buffers do not seem to lie on the same 5-Hz sine wave. Do you know why that is?

FYI I'm getting the data with:

for i in range(N):

rp_s.tx_txt('ACQ:START')

rp_s.tx_txt('ACQ:TRIG CH2_PE')

while 1:
rp_s.tx_txt('ACQ:TRIG:STAT?')
if rp_s.rx_txt() == 'TD':
rp_s.tx_txt('ACQ:STOP')
break

rp_s.tx_txt('ACQ:SOUR1:DATA?')

buff_string = rp_s.rx_txt()
with open("adc_data/ch1/dump1_"+str(i)+".txt","w") as f:
f.write(buff_string)

and then at the end, plotting each buffer at 1-Hz interval.

Thanks for the help!
You do not have the required permissions to view the files attached to this post.

albertryou2
Posts: 19
Joined: Thu Jun 23, 2016 8:20 pm

Re: Stitching sequential buffer reads to form one continuous

Post by albertryou2 » Wed Jun 29, 2016 9:56 pm

Update:
Stitching works but only with additional delay per read: For a 1.5-Hz signal, I'm triggering with 0.5 Hz, but instead of placing each buffer at 2-s intervals, I added an additional delay of about 0.147s per buffer. This seems to line them up now, but I don't understand where this fudge factor comes from. Any idea?
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: Stitching sequential buffer reads to form one continuous

Post by Nils Roos » Thu Jun 30, 2016 1:48 am

How do you generate the signals you are measuring? From the look of the individual segments, the trigger signal does not have a 1:n frequency relation with the measured signal. Your counter-measure of an additional fraction of a second seems to support that theory.

albertryou2
Posts: 19
Joined: Thu Jun 23, 2016 8:20 pm

Re: Stitching sequential buffer reads to form one continuous

Post by albertryou2 » Thu Jun 30, 2016 6:14 pm

Hi Nils,
I am generating the test signal with Red Pitaya, i.e. with

rp_s.tx_txt('SOUR1:FUNC SINE')
rp_s.tx_txt('SOUR1:FREQ:FIX 1.5')
rp_s.tx_txt('SOUR1:VOLT 0.5)

I am also triggering with a 0.5-Hz signal generated by Red Pitaya. You are suggesting that the frequencies of these two signals might not be exact, right? I'll test it with a separate external function generator now.

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

Re: Stitching sequential buffer reads to form one continuous

Post by Nils Roos » Thu Jun 30, 2016 6:21 pm

At very low frequencies, there can be a noticable deviation from the programmed frequency in the RP api generate functions and the generator apps.
See this post and the precision generator, courtesy of ThomasGobmaier.

albertryou2
Posts: 19
Joined: Thu Jun 23, 2016 8:20 pm

Re: Stitching sequential buffer reads to form one continuous

Post by albertryou2 » Thu Jun 30, 2016 7:05 pm

Thanks Nils, just tested the same setup but this time with an external signal generator. It worked out perfectly well without the need for any fudge.

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