Sampling rate??

Post your .Net discussions here
Post Reply
Payam30
Newbie
Posts: 0
Joined: Thu Dec 28, 2017 2:24 pm

Sampling rate??

Post by Payam30 »

Hi,
Using a PS5000a and Pico 6:
I don't really know why when I assign the sampling rate the pico does it automatically to something else. What does the pico do actually? In my application I insert the sampling interval in milisec:
Let's say

Code: Select all

 sampleRedo = 200 nanosec
The frequency of sampling should then be :

Code: Select all

Frequency = 1/(200* 10^(-9)) that is : 5000000 Hz = 5 MS/s
The timebase is then :

Code: Select all

_timebase = (uint)(125000000 * sampleRedo + 2);
but what I see when I try this with pico 6. when I choose 10 kS/s it give me a sampling rate that is 200 kS/s
Image

How can I found the actuall frequency that pico is sampling with?

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

Re: Sampling rate??

Post by Martyn »

PicoScope works by first setting the time across the screen, in this example 5ms/div so 50msecs. You then select the desired number of samples you would like to get in this time window, in this case 10kSamples. The software then works out the closest number of samples that can actually be achieved in this time frame with the actual PicoScope hardware you have, in your case in can collect 10kSamples.

These figures give a sample interval of 5usecs and a sample rate of 200 kSamples/sec as shown in the right hand window.

So you have one fixed parameter, time across screen, one desired parameter, number of samples, and one calculated parameter, sample rate.

When you write your own applications you do not have the need to fix the time first, so have greater flexibility in what you can set.
Martyn
Technical Support Manager

Payam30
Newbie
Posts: 0
Joined: Thu Dec 28, 2017 2:24 pm

Re: Sampling rate??

Post by Payam30 »

I see from the Pico that Pico always shows 10 Divs. Do we by writing own program using pico sdk get the same amount of divs?

The way Pico calculates the frequency and sampling interval is :
(number of divs)*(the type of Div)/(number of sampling point) which will be ( for 10 div and 5 ms/Div and 1000 sampling points)

Code: Select all

sampleIntervall = 10*0.005/1000 =  50 microsec
and the sampling frequency is

Code: Select all

1/50 microsec = 20kHz
so the question are :
1) we have in the SDK that:

Code: Select all

status = Imports.RunStreaming(_handle, ref sampleInterval, Imports.ReportedTimeUnits.MilliSeconds, preTrigger, 1000000 - preTrigger, 1, 1, Imports.RatioMode.None, (uint)sampleCount)
  • is

    Code: Select all

    sampleInterval
    the same as we this calculated? i that case why is it of type uint?
  • is

    Code: Select all

    Imports.ReportedTimeUnits.MilliSeconds
    related to sampling interval? for instance if the sampling interval is in milisecond, do we use milisecond in ReportedTime enum?
  • is

    Code: Select all

    (uint)sampleCount
    the same as number of samples defined in Pico 6?
I have seen that the number of samples vary in the loop and is not always the same. I really want to know how you succeed to have same amount of sample points and same number of time divs. That is crucial for me to know.

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

Re: Sampling rate??

Post by Martyn »

If you wish to have 10 divisions on the screen, then it is down to you and your application. It has nothing to do with the SDK. The PicoScope 6 application is replicating the look of a bench top scope which is one of the reasons why we do this.

It does cause extra overheads, in that you have to calculate out sample interval that will work for the given screen time, and that can be achieved with the chosen hardware.

The other part is that in PicoScope 6 it is not full streaming. It is a block collection mode that allows you to see the data whilst it is being collected if the collection time is long.

You are getting a bit confused due to some of the terms you have in your import file, this is the actually one from GitHub

Code: Select all

		[DllImport(_DRIVER_FILENAME, EntryPoint = "ps5000aRunStreaming")]
		public static extern uint RunStreaming(
			                                        short handle,
			                                        ref uint sampleInterval,
			                                        ReportedTimeUnits sampleIntervalTimeUnits,
			                                        uint maxPreTriggerSamples,
			                                        uint maxPostPreTriggerSamples,
			                                        short autoStop,
			                                        uint downSamplingRatio,
                                                    RatioMode downSampleRatioMode,
			                                        uint overviewBufferSize);
No mention of SampleCount.

The driver will collect the Pre and Post trigger samples and store them in an internal buffer which can be read out after the block has been collected.

The overviewBuffer is where the driver places the collected data, downsampled if required, that is being drawn on the screen as the collection progresses.

Honestly I would forget trying to exactly replicate the PicoScope 6 functionality for streaming, it is unique for our purpose, and code your application to do exactly what it needs to do. Copying PicoScope 6 is like trying to code with your hands tied behind your back, which is why you are having difficulty understanding this.
Martyn
Technical Support Manager

Payam30
Newbie
Posts: 0
Joined: Thu Dec 28, 2017 2:24 pm

Re: Sampling rate??

Post by Payam30 »

Thank you very much for your response,
Can you please answer what the div selection ( for instance 5ms/div) does to the sampling? Is the division length defined somewhere in streaming?

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

Re: Sampling rate??

Post by Martyn »

5ms/div means that we put dashed lines across the screen at 5msec intervals. As there are ten divisions we have a Collection Time of 50msecs which is the important part.

DIV means nothing to the device.
Martyn
Technical Support Manager

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

Re: Sampling rate??

Post by Martyn »

Payam30 wrote: The way Pico calculates the frequency and sampling interval is :
(number of divs)*(the type of Div)/(number of sampling point) which will be ( for 10 div and 5 ms/Div and 1000 sampling points)

Code: Select all

sampleIntervall = 10*0.005/1000 =  50 microsec
and the sampling frequency is

Code: Select all

1/50 microsec = 20kHz
Having seen your emails to support, this is the part you have wrong

Code: Select all

sampleInterval = 0.005/1000 =  5 microsec   <----- Don't times by 10 as 1000 is number of samples in 1 division
and the sampling frequency is then

Code: Select all

1/5 microsec = 200kHz
As I have said, don't worry about divisions, that is purely a PicoScope display thing. Instead just use sample interval and number of samples, then time will look after itself.
Martyn
Technical Support Manager

Post Reply