Wrapper dll for 6000a series

Forum for discussing PicoScope version 6 (non-automotive version)
Post Reply
dbsmith
Newbie
Posts: 1
Joined: Mon Oct 04, 2021 4:06 am

Wrapper dll for 6000a series

Post by dbsmith »

Hello,

I am working on a project using the 6424E in LabView, and I need to run in streaming mode for high speed data capture. I notice that the programming guides and SDK's have streaming examples that avoid callbacks using wrapper dll's, up to the 6000 series. However, the 6000a series programming guide does not mention the wrapper functions, there is no ps6000awrap.dll analogous to the ps6000wrap.dll, and the LabView example conspicuously is missing any Streaming example code.

I've tried building a program that relies upon the ps6000wrap.dll in the hopes that it was compatible, but upon executing the GetStreamingLatestValues function I get a PICO_INVALID_HANDLE status code, even though I'm providing the valid handle. I'm assuming this is because the 6000 series dll cannot communicate with the 6000a series scope.

My question- is there a ps6000aWrap.dll available, or alternatively another way of building a streaming mode application in a LabView environment?

Thanks

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

Re: Wrapper dll for 6000a series

Post by Martyn »

You don't need to use a wrapper with the 6000a driver as it works differently to previous models and does not use a callback.

The function call ps6000aGetStreamingLatestValues will return PICO_OK whilst the buffer is filling with data, and then PICO_WAITING_FOR_DATA_BUFFERS when that buffer is full. At this point you can give the driver a new buffer to fill using the function call ps6000aSetDataBuffer and you can then process the buffer that has already been filled with data. This approach allows your application to process fixed size blocks of data when streaming.

If you need assistance with writing a streaming example please email support@picotech.com
Martyn
Technical Support Manager

dbsmith
Newbie
Posts: 1
Joined: Mon Oct 04, 2021 4:06 am

Re: Wrapper dll for 6000a series

Post by dbsmith »

Martyn,

Thanks for your prompt reply. I've made progress in adapting a streaming VI for the 6000a series according to the programmer's guide, but am still running into problems. For reference, I'm trying to collect 10k samples at 3.2ns resolution from channel A after a trigger signal that occurs on channel D every ~300us, translating to a ~33MS/s transfer rate across my USB 3.0. I need this to run continuously, and to be able to read the buffers without interrupting the capture of new samples.

Referring to the 6000a Series programmer's guide, section 2.6.3.1, I've made it through a single iteration through step 6. I can open the unit, configure the channels, and configure the triggers. Worrying just about
setting a single buffer for channel A at the moment, I call ps6000aSetDataBuffer(), ps6000aRunStreaming(),
ps6000aGetStreamingLatestValues(), and am able to read the buffer, extracting a subarray based on the trigger data returned by ps6000aGetStreamingLatestValues(). However, as described in the guide, ps6000aGetStreamingLatestValues() will eventually return a PICO_WAITING_FOR_DATA_BUFFERS status code after several iterations. At this stage, I try to loop my code back around to step 4 as instructed, starting again with ps6000aSetDataBuffer(). However, calling ps6000aSetDataBuffer again returns a status code 413, 19D in hex, corresponding to PICO_REMOVING_DATA_BUFFER_ENTRIES_NOT_ALLOWED_WHILE_DATA_PROCESSING. Relying on the trigger data returned by GetStreamingLatestValues, I make sure to copy the relevant subarray containing my desired samples before calling SetDataBuffer, so I don't think I'm generating any race conditions. I assume that a continuous mode with minimal lag requires that I set autoStop = false. I have tried providing buffers of different sizes compared to my sample size of 10k, including 10k 50k 100k and 1M, to no effect. I have tried setting up multiple memory segments and rotating through them.I have also tried removing the triggering channel D temporarily and relying on a 300us autotrigger. Finally, I have tried calling ps6000aStop before refreshing the buffer, but this both contradicts the programming guide and introduces significant lag time during the refresh. I'm at a bit of a loss as to how to proceed from here.

Can you please provide a 32 bit PicoScope6000aExampleStreaming.vi or equivalent guidance, or otherwise advise how to handle configuring and refreshing the buffer for a single channel download.

Thanks again

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

Re: Wrapper dll for 6000a series

Post by Martyn »

Use two buffers A and B, start off by giving Buffer A to the driver to fill, when full tell the driver to start filling Buffer B whilst you process the data in Buffer A. When Buffer B is full tell the driver to start using Buffer A again as you have processed the data and it can be reused. Keep repeating this indefinitely.
Martyn
Technical Support Manager

dbsmith
Newbie
Posts: 1
Joined: Mon Oct 04, 2021 4:06 am

Re: Wrapper dll for 6000a series

Post by dbsmith »

Martyn,

As best as I can tell, that's exactly what I'm doing but I still get an error. Here is my pseudocode-

Code: Select all

ps6000aOpenUnit
ps6000aSetChannelOn //Set chA only
ps6000aSetSimpleTrigger //300us autotrigger
do //Referred to as outer loop in discussion
	Buffer b = new Buffer //Length = 100k
	ps6000aSetDataBuffer //Feed it the fresh Buffer b
	ps6000aRunStreaming //3.2ns timebase, 10k post-trigger samples, no autostop, no downsampling
	do //Referred to as inner loop in discussion
		int status = ps6000aGetStreamingLatestValues
		Buffer b2 = subarray of b //subarray built using parameters from returned trigger Struct
		Display b2 on waveform graph
		boolean doStop = check stop button for press
	while status != PICO_WAITING_FOR_DATA_BUFFERS && !doStop
while !doStop
ps6000aStop
ps6000aCloseUnit
Everything executes fine up through the end of the first iteration of the outer loop. The first time the inner loop returns a code that the buffer is full, I enter the outer loop a second time. However, ps6000aSetDataBuffer returns the 0x19D status code the second time it's called, even though I feed it a unique buffer.

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

Re: Wrapper dll for 6000a series

Post by Martyn »

You only need to call RunStreaming once, so I have made some changes to your pseudo code

Code: Select all

ps6000aOpenUnit
ps6000aSetChannelOn //Set chA only
ps6000aSetSimpleTrigger //300us autotrigger
Buffer a = new Buffer //Length = 100k
Buffer b = new Buffer //Length = 100k
ps6000aSetDataBuffer //Feed it the Buffer a to start
ps6000aRunStreaming //3.2ns timebase, 10k post-trigger samples, no autostop, no downsampling

do //Referred to as outer loop in discussion
	do //Referred to as inner loop in discussion
		int status = ps6000aGetStreamingLatestValues
		boolean doStop = check stop button for press
	while status != PICO_WAITING_FOR_DATA_BUFFERS && !doStop
	
	ps6000aSetDataBuffer //Feed the next buffer if currently a use b if b use a

	Display a or b on waveform graph // You can now process the buffer with data in it

while !doStop
ps6000aStop
ps6000aCloseUnit
Martyn
Technical Support Manager

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

Re: Wrapper dll for 6000a series

Post by Martyn »

Can you confirm what you are passing each time as the last parameter in the SetDataBuffer call, this is the ACTION parameter.
Martyn
Technical Support Manager

dbsmith
Newbie
Posts: 1
Joined: Mon Oct 04, 2021 4:06 am

Re: Wrapper dll for 6000a series

Post by dbsmith »

Martyn,

As per the instructions in the programming guide, I had been mistakenly repeating the first call to SetDataBuffer and StartStreaming, making no changes but to pass a new buffer. This call, borrowing components from other LabView examples, included as the action parameter PICO_CLEAR_ALL || PICO_ADD, and I believe that the PICO_CLEAR_ALL component was triggering the error. I've refactored my code to follow your changes, and made sure that subsequent calls to SetDataBuffer after the first only include the PICO_ADD action, and everything seems to be behaving.

For future reference, when writing the programmer's guide for this section, I would suggest that you rephrase the "2.6.3.1 Using streaming mode" section to include a second instruction to call SetDataBuffer when the buffers fill, rather than looping back to the initial call. This would draw attention to the fact that 1. you don't call StartStreaming a second time, and 2. subsequent SetDataBuffer calls can have different input parameters, not just a new buffer.

Thanks for your help, you've been a lifesaver!

Post Reply