Can get only half of 32M samples (Picoscope 4226)

Post your C and C++ discussions here
Post Reply
Oscar
Newbie
Posts: 0
Joined: Mon Mar 18, 2013 7:10 pm

Can get only half of 32M samples (Picoscope 4226)

Post by Oscar »

Hello.

I have modified the C/C++ ps4000con.c script to control a Picoscope 4000 series. It initializes the settings, runs a loop, detecting a window-exit trigger, saving a block to a file, return to the loop.
In our new application we want to have the maximum sample rate and maximum number of samples. The 4226 is a two-channel scope which should be capable of a total of 32 megasamples (256 ms @ 8 ns interval for one channel, 128 ms @ 8 ns for two channels, 256 ms @ 16 ns for two channels). However, when I set the BUFFER_SIZE to 32000000 it comes up with strange values, or no values at all, in the timebase selection query. It does not run properly or crash if I select "1". Setting the buffer to 16000000 works, but obviously gives only half the amount of data.

Do you have any suggestions I should try in order to get the 32 MS?

Oscar

Hitesh

Re: Can get only half of 32M samples (Picoscope 4226)

Post by Hitesh »

Hello Oscar,

If you are trying to capture 32MS with one channel e.g. Ch A, you will need to explicitly turn off Channel B.
If Channel A and B are both enabled, then the buffer memory is shared so the maximum would be just over 16MS per channel.

It is possible to obtain 32MS using the console application with a timebase of 1 with the dlls provided in the current SDK (10.5.0.11).

I hope this helps.

Oscar
Newbie
Posts: 0
Joined: Mon Mar 18, 2013 7:10 pm

Re: Can get only half of 32M samples (Picoscope 4226)

Post by Oscar »

Thanks for your reply. I'm trying to make sure it uses the dll file from the SDK. It previously used the dll from the installed Picoscope 6 software. I uninstalled Picoscope 6 now, but when I want to select the SDK system/x86 folder as location for the driver, the installation fails with "a service installation section in this INF is invalid". I run this in XP mode to compile this in 32-bits, I could not compile it properly with my 64-bits Windows 7, it complained about the dll.

It does not appear to make a difference when (using the Picoscope 6 driver) I moved the channel voltage/disable selection before the timebase selection. I suppose these settings need to be applied to the device, if these functions did not do so already.

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

Re: Can get only half of 32M samples (Picoscope 4226)

Post by Martyn »

If you can post your code we can take a look for you.
Martyn
Technical Support Manager

Oscar
Newbie
Posts: 0
Joined: Mon Mar 18, 2013 7:10 pm

Re: Can get only half of 32M samples (Picoscope 4226)

Post by Oscar »

I reinstalled Picoscope 6.
By adding this line before asking for the settings in the program I get a normal timebase list even when I set BUFFER_SIZE to 32000000:

unit.channelSettings[1].enabled = FALSE;
SetDefaults(&unit); /* this line was already there.

But if I choose 256 ms @ 8 ns (timebase 1) for channel A only, or 256 ms @ 16 ns for A and B together, then I do not hear a click in the device when detection mode is started, and it does not trigger on anything.

I have uploaded the code here:
http://www.lightningwizard.com/research ... 4000_adv.c

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

Re: Can get only half of 32M samples (Picoscope 4226)

Post by Martyn »

You may have

Code: Select all

	unit.channelSettings[1].enabled = FALSE; 
	SetDefaults(&unit);
but just below you have

Code: Select all

	    for (i = 0; i < MAX_CHANNELS; i++)
		{
			if (unit.channelSettings[i].range!=99) unit.channelSettings[i].enabled = TRUE; else unit.channelSettings[i].enabled = FALSE;
		}
which will re enable the channel if the range is not 99 (off)
Martyn
Technical Support Manager

Oscar
Newbie
Posts: 0
Joined: Mon Mar 18, 2013 7:10 pm

Re: Can get only half of 32M samples (Picoscope 4226)

Post by Oscar »

Yes, but that line is only executed if it can open a file settings.cfg. Else (after line 832) it asks the user to provide the settings. There it calls:

Code: Select all

set_voltages(&unit);
timeintv_ns = SetTimebase(unit);
It then stores the settings in a text file, makes sure it does not request more samples than BUFFER_SIZE and sets up an advanced trigger, after which it applies this in line 932:

Code: Select all

pretriggersamples = (long)(pretrigger_pct*0.01 * sampleCount); // global variable used in triggered block data collection
SetTrigger(unit.handle, &sourceDetails, 1, &conditions, 1, &directions, &pulseWidth, 0, 0, 0); 
After which it calls CollectBlockTriggered(&unit).

Oscar
Newbie
Posts: 0
Joined: Mon Mar 18, 2013 7:10 pm

Re: Can get only half of 32M samples (Picoscope 4226)

Post by Oscar »

Here is a screen capture of the original program, only modified to have a BUFFER_SIZE of 32000000 instead of 1024.
Just to see if it were any modifications I made. It does not appear so.
http://www.lightningwizard.com/research/PS4000con.PNG

I disabled channel B (99), then chose timebase, but it does not give the list of values. I chose 1, but it is a strange number.
At 16 MS also no list but when I select 1 it picks 8 ns. It does not give a click and it does not trigger.
At 8 MS also no list but when I select 1 it picks 8 ns. It gives a click and it triggers. But, it listed "timebase: 6".

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

Re: Can get only half of 32M samples (Picoscope 4226)

Post by Martyn »

I will check this out more closely when I am back in the office tomorrow.
Martyn
Technical Support Manager

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

Re: Can get only half of 32M samples (Picoscope 4226)

Post by Martyn »

I have made one change in the RunBlock and it now works. You had preTrigger and Total, not preTrigger and postTrigger, so it was throwing an error code 14 and the scope wasn't running so would never return ready even if there was a trigger signal.

Code: Select all

	status = ps4000RunBlock(unit->handle, pretriggersamples, sampleCount - pretriggersamples, timebase, oversample,	&timeIndisposed, 0, CallBackBlock, NULL);
Martyn
Technical Support Manager

Oscar
Newbie
Posts: 0
Joined: Mon Mar 18, 2013 7:10 pm

Re: Can get only half of 32M samples (Picoscope 4226)

Post by Oscar »

Many thanks for your help! It works. I'm able to get up to 33554226 samples now!
Best regards,
Oscar

Post Reply