PicoScope 7 Software
Available on Windows, Mac and Linux
Code: Select all
setenv('MW_MINGW64_LOC','C:\TDM-GCC-64')
mex -setup C++
clc;
clear all;
close all;
loadlibrary 'ps5000a.dll' 'ps5000aApi.h' addheader 'picoStatus.h' mfilename 'PS5000aMFile';
if ~libisloaded('ps5000a')
error('library ps5000a.dll or ps5000a.h not found') %check if the library is loaded
end
% loadlibrary('ps5000aWrap.dll', 'ps5000aWrapMFile');
pBufferChASize = 1000000;
pBufferChA = libpointer('int16Ptr', zeros(pBufferChASize, 1));
[methodinfo,structs,enuminfo] = PS5000aMFile; % Data and method structure for the ps5000a api.
unithandle = 0; % Handle to the opened unit.
offsetVoltage = 0; % Offset in microvolt (±1 V).
pkToPk = 500000; % Peak-to-peak amplitude in microvolt (±250 mV to ±2 V).
waveType = enuminfo.enPS5000AWaveType.PS5000A_SINE; % Type of Wave. See commentsection at the bottom of this file for a full list.
%waveType = 'PS5000A_SINE'; % Type of Wave. See commentsection at the bottom of this file for a full list.
startFrequency = 1000; % Hz (must be lower than or equal to stopfrequency).
stopFrequency = 1000; % Hz.
increment = 0; % Increment in frequency for sweepmode.
dwellTime = 0; % Time (sec) spent in each frequency for sweepmode.
sweepType = enuminfo.enPS5000ASweepType.PS5000A_UP; % Type of sweep. See commentsection at the bottom of this file for a full list.
operation = enuminfo.enPS5000AExtraOperations.PS5000A_ES_OFF; % TRUE or FALSE.
shots = 0; % Number of shots if not in sweepmode.
sweeps = 0; % Number of sweeps if in sweepmode.
triggerType = enuminfo.enPS5000ASigGenTrigType.PS5000A_SIGGEN_RISING; % Trigger type. See commentsection at the bottom of this file for a full list.
triggerSource = enuminfo.enPS5000ASigGenTrigSource.PS5000A_SIGGEN_NONE; % Trigger source. See commentsection at the bottom of this file for a full list.
extInThreshold = 0; % Threshold for trigger on external in.
resolution = enuminfo.enPS5000ADeviceResolution.PS5000A_DR_8BIT;
noOfPreTriggerSamples = 0;
noOfPostTriggerSamples = 10;
noOfSamples = noOfPreTriggerSamples + noOfPostTriggerSamples;
maxSamples = noOfSamples;
timebase = 25;
oversample = 1;
timeIndisposedMs = [];
segmentIndex = 0; % Leave set to 0 unless the data is being captured in a specific segment on the device.
lpReady = []; % Callback not used
pParameter = [];
overflow = [];
channelA = enuminfo.enPS5000AChannel.PS5000A_CHANNEL_A;
range = enuminfo.enPS5000ARange.PS5000A_500MV;
downSampleRatio = 0; % If downSampleRatioMode = RATIO_MODE_NONE then this value is ignored
downSampleRatioMode = enuminfo.enPS5000ARatioMode.PS5000A_RATIO_MODE_NONE;
true = enuminfo.enPS5000ATriggerState.PS5000A_CONDITION_TRUE;
pico_status = 0;
[status_open,unithandle] = calllib('ps5000a','ps5000aOpenUnit',unithandle,0,resolution);
status_open = dec2hex(status_open);
status_ps5000aFlashLed = dec2hex(calllib('ps5000a','ps5000aFlashLed',unithandle, -1));
status_ps5000aPingUnit = dec2hex(calllib('ps5000a','ps5000aPingUnit',unithandle));
status_ps5000aSetChannel = dec2hex(calllib('ps5000a','ps5000aSetChannel',unithandle,channelA,true,true,range,offsetVoltage));
status_ps5000aGetTimebase = dec2hex(calllib('ps5000a','ps5000aGetTimebase',unithandle,timebase,noOfSamples,0,maxSamples,segmentIndex));
status_SetSigGenBuiltIn = dec2hex(calllib('ps5000a','ps5000aSetSigGenBuiltIn',unithandle,...
offsetVoltage,pkToPk,waveType,startFrequency,stopFrequency,increment,dwellTime,...
sweepType,operation,shots,sweeps,triggerType,triggerSource,extInThreshold));
status_ps5000aRunBlock = dec2hex(calllib('ps5000a','ps5000aRunBlock',unithandle, noOfPreTriggerSamples,...
noOfPostTriggerSamples, timebase, timeIndisposedMs, segmentIndex, lpReady, pParameter));
ready = 0;
% Poll the driver until it has captured some data
while(ready == 0)
[status_read, ready] = calllib('ps5000a', 'ps5000aIsReady', unithandle, ready);
status_read = dec2hex(status_read);
pause(0.1);
end
% %pause(1);
% stillColectingData = 0;
% while(stillColectingData == 0)
% status_IsReady = calllib('ps5000a','ps5000aIsReady',unithandle,&stillColectingData);
% end
status_ps5000aSetDataBuffer = dec2hex(calllib('ps5000a','ps5000aSetDataBuffer',unithandle,...
channelA,pBufferChA,pBufferChASize,segmentIndex,downSampleRatioMode));
status_ps5000aGetValues = dec2hex(calllib('ps5000a','ps5000aGetValues',unithandle,...
0,noOfSamples,downSampleRatio, downSampleRatioMode,segmentIndex,overflow));
% status_ps5000aBlockReady = calllib('ps5000a','ps5000aBlockReady',unithandle,pico_status,pParameter);
bufferChA = get(pBufferChA, 'Value');
unloadlibrary('ps5000a');
Code: Select all
[status_open,unithandle] = calllib('ps5000a','ps5000aOpenUnit',unithandle,[],resolution);
Code: Select all
loadlibrary('ps5000a.dll', @ps5000aMFile);
loadlibrary('ps5000aWrap.dll', @ps5000aWrapMFile);