Use of GetTimebase function

Post general discussions on using our drivers to write your own software here
Post Reply
hexamer
Advanced User
Advanced User
Posts: 5
Joined: Tue Aug 12, 2014 10:09 pm

Use of GetTimebase function

Post by hexamer »

I'm working to diagnose this issue for the FRA4PicoScope app: viewtopic.php?p=145045#p145045 and it's raising questions in my mind on proper use of the GetTimebase function. For a long time now, my application has assumed that timebase does not affect the maximum number of samples (see comment and code here): https://bitbucket.org/hexamer/fra4picos ... lines-1235

While reading the documentation for ps4000aGetTimebase today, it contradicts my assumption, saying "The scope allocates a certain amount of memory for internal overheads and this may vary depending on the number of segments, number of channels enabled, and the timebase chosen."

If this is correct, then I may need to make a change to the application with complexity dependent on what other knowledge I can use. Specifically:

1) How much could maxSamples vary based on timebase?
2) Is it predictable such that the lowest number of samples available corresponds to the highest sampling rate for the scope?

You'll also see here: https://bitbucket.org/hexamer/fra4picos ... lines-1237 that I always pass 0 for noSamples, thinking it doesn't matter. But I'm wondering of that's causing ps4000aGetTimebase to return 0 in maxSamples. I'm not sure I understand why we even need to pass a requested size - I'm really confused on the dependencies in this function.

Finally, maybe there is a simpler method to tell the maximum samples that can be captured?

Thanks,

Aaron.

AndrewA
PICO STAFF
PICO STAFF
Posts: 401
Joined: Tue Oct 21, 2014 3:07 pm

Re: Use of GetTimebase function

Post by AndrewA »

Hi Aaron,

I have just looked at the ps5000aGetTimebase in the related Programmers guide.
It seems to clear that *timeIntervalNanoseconds and * maxSamples are outputs and the other variables inputs to the function.
It also has the same statement relating to internal overheads.
If you are relying on this function to find and and then capture the Maximum number samples I would pass timebase with the correct value.
Even set noSamples to a positive number, not zero, may fix the issue you are having.
Also do you use or check 'noOfSamples' returned from the psXXXXGetValues function?
I don't think there is a easier way to find the maximum number of samples for your scope settings.

1) How much could maxSamples vary based on timebase?
I would expect should not change.
2) Is it predictable such that the lowest number of samples available corresponds to the highest sampling rate for the scope?
I would expect this not be the case, unless you have set a large number of memory segments.
But in both cases there may be odd settings with certain models/drivers that may return a slight differences in the number of max. samples.
Regards Andrew
Technical Specialist

hexamer
Advanced User
Advanced User
Posts: 5
Joined: Tue Aug 12, 2014 10:09 pm

Re: Use of GetTimebase function

Post by hexamer »

Thank you for the quick response, Andrew.
AndrewA wrote: It seems to clear that *timeIntervalNanoseconds and * maxSamples are outputs and the other variables inputs to the function.
I apologize and will try to be more clear. I agree that the ins/outs are syntactically clear. What I am failing to understand is why the function would need noSamples to compute any of the outputs.
AndrewA wrote: I would pass timebase with the correct value.
This is a bit troubling for the app's "low noise" mode since it uses many timesbases in a FRA sweep and I need a way to know (at least the lowest possible) maxSamples ahead of time to validate the starting frequency. If the starting FRA frequency is too low it would attempt to request more block samples than the scope is capable of storing. Without getting into any proprietary details, is there really no way to predict what timebase would lead to the lowest maxSamples?

The application also ideally needs to know the highest possible maxSamples to allocate internal buffers. Continually resizing them would probably be very inefficient.
AndrewA wrote: Even set noSamples to a positive number, not zero, may fix the issue you are having.
I will certainly try this if I find that maxSamples is really getting set to 0.
AndrewA wrote: Also do you use or check 'noOfSamples' returned from the psXXXXGetValues function?
I am never checking whether the out value (actual) matches the in value (requested) in calls to psXXXXGetValues.
AndrewA wrote: 1) How much could maxSamples vary based on timebase?
I would expect should not change.
This confuses me because it seems to contradict "The scope allocates a certain amount of memory for internal overheads and this may vary depending on the number of segments, number of channels enabled, and the timebase chosen."

Are you saying that timebase would only affect maxSamples if I were using a large number of memory segments?

Martyn
Site Admin
Site Admin
Posts: 4491
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Use of GetTimebase function

Post by Martyn »

This function was created to specifically support the operation of the PicoScope 6 software, it is not needed for applications built using the SDK unless you need to confirm if combinations are valid.

There are three interlinked parameters that define a data capture

Number of samples
Sample interval
TIme of capture

the first two are physically linked to the hardware, and time of capture is the product, so an SDK example can just specify number of samples, and sample interval (timebase). PicoScope 6 works the wrong way round in that it starts with the time of capture and fixes this value, it then allows you to request how many samples you would like to collect in the screen, and from this it will try and calculate a sampling interval (timebase) that allows you to collect as close as possible to the number of samples you have requested. Exact matches are not always possible due to the fixed ranges of timebases that the hardware can support and the available memory on the device, and so the function allows you to pass the requested number of samples and the function will return the actual number the scope will collect.
Martyn
Technical Support Manager

hexamer
Advanced User
Advanced User
Posts: 5
Joined: Tue Aug 12, 2014 10:09 pm

Re: Use of GetTimebase function

Post by hexamer »

Martyn,

Thank you for the explanation. I can see how this function would be useful for the PicoScope application. Given the advice from you and Andrew, I did decide just to be conservative and re-code the parts of the application related to buffer allocation and block captures. I also see that the PS6000A API added some functions for determining buffer size. At least in that case it's clear max samples has no dependency on timebase.

Thanks,

Aaron.

Post Reply