GetTimeBase and 4227 Scopes (timebase = 4 ns)

Post any questions you may have about our current range of oscilloscopes
Post Reply
rbreese

GetTimeBase and 4227 Scopes (timebase = 4 ns)

Post by rbreese » Mon Jun 27, 2011 9:35 pm

I have recently purchased a 4227 picoscope -- I bought the 4227 instead of the 4226 because of its higher sampling rate of 250 M/s

I have been experimenting with the C# demo in the PS4000 SDK. I noticed that in running the demo, that the code would not let you specify a 0 value for the timebase in the GetTimeBase function call. I figured that they wanted the demo to work with either the 4226 or 4227 as the SDK documentation notes that the 0 value is only for 4227 scopes.

However, when I changed the example code to pass in a '0' value for timebase, I get a returned status of PICO_INVALID_TIMEBASE from the GetTimeBase function call. I have the latest SDK and the PDF documentation indicates that a timebase of 0 is valid for 4227 scopes (the demo correctly identifies that I have a 4227 scope attached).

This essentially means that the extra money that I spent for the 4227 is wasted as I can't access the fastest timebase under program control.

Are there any plans to update the ps4000.dll to allow a value of '0' for the GetTimeBase call for 4227 scopes?

Chris
Site Admin
Site Admin
Posts: 169
Joined: Tue Aug 17, 2010 9:00 am
Location: St. Neots

Re: GetTimeBase and 4227 Scopes (timebase = 4 ns)

Post by Chris » Tue Jun 28, 2011 7:46 am

The scope will work on timebase 0 if only 1 channel is enabled.

Channels are enabled by default, so you need to turn off the channel you're not using.

-Chris.

rbreese

Re: GetTimeBase and 4227 Scopes (timebase = 4 ns)

Post by rbreese » Tue Jun 28, 2011 4:04 pm

Thanks for the reply. I was using two channels because I really need to use an external trigger, but the API does not seem to allow use of the external trigger signal. So, I was using one of the channels as a trigger channel.

So, is there a way in the API to trigger using the external trigger input where there is only one channel enabled? It does not look like it from the API documentation.

Chris
Site Admin
Site Admin
Posts: 169
Joined: Tue Aug 17, 2010 9:00 am
Location: St. Neots

Re: GetTimeBase and 4227 Scopes (timebase = 4 ns)

Post by Chris » Thu Jun 30, 2011 2:06 pm

Yes, you can trigger on the external signal.

To amend the C# example in the SDK...


Imports.TriggerConditions[] conditions = new Imports.TriggerConditions[] {
new Imports.TriggerConditions(Imports.TriggerState.DontCare,
Imports.TriggerState.DontCare,
Imports.TriggerState.DontCare,
Imports.TriggerState.DontCare,
Imports.TriggerState.True, // external input
Imports.TriggerState.DontCare,
Imports.TriggerState.DontCare)};


Note: The external input has a fixed voltage range of +/-20V, so to set the the triggerVoltage for the tTriggerChannelProperties structure, use...

short triggerVoltage = mv_to_adc(1500, 10); // 1500 = 1.5v trigger level, 10 = inputRanges[10] = 20000 = 20V

rbreese

Re: GetTimeBase and 4227 Scopes (timebase = 4 ns)

Post by rbreese » Wed Jul 06, 2011 3:31 pm

I have had no success in getting the external trigger to actually work with the SDK. I have tried modifying both the C example (PS4000con.c) and the C# example and both give the same results, in that trying to use the external trigger results in the scope automatically triggering (ie. the block trigger code returns immediately indicating a trigger regardless of what is actually happening on the external input).

I modified the C code in the CollectBlockTriggered example to be:

Code: Select all

   short	triggerVoltage = mv_to_adc(1000,	PS4000_20V); // External fixed at +/- 20V
	struct tTriggerChannelProperties sourceDetails = {	triggerVoltage, 10, triggerVoltage,	10, PS4000_EXTERNAL,LEVEL };

	struct tTriggerConditions conditions = {CONDITION_DONT_CARE, CONDITION_DONT_CARE,CONDITION_DONT_CARE,CONDITION_DONT_CARE, CONDITION_TRUE, CONDITION_DONT_CARE,CONDITION_DONT_CARE };

	struct tPwq pulseWidth;
	
	struct tTriggerDirections directions = {	NONE,NONE,NONE,	NONE,RISING,  NONE };

The trigger signal is a 3.3 V pulse that is about 2 us wide. The only way that I can get the code to NOT trigger immediately is to provide a negative value for the trigger voltage (but then, the code never triggers). It would be nice to know how to use the external trigger with the SDK. I have no problem using the external trigger with the PicoScope front end.

FYI:
a. Your value for PS4000_MAX_VALUE (used by mv_to_adc function) is inconsistent between the C code example and the C# example. In the C code (ps4000api.h), the value is 32764, in the C# example (ps4000imports.cs) it is 32512 --- I assume the C example is correct and the C# example is wrong (unless it is a case of the lower 8 bits being a don't care which I would not understand in that case).

b. Your C code function 'BlockDataHandler' never initializes 'fp' to NULL, so if the Block collection is aborted by the user by a key press, the code crashes when a fclose attempt is made on a garbage 'fp' value.

Chris
Site Admin
Site Admin
Posts: 169
Joined: Tue Aug 17, 2010 9:00 am
Location: St. Neots

Re: GetTimeBase and 4227 Scopes (timebase = 4 ns)

Post by Chris » Thu Jul 07, 2011 4:05 pm

If it works ok using Picoscope6, check that the C# application is using the same ps4000.dll.

If it is, and it still doesn't work, please email support@picotech.com to arrange checking of the device.

MaxValue = 32764 for the 4000 series scopes.
The C# code has been modified, and ps4000.c has fp is initialised to NULL in the next release of the sdk ( > 10.1.0.17)

Post Reply