The console example is meant to provide some sort of guidance as to how to call the necessary functions in order to collect some data from the device. I guess in this case some of the comments may not make certain things clear.
In the console example, there is a 'set_timebase' function which repeatedly queries the ps3000_get_timebase() function in order to determine which timebases are available for the number of samples desired, after which the user is prompted to select the desired timebase. The entered option is then stored in the 'timebase' variable.
A default timebase of 8 which should correspond to 1/256 of the maximum sample rate.
The ps3000_get_timebase function is used to query the driver to determine the validity of the number of samples required and the timebase selected. If the parameters are correct the function will return 1, otherwise 0 is returned.
Looking at the collect_block_immediate() function in the console example, a while loop is used to query the ps3000_get_timebase() function in order to determine if the timebase selected is valid. If it is, then the function returns the time interval, time units (e.g. milliseconds, microseconds etc.) and the maximum number of samples that are available (this depends on the timebase chosen, number of channels enabled etc.)
In the manual, the line ”selects time bases until the required number of nanoseconds per sample is located” refers to querying the driver to see which timebases and the corresponding time intervals between samples.
The timebase is actually set when the ps3000_run_block() function is called.
With regards to the comments in the sample program:
1 - 'find the maximum number of samples, the time interval (in time_units),
As mentioned above the maximum number of samples indicates the maximum number of samples depending on the number of channels enabled, the timebase chosen and the oversample selected, while time_interval is a pointer to the time interval in nanoseconds between readings at the selected timebase. T
2 - 'the most suitable time units, and the maximum oversample at the current timebase
The most suitable time units is an enumeration returned from the driver indicating the best time units that the results should be measured in. This values is then used in the call to the ps3000_get_times_and_values() function in order to specify the time units for the time values returned.
The oversample factor is user defined - the maximum number of samples is reduced while the time interval is multiplied by this factor respectively.
For 1 and 2, I highly recommend referring to the ps3000_get_timebase definition in the Programmer's Guide:http://www.picotech.com/document/pdf/ps3000pg-en-2.pdf
The time_interval, time_units and max_samples variables are pointers to data - the driver writes to these memory locations with the values.
3 - get the times (in nanoseconds)
If instead of the ps3000_get_values function, the function ps3000_get_times_and_values (see section 2.4.22 in the Programmer's Guide) were to be called, it would additionally return a pointer to a buffer containing the times between the trigger event and the corresponding sample.
4 - 'and the values (in ADC counts)
The driver will return data from the oscilloscope in the form of ADC count values when the ps3000_get_values function is called; these can then be converted to milliVolts using the adc_to_mv function in the console example.
With regards to calculating the sample rate perhaps you can use the following structure to calculate the time taken to obtain the data:
- Code: Select all
// code to set up buffers etc.
// start timer
// Run Block
// Get Data
elapsedTime = (time2.QuadPart - time1.QuadPart) * 1000000.0 / frequency.QuadPart;
sampling_rate = (totalSamples / elapsedTime) * 1000000.0;
The following web article may be of interest:http://support.microsoft.com/kb/172338
I hope this helps - please let me know if you require any further clarification.