PicoScope 7 Software
Available on Windows, Mac and Linux
.Parameter must be scalar
How do I correctly use the AWG to give me a 1kHz sine wave?runBlock: Waiting for device to become ready...
Code: Select all
PS5000aConfig;
%% DEVICE CONNECTION
% Create a device object.
ps5000aDeviceObj = icdevice('picotech_ps5000a_generic.mdd');
% Connect device object to hardware.
connect(ps5000aDeviceObj);
%% FUNCTION GENERATOR - SIMPLE
% Configure property value(s).
% Output a Sine wave, 2000mVpp, 0mV offset (uses preset frequency)
% invoke(ps5000aDeviceObj, 'setSigGenBuiltInSimple', 0, 2000, 0);
awgBufferSize = get(ps5000aDeviceObj, 'awgBufferSize');
%x = [0:(2*pi)/1023:2*pi];
sampleSize = 1024;
t = linspace(0,2e-3,sampleSize);
f = 1e3;
y = normalise(sin(2*pi*f*t));
dacFrequency = 200e6;
startDelta = freq2delta(f, sampleSize, awgBufferSize, dacFrequency);
% Set parameters
offsetMv = 0;
pkToPkMv = 2000;
increment = 0; % Hz
dwellTime = 1; % seconds
sweepType = ps5000aEnuminfo.enPS5000ASweepType.PS5000A_UP;
operatiom = PicoConstants.FALSE;
operation = ps5000aEnuminfo.enPS5000AIndexMode.PS5000A_SINGLE;
shots = 1;
sweeps = 0;
triggerType = ps5000aEnuminfo.enPS5000ASigGenTrigType.PS5000A_SIGGEN_RISING;
triggerSource = ps5000aEnuminfo.enPS5000ASigGenTrigSource.PS5000A_SIGGEN_SOFT_TRIG;
extInThresholdMv = 0;
% Call function
invoke(ps5000aDeviceObj, 'setSigGenArbitrary', offsetMv, pkToPkMv, startDelta, increment, dwellTime, ...
y, sweepType, operatiom, operation, shots, sweeps, triggerType, triggerSource, extInThresholdMv);
% Trigger the AWG
invoke(ps5000aDeviceObj, 'ps5000aSigGenSoftwareControl', 1);
%invoke(ps5000aDeviceObj, 'setSigGenArbitrarySimple', 0, 2000, y);
%% Set input channel parameters
% Channel A enabled, the rest disabled. Page 78 of programmers guide
invoke(ps5000aDeviceObj, 'ps5000aSetChannel', 0, 1, 1, 6, 0);
invoke(ps5000aDeviceObj, 'ps5000aSetChannel', 1, 0, 1, 6, 0);
invoke(ps5000aDeviceObj, 'ps5000aSetChannel', 2, 0, 1, 6, 0);
invoke(ps5000aDeviceObj, 'ps5000aSetChannel', 3, 0, 1, 6, 0);
[status, resolution] = invoke(ps5000aDeviceObj, 'ps5000aSetDeviceResolution', 12);
%% SET SIMPLE TRIGGER
% Channel : 0 (PS5000A_CHANNEL_A)
% Threshold : 0 (mV)
% Direction : 2 (Rising)
% Delay : 0
% Auto trigger: 0 (wait indefinitely)
[status] = invoke(ps5000aDeviceObj, 'setSimpleTrigger', 0, 0, 0, 2, 0, 0);
%% GET TIMEBASE
% Driver default timebase index used - use ps5000aGetTimebase or
% ps5000aGetTimebase2 to query the driver as to suitability of using a
% particular timebase index then set the 'timebase' property if required.
% timebase : 65 (default)
% segment index: 0
[status, timeIntervalNanoSeconds, maxSamples] = invoke(ps5000aDeviceObj, 'ps5000aGetTimebase', 100, 0);
Nsamples = 2048;
samplingRate = 1/(double(timeIntervalNanoSeconds)*1e-9);
%% SET BLOCK PARAMETERS AND CAPTURE DATA
% Set pre-trigger samples.
set(ps5000aDeviceObj, 'numPreTriggerSamples', 0);
set(ps5000aDeviceObj, 'numPostTriggerSamples', Nsamples); %% Samples to record after trigger
% Capture a block of data:
% segment index: 0
[status] = invoke(ps5000aDeviceObj, 'runBlock', 0);
% Retrieve data values:
% start index : 0
% segment index : 0
% downsampling ratio: 1
% downsampling mode : 0 (PS5000A_RATIO_MODE_NONE)
[chA, chB, chC, chD, numSamples, overflow] = invoke(ps5000aDeviceObj, 'getBlockData', 0, 0, 1, 0);
% Stop the device
[status] = invoke(ps5000aDeviceObj, 'ps5000aStop');
%% PROCESS DATA
% Plot data values.
figure;
% Calculate time (nanoseconds) and convert to milliseconds
% Use timeIntervalNanoSeconds output from ps5000aGetTimebase or
% ps5000aGetTimebase2 or calculate from Programmer's Guide.
timeNs = double(timeIntervalNanoSeconds) * double([0:numSamples - 1]);
timeMs = timeNs / 1e6;
% Channel A
plot(timeMs, chA, 'b');
title('Channel A');
xlabel('Time (ms)');
ylabel('Voltage (mV)');
%% DEVICE DISCONNECTION
% Disconnect device object from hardware.
disconnect(ps5000aDeviceObj);
Code: Select all
invoke(ps5000aDeviceObj, 'setSigGenArbitrary', offsetMv, pkToPkMv, startDelta, increment, dwellTime, ...
y, sweepType, operatiom, operation, shots, sweeps, triggerType, triggerSource, extInThresholdMv);
Instrument Device Object Using Driver : picotech_ps5000a_generic.mdd
Instrument Information
Type: Oscilloscope
Manufacturer: Pico Technology Ltd.
Model: PicoScope 5000 Series
Driver Information
DriverType: MATLAB generic
DriverName: picotech_ps5000a_generic.mdd
DriverVersion: 1.1.20
Communication State
Status: open
Code: Select all
%% FUNCTION GENERATOR - SIMPLE
% Configure property value(s).
% Output a Sine wave, 2000mVpp, 0mV offset (uses preset frequency)
% invoke(ps5000aDeviceObj, 'setSigGenBuiltInSimple', 0, 2000, 0);
awgBufferSize = get(ps5000aDeviceObj, 'awgBufferSize');
%x = [0:(2*pi)/1023:2*pi];
sampleSize = 1024;
t = linspace(0,2e-3,sampleSize);
f = 1e3;
y = normalise(sin(2*pi*f*t));
dacFrequency = 200e6;
startDelta = freq2delta(f, sampleSize, awgBufferSize, dacFrequency); % Not required as calculated by the Instrument Driver
% Set parameters
% Set the frequency in the Instrument Driver
set(ps5000aDeviceObj, 'startFrequency', f);
set(ps5000aDeviceObj, 'stopFrequency', f);
offsetMv = 0;
pkToPkMv = 2000;
increment = 0; % Hz
dwellTime = 1; % seconds
sweepType = ps5000aEnuminfo.enPS5000ASweepType.PS5000A_UP;
operation = PicoConstants.FALSE;
sweepType = ps5000aEnuminfo.enPS5000AIndexMode.PS5000A_SINGLE;
shots = 1;
sweeps = 0;
triggerType = ps5000aEnuminfo.enPS5000ASigGenTrigType.PS5000A_SIGGEN_RISING;
triggerSource = ps5000aEnuminfo.enPS5000ASigGenTrigSource.PS5000A_SIGGEN_SOFT_TRIG;
extInThresholdMv = 0;
% Call function
invoke(ps5000aDeviceObj, 'setSigGenArbitrary', offsetMv, pkToPkMv, increment, dwellTime, ...
y, sweepType, operation, sweepType, shots, sweeps, triggerType, triggerSource, extInThresholdMv);
% Trigger the AWG
invoke(ps5000aDeviceObj, 'ps5000aSigGenSoftwareControl', 1);