PicoScope 3000Series Pretrigger in Streaming Mode

Post your MATLAB discussions here
Post Reply
Dome1985
Newbie
Posts: 0
Joined: Thu Apr 03, 2014 9:19 am

PicoScope 3000Series Pretrigger in Streaming Mode

Post by Dome1985 »

Hello all,

I am using the PicoScope 3000 Series with the SDK of Matlab.

It works quite good, but for some reason the Pretrigger condition doesn´t work.

I am using the following example of the SDK:

PS3000a_IC_Generic_Driver_2buffers_Streaming_SimpleTrig.m

Even if i change the variable maxPreTriggerSamples from 0 to as example 100, it doesn´t work.
If i look into the plot i have the whole data, and not as expected 100 samples before the trigger occures.

Thanks for any help.

Domew1985

Hitesh

Re: PicoScope 3000Series Pretrigger in Streaming Mode

Post by Hitesh »

Hi Dome1985,

In streaming mode, the device begins to collect data as soon as the ps3000aRunStreaming function is called.

You will need to keep track of the samples being collected and discard anything that you do not require prior to the number of pre-trigger samples.

Hope this helps.

Dome1985
Newbie
Posts: 0
Joined: Thu Apr 03, 2014 9:19 am

Re: PicoScope 3000Series Pretrigger in Streaming Mode

Post by Dome1985 »

Thank you Hitesh,

okay i understand. But the function ps3000aRunStreaming expect the variable MaxPreTriggerSamples as an Input.

So the example PS3000a_IC_Generic_Driver_2buffers_Streaming_SimpleTrig.m doesn´t work with an maxpretriggersample value higher than 0 ? (I think yes, because when the RunStreaming function gets called, it doesn´t process the correct data)

Do you have an example for the streaming mode for a pretriggervalue as example 100 ?

Thank you.
Dome1985

Hitesh

Re: PicoScope 3000Series Pretrigger in Streaming Mode

Post by Hitesh »

Hi Dome1985,

Are you expecting the data that is returned from streaming to only consist of pre-trigger and post-trigger samples?

If so, you won't necessarily get this with streaming capture. As I mentioned previously, data collection begins immediately, so if your trigger occurs sometime later, there may be some data prior to the amount of pre-trigger samples, which is why you would have to process the data.

Depending on the length of time that you are capturing data over, you could consider using a block mode capture where it will only capture pre- and post-trigger samples if you are happy to wait for the data to be collected before it is transferred to the PC.

Hope this helps.

Dome1985
Newbie
Posts: 0
Joined: Thu Apr 03, 2014 9:19 am

Re: PicoScope 3000Series Pretrigger in Streaming Mode

Post by Dome1985 »

Hello,

i am using the streaming mode.
i developed a pre and posttrigger algorithm which works like the first in first out (FIFO) principle for the pretrigger data which i write into my pretrigger vector. It is pretty complicated to explain it by writing, but i want to try it.

I had a look in each cell of the vector and it adds the samples or the group of samples into my pretriggervector till it is "full". The size of this vector depend on to the samplerate, as example i have 50 microseconds as a samplerate and i want to have a pretrigger time of 1 second, the size will be: 20000 = 1second / 50us, so each cell to the next cell have a timedistance of 50us.

Then i also had a look at the whole size of the "group of samples" which i got from the driver, sometimes it is bigger then the pretriggervector and sometimes not. Dependence to that i write the correct data into my pretriggervector.

Is it correct that if i got a group of samples the latest one is on the last position of this vector and the oldest one on the first position?

Is there any bug or problem with the streaming mode and the group of samples? Why is it possible to define a pre and postrigger amount by calling this Runstreaming function, if i can not use it?

Thanks
Dom

Dome1985
Newbie
Posts: 0
Joined: Thu Apr 03, 2014 9:19 am

Re: PicoScope 3000Series Pretrigger in Streaming Mode

Post by Dome1985 »

Hey,

in addition to the topic above, is there any known mistake regarding the start and end indices of the callback of the function:

invoke(app.ps3206B_obj, 'AvailableData'); ?

Dom

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

Re: PicoScope 3000Series Pretrigger in Streaming Mode

Post by Martyn »

If I understand correctly the following will help

The scope will stream data as soon as you issue the run streaming call. If you have pretrigger samples set this is instructing the device to collect a minimum number of samples before indicating that a trigger has occurred.

This means that it is possible to collect many more values than the value defined by pretrigger samples if you continually ask for data within your application. Your application needs to take account of this and look for the indication of a trigger in the callback.

As an example of this set our PicoScope 6 software into streaming mode and ensure that the trigger diamond is above or below the signal level. The trace will draw up to the trigger diamond and will then continually scroll left from that point, like a chart recorder, now change the signal so that the voltage passes through the trigger diamond at which point the trace will continue until the end of the display.
Martyn
Technical Support Manager

Dome1985
Newbie
Posts: 0
Joined: Thu Apr 03, 2014 9:19 am

Re: PicoScope 3000Series Pretrigger in Streaming Mode

Post by Dome1985 »

Hello,

thanks for your information. With the PicoScope 6 Software it works as expected, but i need this in my application by using the SDK with Matlab by using the streaming mode.

I doublechecked the start and end indizes of this function: invoke(ps3206B_obj, 'AvailableData');
and i chose the maxbuffersize where the driver saves the group of samples 4-5 times bigger then the amount of samples in each group.

I looked inside of the these two vectors:

valuesNoneChA = get(dataChA.pBufferNoneA, 'Value');
dataOfOneRun = valuesNoneChA(firstValuePosn:lastValuePosn, 1);

and my algorithm takes the right information of the data, depending on the index where the trigger occurs.
But it still doens´t work. Could it be possible that if i choose a sampling rate of 100 ns, that the sampler inside of the PicoScope samples the data with another samplerate, (maybe next to 100ns, as example 96ns or 105ns?)

This would solve my problem, because then i have to choose my size of each vector a little bit higher/lower.
Is there any information about?

Thanks.
Dom

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

Re: PicoScope 3000Series Pretrigger in Streaming Mode

Post by Martyn »

Are you using the latest wrapper that copies data into an application buffer, or are you using the older version which is known to have an issue with data corruption, and possibly the trigger index ?
Martyn
Technical Support Manager

Dome1985
Newbie
Posts: 0
Joined: Thu Apr 03, 2014 9:19 am

Re: PicoScope 3000Series Pretrigger in Streaming Mode

Post by Dome1985 »

I am using the sdk version : PS3000asdk_r10_5_0_29
and i think i define an application buffer with this function:

invoke(ps3206B_obj, 'ps3000aSetDataBuffer', ...
Channel_A, ...
dataChA.pBufferNoneA, ...
MaxBufferSizeChA, ...
SegmentIndex, ...
enuminfo.enPS3000ARatioMode.PS3000A_RATIO_MODE_NONE);

If i understand something wrong regarding the application buffer, then let me know.

Unfortunately, if i update my sdk version, i can´t connect my picoscope anymore so, never change a "running" (connected) system.

Dom

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

Re: PicoScope 3000Series Pretrigger in Streaming Mode

Post by Martyn »

We have r10_5_0_19, r10_5_0_28 and r10_5_0_32

You will need to be using r10_5_0_32 otherwise it will be difficult for us to support you as we have already fixed an issue with streaming data that was present in the two earlier versions. I believe you may have already been provided with a sample piece of code, based on this later version, that has worked.
Martyn
Technical Support Manager

Dome1985
Newbie
Posts: 0
Joined: Thu Apr 03, 2014 9:19 am

Re: PicoScope 3000Series Pretrigger in Streaming Mode

Post by Dome1985 »

hello,

ok, i will give it a try to download the latest one. I already tried it in the past and try to connect and copy the right files to the right places, but in the past it doesn´t work.

Maybe you can have a look at my system too:

I have windows 7 64 bit, but i use 32 bit Matlab Version so i copy all the files of 32 bit of the latest version PS3000asdk_r10_5_0_32 to this place like this link describes it:

http://www.youtube.com/watch?v=5HFnmki3IdY (Search name in youtube is: PicoScope - how to get started using the MATLAB instrument drivers )

Then i updated my picoScope driver in the device manager to the version: 2.0.3.8

and i downloaded the Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 SP1

In the end i set the path like in the youtube link described, is this allright or did i forget something?

Thanks.

Dom

Dome1985
Newbie
Posts: 0
Joined: Thu Apr 03, 2014 9:19 am

Re: PicoScope 3000Series Pretrigger in Streaming Mode

Post by Dome1985 »

Hey,

so i tried since yesterday to connect PicoScope 3206B and it says almost everytime:

Warning: The library name case did not match the file name.
The library will be named "ps3000a".
Warning: The library class 'ps3000a' already exists. Use a classname alias.
Error using instrument/delete (line 82)
Operation failed: An error occurred while executing the driver disconnect code.
Library was not found
If this error is not an instrument error, use MIDEDIT to inspect the driver.

Error in icdevice (line 278)
delete(obj);

Error in PS3000a_IC_Generic_Driver_2buffers_Streaming_SimpleTrig (line 58)
ps3000a_obj = icdevice('PS3000a_IC_drv', ''); % Specify serial number as 2nd argument if required.

I add paths in Matlab: C:\Pico SDK\PS3000asdk_r10_5_0_32 with all subfolders, and i did all the things as i described, now i have no idea anymore. Could anybody tell me what i should do?
(I did not connected the PicoScope without disconnecting it)

It is almost like a coincidence, because if i set the path in a special order, sometimes it works and sometimes not.

I am under strom time pressure, so please give me a good advice.

Thanks

Dom

Hitesh

Re: PicoScope 3000Series Pretrigger in Streaming Mode

Post by Hitesh »

Hi Dom,

Please rename ps3000a.dll to PS3000a.dll. The Instrument driver is expecting the dll to be named with a capital 'PS'.

You do not need the Microsoft Software Development Kit 7.1 as you are using a 32-bit version of MATLAB. You should use the lcc-win32 C compiler when you run mex -setup in MATLAB.

The warning you are getting is because an attempt to load the library ps3000a.dll has been made for a second time. The error is because PS3000a.dll cannot be found.

Note that if the dlls are in the same folder as the Instrument Driver, the only paths you need to set are to the Functions folder and the PicoConstants.m and PicoStatus.m file.

I will send an updated streaming example (which you should already have) via your e-mail support ticket.

Thanks,

Post Reply