Test and Measurement Forum

Oversampling problem

Post your C and C++ discussions here

Oversampling problem

Postby Guillaume_UC » Fri Aug 23, 2013 4:43 pm

Hi,
My aim is to get a waveform sampled at 7.8125 MHz using the oversampling feature in order to enhance vertical resolution.
Therefore, I tried to set the sampling frequency to 125 MHz, and use oversample=16.
I connected channel A to a 120 kHz sinusoidal waveform generator. We have a picoscope ps4227.
However, the code copied below does not work.
-When I try with oversample=1, everything works fine: the period of the digitized signal in outputvaluesA that I measure manually, by visualizing the waveform, is what is expected (i.e. 1e9/120e3/interval samples)
-With oversample=16:
-The values returned by getTimebase are as expected (interval=1.0e9f/fs, and maxsample is divided by 16 compared to oversample=1)
-The period of the digitized signal in outputvaluesA that I measure manually is 1e9/120e3/(interval/16) samples (the same number of sample as with oversample=1), and not 1e9/120e3/interval, as expected
- The vertical resolution is not enhanced (still 12 bits)
Therefore, it appears that oversample=16 acts as expected for the function GetTimebase, however for the function RunBlock oversample=16 gives exactly the same data as what would have been obtained with oversample=1.
Is something missing or wrong in the code? Does our picoscope have ths oversampling feature?

Also, we noticed that in the last version of the SDK (10.5.019), the functions ps4000SetSimpleTrigger and ps4000IsReady are missing from the .lib file (an error is sent by the linker). We worked this around by using the 3 other trigger functions and the callback for RunBlock, it works fine but it is less convenient.

Thank you,
Guillaume

Code: Select all
nFs=1;
oversample=16;
wfm_duration=1e-3;
fs=250e6/pow(2,nFs)/oversample; //targeted sampling frequency (after subsampling): 7812500 Hz
nsample = ceil(wfm_duration*fs);

ps4000SetSimpleTrigger(handle,1,PS4000_EXTERNAL,trigThresh,RISING,0,0);
ps4000GetTimebase(handle, nFs, nsample, &interval, oversample, &maxsample, 0);
printf("Interval %d ns (%f ns obtained using nFs and oversample)\n", interval,1.0e9f/fs);

outputvaluesA = (short *) malloc(nsample*sizeof(short));
outputvaluesB = (short *) malloc(nsample*sizeof(short));
status = ps4000SetDataBuffer(handle, PS4000_CHANNEL_A, outputvaluesA, nsample);
status = ps4000SetDataBuffer(handle, PS4000_CHANNEL_B, outputvaluesB, nsample);

ready=0;
status = ps4000RunBlock( handle, 0, nsample, nFs, oversample, NULL, 0,  readycallback, NULL);
while (ready == 0)   //ready is set to 1 when readycallabck is called
        Sleep(1);
status = ps4000GetValues(handle, 0, &nsample, 1, RATIO_MODE_NONE, 0, &overflow);
Guillaume_UC
Newbie
 
Posts: 0
Joined: Fri Aug 23, 2013 4:32 pm

Re: Oversampling problem

Postby Hitesh » Tue Sep 10, 2013 12:28 pm

Hi Guillame,

I'm in the process of looking into this and will post an update later.

Could you please explain the presence of 1e9 in your formulae as I've understood the number of samples in one period as:

Code: Select all
num_samples = f_sampling / f_waveform


which should give 1041 samples with oversampling set to 1, and 65 samples when set to 16

With regards to the functions, it appears they were missed from the header file but should be corrected in the next SDK release.

Regards,
Hitesh

Technical Specialist
Pico Technology
Hitesh
Site Admin
Site Admin
 
Posts: 2058
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: Oversampling problem

Postby Guillaume_UC » Tue Sep 10, 2013 6:25 pm

Hi Hitesh,
Thank you for your reply.
The 1e9 is to convert ns to s, assuming we use the "interval" value returned by ps4000GetTimebase (timeIntervalNanoseconds parameter). Therefore the expected number of samples per sine period is 1/f_waveform/(interval in s) or 1e9/f_waveform/(interval in ns), or as you wrote, f_sampling/f_waveform.
Therefore, as you say, with the test conditions described in my initial post, the expected number of samples per sine period is 1041 samples with oversampling=1 and 65 with oversampling=16.
My initial post may be a little confusing... If I try to summarize my problem, it appeared that the waveform data obtained using ps4000RunBlock followed by ps4000GetValues was not affected by the value of the oversample parameter of ps4000RunBlock (which always seemed to behave as if oversample=1).
Thank you for your help,
Guillaume.
Guillaume_UC
Newbie
 
Posts: 0
Joined: Fri Aug 23, 2013 4:32 pm

Re: Oversampling problem

Postby Hitesh » Wed Sep 11, 2013 3:27 pm

Hi Guillaume,

I've had some clarification. It appears that the PicoScope 4227 does not support oversampling as it makes use of downsampling.

You can use the averaging functionality provided by using downsampling. You will need to use the function ps4000SetDataBufferWithMode and use the RATIO_MODE_AVERAGE enumeration. Ensure that the oversample value is set back to 1.

I hope this helps.
Hitesh

Technical Specialist
Pico Technology
Hitesh
Site Admin
Site Admin
 
Posts: 2058
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: Oversampling problem

Postby Guillaume_UC » Wed Sep 11, 2013 6:52 pm

It makes sense, I will try this. Thank you for your help.
Guillaume_UC
Newbie
 
Posts: 0
Joined: Fri Aug 23, 2013 4:32 pm


Return to C and C++

Who is online

Users browsing this forum: No registered users and 0 guests