Repeating Triggering 6402c

Post your MATLAB discussions here
tei
Newbie
Posts: 0
Joined: Fri Jun 17, 2016 8:06 am

Repeating Triggering 6402c

Post by tei »

I'm trying to configure a repeating trigger with Matlab 2014b. Therefore I change your Matlab-Streaming Example, but I don't find the configuration point in your documentation to set the trigger to "Repeat". In your PICOScope.GTK.exe there is the possibility to configure the Trigger in that way. At the moment it triggers only once and after this the PicoScope goes to AutoStop-State.
Should I use a different mode than "Streaming" and where can I configure the Trigger to "Repeat".

Thank you in advance.

Hitesh

Re: Repeating Triggering 6402c

Post by Hitesh »

Hi Tei,

The Repeat trigger is a feature of the PicoScope 6 software.

A single capture in the PicoScope 6 software corresponds to the call to ps6000RunBlock() for block captures or ps6000RunStreaming() for streaming mode captures and if you wish to set up a repeat trigger you would call ps6000RunBlock() or ps6000RunStreaming() for however many waveforms you need to capture after setting up the trigger before the first data acquisition run.

In the case of a block mode capture you can segment the memory if you wish.

The mode of data collection will depend on how many samples you need to collect and at what sampling rate.

Regards,

MoJou
Newbie
Posts: 0
Joined: Fri Jan 29, 2016 10:25 am

Re: Repeating Triggering 6402c

Post by MoJou »

Hello,
I've got a similar problem. I try to set a threshold on channel A to for example 1700 mV. Therefore I use the example

Code: Select all

PS4000A_ID_Block_Example.m
where the commands

Code: Select all

set(triggerGroupObj, 'autoTriggerMs', 0);
set(triggerGroupObj, 'delay', 0);
% Channel     : 0 (ps4000aEnuminfo.enPS4000AChannel.PS4000A_CHANNEL_A)
% Threshold   : 1700 (mV)
% Direction   : 2 (ps4000aEnuminfo.enPS4000AThresholdDirection.PS4000A_RISING)
[status.setSimpleTrigger] = invoke(triggerGroupObj, 'setSimpleTrigger', 0, 1700, 2);
are used. (The range was set to +- 5 V.)


If I now run the Program the command line shows

Code: Select all

Copyright (C) Pico Technology Ltd. 2014 - 2015

PicoScope 4000 Series (A API) MATLAB Instrument Driver

Number of units found: 1

Serial number(s): CS570/011

Opening PicoScope 4000 Series device...

   Instrument Device Object Using Driver : picotech_ps4000a_generic.mdd
 
   Instrument Information
      Type:               Oscilloscope
      Manufacturer:       Pico Technology Ltd.
      Model:              PicoScope 4000 Series (A API)
 
   Driver Information
      DriverType:         MATLAB generic
      DriverName:         picotech_ps4000a_generic.mdd
      DriverVersion:      1.1.26
 
   Communication State
      Status:             open

Setting Device Parameters...

Default Channel Setup:-
-----------------------

Channel A:-
	Enabled: True
	Coupling: DC
	Range: 5V
	Analogue Offset: 0.0V

Channel B:-
	Enabled: True
	Coupling: DC
	Range: 5V
	Analogue Offset: 0.0V

Turning off trigger...

Default Block mode parameters:-

               Timebase index : 79
                 Time Interval: 1540.0 ns
 Number of pre-trigger samples: 0
Number of post-trigger samples: 1000000
       Total number of samples: 1000000

Default Streaming mode parameters:-

 Streaming interval: 1.00e-06 s
Streaming auto stop: 1


Initialisation complete.

Connected to PicoScope 4000 Series device:-

      Instrument Model: 4225
   Batch/Serial Number: CS570/0119
     Analogue Channels: 2
             Bandwidth: 20 MHz
         Buffer memory: 250 MS
 Maximum sampling rate: 400 MS/s
 Signal Generator Type: None

runBlock:- Collecting block of data:
	Timebase: 79
	Pre-trigger samples: 0
	Post-trigger samples: 1000000
runBlock: Waiting for device to become ready...
runBlock: Device ready.

getBlockData: Setting up data buffers...
getBlockData: Retrieving data...
getBlockData: Assigning data to array and converting to millivolts.
getBlockData: Data succesfully retrieved.
Connection to PicoScope 4225 with serial number CS570/0119 closed successfully.
Libraries unloaded successfully.
The data is collected without a trigger event. It simply starts gathering data and displays it.

Am I doing something wrong?


Regards

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

Re: Repeating Triggering 6402c

Post by Martyn »

This looks suspect
MoJou wrote:

Code: Select all

Turning off trigger...
I would check the code to see if you are actually setting a trigger
Martyn
Technical Support Manager

MoJou
Newbie
Posts: 0
Joined: Fri Jan 29, 2016 10:25 am

Re: Repeating Triggering 6402c

Post by MoJou »

Yes, I know, it always tells Turning off trigger when using

Code: Select all

connect(ps4000aDeviceObj);
This seems to be the default option for the device.

Code: Select all

Default Channel Setup:-
-----------------------
(...)
Turning off trigger...
But afterwards the trigger is set using the commands

Code: Select all

triggerGroupObj = get(ps4000aDeviceObj, 'Trigger');
triggerGroupObj = triggerGroupObj(1);

set(triggerGroupObj, 'autoTriggerMs', 0);

[status.setSimpleTrigger] = invoke(triggerGroupObj, 'setSimpleTrigger', 0, thresholdvalue, 2);

Regards

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

Re: Repeating Triggering 6402c

Post by Martyn »

What signal are you feeding into the scope, and have you tried with different trigger level values ?
Martyn
Technical Support Manager

MoJou
Newbie
Posts: 0
Joined: Fri Jan 29, 2016 10:25 am

Re: Repeating Triggering 6402c

Post by MoJou »

I am using a Burst-Signal (Sine multiplied by a hamming-window) with arbitrary amplitude. When i use the PicoScope 6 software I can see the signal, and the repeated trigger does work.

Am I trying to set up the same thing with the Matlab-Examples it does not.


Regards


~edit~

I also can add the code, but its more or less the edited block mode example. (I also tried to set the trigger in the streaming-mode example)

Code: Select all

%% PicoScope 4000 Series (A API) Instrument Driver Oscilloscope Block Data Capture Example
% This is an example of an instrument control session using a device 
% object. The instrument control session comprises all the steps you 
% are likely to take when communicating with your instrument. 
%       
% These steps are:
%    
% # Create a device object   
% # Connect to the instrument 
% # Configure properties 
% # Invoke functions 
% # Disconnect from the instrument 
%
% To run the instrument control session, type the name of the file,
% PS4000A_ID_Block_Example, at the MATLAB command prompt.
% 
% The file, PS4000A_ID_BLOCK_EXAMPLE.M must be on your MATLAB PATH. For
% additional information on setting your MATLAB PATH, type 'help addpath'
% at the MATLAB command prompt.
%
% *Example:*
%     PS4000A_ID_Block_Example;
%
% *Description:*
%     Demonstrates how to call functions in order to capture a block of
%     data from a PicoScope 4000 Series Oscilloscope using the underlying
%     'A' API.
%
% *See also:*  | 
%
% *Copyright:* (C) Pico Technology Limited 2014 - 2015. All rights reserved.

%% Suggested Input Test Signal
% This example was published using the following test signal:
%
% * Channel A: 4Vpp, 5Hz sine wave

%% Clear Command Window

clc;

%% Load Configuration Information

PS4000aConfig;

%% Device Connection

% Create a device object. 
% The serial number can be specified as a second input parameter.
ps4000aDeviceObj = icdevice('picotech_ps4000a_generic.mdd', '');

% Connect device object to hardware.
connect(ps4000aDeviceObj);

%% Set Channels

% Default driver settings applied to channels are listed below - 
% use ps4000aSetChannel to turn channels on or off and set voltage ranges, 
% coupling, as well as analogue offset.

% In this example, data is only collected on Channel A so default settings
% are used and channels B to H are switched off.

% Channels       : 1 - 7 (ps4000aEnuminfo.enPS4000AChannel.PS4000A_CHANNEL_B - PS4000A_CHANNEL_H)
% Enabled        : 0
% Type           : 1 (ps4000aEnuminfo.enPS4000ACoupling.PS4000A_DC)
% Range          : 8 (ps4000aEnuminfo.enPS4000ARange.PS4000A_5V)
% Analogue Offset: 0.0

% Execute device object function(s).
[status.setChB] = invoke(ps4000aDeviceObj, 'ps4000aSetChannel', 1, 0, 0, 4, 0.0);

if(ps4000aDeviceObj.channelCount == PicoConstants.QUAD_SCOPE || ps4000aDeviceObj.channelCount == PicoConstants.OCTO_SCOPE)

    [status.setChC] = invoke(ps4000aDeviceObj, 'ps4000aSetChannel', 2, 0, 1, 8, 0.0);
    [status.setChD] = invoke(ps4000aDeviceObj, 'ps4000aSetChannel', 3, 0, 1, 8, 0.0);

end

if(ps4000aDeviceObj.channelCount == PicoConstants.OCTO_SCOPE)

    [status.setChE] = invoke(ps4000aDeviceObj, 'ps4000aSetChannel', 4, 0, 1, 8, 0.0);
    [status.setChF] = invoke(ps4000aDeviceObj, 'ps4000aSetChannel', 5, 0, 1, 8, 0.0);
    [status.setChG] = invoke(ps4000aDeviceObj, 'ps4000aSetChannel', 6, 0, 1, 8, 0.0);
    [status.setChH] = invoke(ps4000aDeviceObj, 'ps4000aSetChannel', 7, 0, 1, 8, 0.0);

end

%% Verify Timebase Index and Maximum Number of Samples
% Driver default timebase index used - use ps4000aGetTimebase2 to query the
% driver as to suitability of using a particular timebase index and the
% maximum number of samples available in the segment selected (the buffer
% memory has not been segmented in this example) then set the 'timebase'
% property if required.
%
% To use the fastest sampling interval possible, set one analogue channel
% and turn off all other channels.
%
% Use a while loop to query the function until the status indicates that a
% valid timebase index has been selected. In this example, the timebase 
% index of 79 is valid. 

% Initial call to ps4000aGetTimebase2 with parameters:
% timebase      : 79
% segment index : 0

status.getTimebase2 = PicoStatus.PICO_INVALID_TIMEBASE;
timebaseIndex = get(ps4000aDeviceObj, 'timebase');

while(status.getTimebase2 == PicoStatus.PICO_INVALID_TIMEBASE)

    [status.getTimebase2, timeIntervalNanoSeconds, maxSamples] = invoke(ps4000aDeviceObj, 'ps4000aGetTimebase2', timebaseIndex, 0);
    
    if(status.getTimebase2 == PicoStatus.PICO_OK)
       
        break;
        
    else
        
        timebaseIndex = timebaseIndex + 1;
        
    end

end

set(ps4000aDeviceObj, 'timebase', timebaseIndex);

%% Set Simple Trigger
% Set a trigger on Channel A, with an auto timeout - the default value for
% delay is used.

% Trigger properties and functions are located in the Instrument
% Driver's Trigger group.

triggerGroupObj = get(ps4000aDeviceObj, 'Trigger');
triggerGroupObj = triggerGroupObj(1);

% Set the autoTriggerMs property in order to automatically trigger the
% oscilloscope after 1 second if a trigger event has not occurred. Set to 0
% to wait indefinitely for a trigger event.

set(triggerGroupObj, 'autoTriggerMs', 0);
set(triggerGroupObj, 'delay', 0);
% Channel     : 0 (ps4000aEnuminfo.enPS4000AChannel.PS4000A_CHANNEL_A)
% Threshold   : 500 (mV)
% Direction   : 2 (ps4000aEnuminfo.enPS4000AThresholdDirection.PS4000A_RISING)

[status.setSimpleTrigger] = invoke(triggerGroupObj, 'setSimpleTrigger', 0, 500, 2);

%% Set Block Parameters and Capture Data
% Capture a block of data and retrieve data values for Channel A.

% Block data acquisition properties and functions are located in the 
% Instrument Driver's Block group.

blockGroupObj = get(ps4000aDeviceObj, 'Block');
blockGroupObj = blockGroupObj(1);

% Set pre-trigger and post-trigger samples as required
% The default of 0 pre-trigger and 1 million post-trigger samples is used
% in this example.

% set(ps4000aDeviceObj, 'numPreTriggerSamples', 0);
% set(ps4000aDeviceObj, 'numPostTriggerSamples', 2e6);

%%
% This example uses the _runBlock_ function in order to collect a block of
% data - if other code needs to be executed while waiting for the device to
% indicate that it is ready, use the _ps4000aRunBlock_ function and poll
% the _ps4000aIsReady_ function.

% Capture a block of data:
%
% segment index: 0 (The buffer memory is not segmented in this example)

[status.runBlock] = invoke(blockGroupObj, 'runBlock', 0);

% Retrieve data values:
%
% start index       : 0
% segment index     : 0
% downsampling ratio: 1
% downsampling mode : 0 (ps4000aEnuminfo.enPS4000ARatioMode.PS4000A_RATIO_MODE_NONE)

% Provide additional output arguments for the remaining channels e.g. chB
% for Channel B
[numSamples, overflow, chA] = invoke(blockGroupObj, 'getBlockData', 0, 0, 1, 0);

% Stop the device
[status.stop] = invoke(ps4000aDeviceObj, 'ps4000aStop');

%% Process Data
% Plot data values returned from the device.

figure1 = figure('Name','PicoScope 4000 Series Example - Block Mode Capture', ...
    'NumberTitle', 'off');

% Calculate sampling interval (nanoseconds) and convert to milliseconds
% Use the timeIntervalNanoSeconds output from the ps4000aGetTimebase2
% function or calculate it using the main Programmer's Guide.

timeNs = double(timeIntervalNanoSeconds) * double(0:numSamples - 1);
timeMs = timeNs / 1e6;

% Channel A
plot(timeMs, chA);

title('Block Data Acquisition');
xlabel('Time (ms)');
ylabel('Voltage (mV)');

grid on;
legend('Channel A');

%% Disconnect Device
% Disconnect device object from hardware.
disconnect(ps4000aDeviceObj);
delete(ps4000aDeviceObj);

Hitesh

Re: Repeating Triggering 6402c

Post by Hitesh »

Hi Mojou,

Which version of the ps4000a dll are you using?

Is it possible to see what the input signal looks like when using PicoScope 6?

Regards,

MoJou
Newbie
Posts: 0
Joined: Fri Jan 29, 2016 10:25 am

Re: Repeating Triggering 6402c

Post by MoJou »

Hi,

attached you can see a measurement where I am sending a weighted sine pulse and the corresponding signal on the second channel. There is no problem with the trigger-settings.

Actually I am using the 64Bit dll files from the SDK but I don't know where to look up the version number.


Regards
Attachments
Repeated Trigger in PicoScope 6
Repeated Trigger in PicoScope 6

Hitesh

Re: Repeating Triggering 6402c

Post by Hitesh »

Hi MoJou,

After running some tests, it looks as though this might have been an issue with the driver (to check the version number, right-click the ps4000a.dll, select Properties and then click on the Details tab).

The dll should be located in the C:\Program Files\Pico Technology\SDK\lib folder

Please could you e-mail support@picotech.com and I will look to provide you with updated drivers which should resolve the issue.

Regards,

MoJou
Newbie
Posts: 0
Joined: Fri Jan 29, 2016 10:25 am

Re: Repeating Triggering 6402c

Post by MoJou »

Hi,

with the updated driver dll files it works great. Do I have any chance to get absolute time information when I start a triggered measurement? For example I start a measurement but my Trigger occurs after 30 seconds. Is it possible to get this information (First Trigger at 30 sec, second Trigger at 120 sec and so on...)?


Regards

Hitesh

Re: Repeating Triggering 6402c

Post by Hitesh »

Hi MoJou,

Unfortunately, the driver for the PicoScope that you are using does not provide a trigger timestamping feature.

The device will indicate that it is ready when it has completed data collection i.e. completed collection of all samples in that run.

Regards,

MoJou
Newbie
Posts: 0
Joined: Fri Jan 29, 2016 10:25 am

Re: Repeating Triggering 6402c

Post by MoJou »

Hi Hitesh,

does the PicoScope 5444B support the timestamp feature?

Regards
MoJou

Hitesh

Re: Repeating Triggering 6402c

Post by Hitesh »

Hi MoJou,

Not at the present moment but I can add this to a feature request.

It is available for the PicoScope 3000 Series and work has been carried out for the PicoScope 6000 Series but is in the process of being tested.

Regards,

MoJou
Newbie
Posts: 0
Joined: Fri Jan 29, 2016 10:25 am

Re: Repeating Triggering 6402c

Post by MoJou »

Hi Hitesh,

it would be great if you could add this feature. Actually i am using the streaming-mode and check for a certain threshold. If this threshold is exceeded the program writes the data into a binary file. So this is a kind of soft- trigger which is highly computationally expensive.


Regards

Post Reply