Code covered by the BSD License  

Highlights from
PicoScope® 2000 Series - MATLAB® Generic Instrument Driver

image thumbnail

PicoScope® 2000 Series - MATLAB® Generic Instrument Driver

by

 

01 Feb 2013 (Updated )

MATLAB Instrument Driver for use with PicoScope 2000 Series oscilloscopes (Beta Release)

PS2000_IC_Generic_Driver_GetBlock.m
%PS2000_IC_GENERIC_DRIVER_GETBLOCK Code for communicating with an instrument. 
%  
%   This is a modified version of the machine generated representation 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:
%       
%       1. Create a device object   
%       2. Connect to the instrument 
%       3. Configure properties 
%       4. Invoke functions 
%       5. Disconnect from the instrument 
%  
%   To run the instrument control session, type the name of the file,
%   PS2000_IC_Generic_Driver_GetBlock, at the MATLAB command prompt.
% 
%   The file, PS2000_IC_GENERIC_DRIVER_GETBLOCK.M must be on your MATLAB 
%   PATH. For additional information on setting your MATLAB PATH, type 
%   'help addpath' at the MATLAB command prompt.
%
%   Example:
%       PS2000_IC_Generic_Driver_GetBlock;
%
%   Description:
%       Demonstrates how to call functions in order to collect a block of 
%       samples.
%
%   See also ICDEVICE.
%
%   Copyright:   Pico Technology Limited 2013
%
%   Author:      HSM
%
%   Creation time: 04-Jan-2013 15:28:07 
%   Modified     : 08-Nov-2013

%% CLEAR WORKSPACE

clear all;
clc;

%% LOAD CONFIGURATION INFORMATION

PS2000Config;

%% DEVICE CONNECTION

% Create a device object. 
ps2000DeviceObj = icdevice('picotech_ps2000_generic.mdd');

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

%% DATA COLLECTION
% Data for channels is returned in milliVolts
disp('Collecting block of data...');

% Execute device object function(s).
[bufferTimes, bufferChA, bufferChB, numDataValues, timeIndisposedMs] = invoke(ps2000DeviceObj, 'getBlockData');

disp('Data collection complete.');

%% STOP THE DEVICE
% Additional blocks can be captured prior to stopping the device.

stopStatus = invoke(ps2000DeviceObj, 'ps2000Stop');

%% PROCESS DATA

disp('Plotting data...')

% Find the time units used by the driver
timesUnits = adcunits(get(ps2000DeviceObj, 'timeUnits'));

% Append to string
time_label = strcat('Time (', timesUnits, ')');

% Plot

figure;
plot(bufferTimes, bufferChA, bufferTimes, bufferChB);
title('Plot of Voltage vs. Time');
xlabel(time_label);
ylabel('Voltage (mv)');
legend('Channel A', 'Channel B');

%% DISCONNECT

% Disconnect device object from hardware.
disconnect(ps2000DeviceObj);

Contact us