Test and Measurement Forum

Questions about ps3000 C++ example program

Post your C and C++ discussions here

Questions about ps3000 C++ example program

Postby adw » Wed Aug 24, 2011 5:24 pm

Sorry in advance if these are obvious questions, but I trying to understand how the fast streaming example works.

Question 1
In the streamintTests.cpp file, the code below is used 3 times. I'm assuming this is converting all time units to nanoseconds, but if I seclect seconds for the time units, I would get the same caculation as nano seconds. I'm assuming the default case should be time_interval_ns = g_DeviceSetting.sample_setting.interval * 1000 * 1000 * 1000; correct?

Code: Select all
   switch(g_DeviceSetting.sample_setting.time_unit)
   {
   case PS3000_NS:
      time_interval_ns = g_DeviceSetting.sample_setting.interval;
      break;
   case PS3000_US:
      time_interval_ns = g_DeviceSetting.sample_setting.interval * 1000;
      break;
   case PS3000_MS:
      time_interval_ns = g_DeviceSetting.sample_setting.interval * 1000 * 1000;
      break;
   default:
      time_interval_ns = g_DeviceSetting.sample_setting.interval;
   }


Question 2
I don't understand how the sample settings are applied. In the Sample Info dialog box, there are fields for Sample Interval, Sample Time Units, and No. of Samples. For exampele, if I set the Sample Interval to 300, Sample Time Units to Milli, and No. of Samples to 1,000,000. This would mean that I'm collecting 1,000,000 samples/sec every 300 milliseconds?
adw
Newbie
 
Posts: 0
Joined: Wed Aug 24, 2011 4:31 pm

Re: Questions about ps3000 C++ example program

Postby Martyn » Wed Aug 31, 2011 2:00 pm

Q1: The default case should be as it is but there should be another case

Code: Select all
case PS3000_S:
time_interval_ns = g_DeviceSetting.sample_setting.interval * 1000 * 1000 * 1000;
break;


Q2:
The settings are applied by the function ps3000_run_streaming_ns which is called when you Start Streaming
The values are defined as
sample_interval - the time interval, in time_units, between data points.
time_units - the units in which sample_interval is measured.
max_samples - the maximum number of samples that the driver should store from each channel.
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2350
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Questions about ps3000 C++ example program

Postby adw » Thu Oct 20, 2011 12:31 am

Okay, thankyou.

I'm trying to use the example code to sample 5 million samples in 5 seconds. I set the Sample Interval = 1, Sample Time Units = Micro, No of Samples = 5,000,000, Numerator = 1 and Denominator = 1. When I run the gui with these inputs, the ps3000_run_streaming_ns is returning 0. It seems to only work with a No of Samples = 2,097,152 or less.

Could you give me a clue on what I'm doing wrong?
adw
Newbie
 
Posts: 0
Joined: Wed Aug 24, 2011 4:31 pm

Re: Questions about ps3000 C++ example program

Postby searchresults » Thu Oct 20, 2011 5:23 pm

2,097,152 = 2^21....I'm guessing you're reaching the limit of something.

Maybe it's an int/long thing?
searchresults
Newbie
 
Posts: 0
Joined: Thu Oct 06, 2011 7:48 pm

Re: Questions about ps3000 C++ example program

Postby adw » Mon Oct 24, 2011 11:47 pm

short ps3000_run_streaming_ns (
short handle,
unsigned long sample_interval,
PS3000_TIME_UNITS time_units,
unsigned long max_samples,
short auto_stop,
unsigned long noOfSamplesPerAggregate,
unsigned long overview_buffer_size )

Max_samples is an unsigned long, so it can range from 0 to 4,294,967,295. 5,000,000 is well below the limit, so I don't understand why the funtion will not accept anything more than 2 ^21 for this variable.

Is anyone else having this problem?
adw
Newbie
 
Posts: 0
Joined: Wed Aug 24, 2011 4:31 pm

Re: Questions about ps3000 C++ example program

Postby Martyn » Thu Oct 27, 2011 9:00 am

max_samples should only used by the driver to check if the autoStop flag should be set and therefore 5000000 should be fine, however there appears to be an issue with the driver rejecting values greater than 2097152. I have reported this issue to the development team.

It is possible to work around the problem by selecting a max_samples value of 2097152. with auto_stop set to 0, and then stop streaming once you have collected the required number of samples.
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2350
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots


Return to C and C++

Who is online

Users browsing this forum: No registered users and 2 guests