PicoScope 7 Software
Available on Windows, Mac and Linux
Code: Select all
* Call GetStreamingLatestValues
* Sub-loop - poll the driver using IsReady
* Call AvailableData
* Call IsTriggerReady if data has been collected and a trigger has been set
* Process data collected in application buffer
* Call AutoStopped to check if autoStop flag has been set if the autoStop parameter was set in the call to ps6000RunStreaming
Code: Select all
function PicoMatlab
close all;
global data;
data=struct ('unithandle',0,...
'handle',0,...
'fighandle',0,...
'guitimebase',0,...
'timebase',0,...
'guiInputRange',0,...
'InputRange',0);
if ~libisloaded('PS6000')
loadlibrary('PS6000.dll','ps6000Api.h');
end
if ~libisloaded('ps6000Wrap')
loadlibrary('ps6000Wrap.dll','ps6000wrap.h');
end
unithandle= libpointer('int16Ptr',0);
STATUS=calllib('PS6000','ps6000OpenUnit',unithandle,[])
%
data.unithandle=unithandle.value;
if data.unithandle<1
'Error openning the unit'
return
end
channel=0;
enable=1;
typeACDC=1; %DC 1Mohm
% range=9;%plusminus 10 volts
range=8;%plusminus 10 volts
offet=0;
bandwidthlim=0 %full bandwidth;
STATUS=calllib('PS6000', 'ps6000SetChannel', data.unithandle, channel, enable,...
typeACDC,range,offet,bandwidthlim)
pEnabChannels= libpointer('int16Ptr',[1 0 0 0]);
STATUS=calllib('ps6000Wrap','setEnabledChannels', data.unithandle,pEnabChannels);
enable=1;
channel=0;
threshold=10000 ;
thresdir=2;
delay=0;
autoTriggerms=1000;
%trigger with SetSimpleTrigger. This is where I believe there can be something wrong. I tried all thresholds and directions possible.
STATUS=calllib('PS6000','ps6000SetSimpleTrigger',data.unithandle, enable,...
channel,threshold,thresdir,delay,autoTriggerms)
BUFFERSIZE=2e2;
%set data buffer
channel=0; %channel A
bufferLength=BUFFERSIZE;
pBuffer= libpointer('int16Ptr',zeros(1,round(bufferLength)));
downSampleRatioMode=0;
STATUS=calllib('PS6000','ps6000SetDataBuffer',data.unithandle,channel,...
pBuffer,bufferLength,downSampleRatioMode)
channel=0;
pAppBuffer= libpointer('int16Ptr',zeros(1,round(bufferLength)));
pDrvBuffer= libpointer('int16Ptr',zeros(1,round(bufferLength)));
STATUS=calllib('ps6000Wrap','setAppAndDriverBuffers', data.unithandle,...
channel,pAppBuffer,pDrvBuffer,BUFFERSIZE);
sampleInterval=1000;
pSampleInterval= libpointer('ulongPtr',sampleInterval);
sampleIntervalTimeUnits=2;
maxPreTrigSamp=0;
maxPostTrigSamp=BUFFERSIZE;
autoStop=0;
downSampleRatio=1;
downSampleRatioMode=0;
overviewBufferSize=BUFFERSIZE;
figure(22);
STATUS=calllib('PS6000','ps6000RunStreaming',data.unithandle,pSampleInterval,...
sampleIntervalTimeUnits,maxPreTrigSamp,maxPostTrigSamp,autoStop,downSampleRatio,...
downSampleRatioMode,overviewBufferSize)
for(I=1:300);
STATUS=calllib('ps6000Wrap','GetStreamingLatestValues',data.unithandle);
ready=calllib('ps6000Wrap','IsReady',data.unithandle)
while(~ready)
'esperando el ready'
STATUS=calllib('ps6000Wrap','GetStreamingLatestValues',data.unithandle); %infinite loop never ready if I do not include this line
ready=calllib('ps6000Wrap','IsReady',data.unithandle)
end
pStartIndex=libpointer('ulongPtr',0);
STATUS=calllib('ps6000Wrap','AvailableData',data.unithandle, pStartIndex);
pTriggeredAt=libpointer('ulongPtr',1e4);
STATUS=calllib('ps6000Wrap','IsTriggerReady',data.unithandle,pTriggeredAt);
At=sampleInterval*(10.^(3*sampleIntervalTimeUnits-15));
t=At*(1:length(pBuffer.value));
plot(t,pBuffer.value); %nothing obtained in pAppBuffer or pDrvBuffer, Aplication and Driver buffer defined as suggested. The plotted signal does not seem to be triggered as specified.
hold on;
drawnow;
end
STATUS=calllib('PS6000','ps6000Stop',data.unithandle);
STATUS=calllib('PS6000','ps6000CloseUnit',data.unithandle)
return
Code: Select all
enable=1;
channel=0;
threshold=10000 ;
thresdir=2;
delay=0;
autoTriggerms=1000;
STATUS=calllib('PS6000','ps6000SetSimpleTrigger',data.unithandle, enable,...
channel,threshold,thresdir,delay,autoTriggerms)
Code: Select all
thresholdUpper=5000;
hysteresisUpper=100;
thresholdLower=1000;
hysteresisLower=100;
channel=0;
thresholdMode=0;
pTriggerProperties= libpointer('int32Ptr',[thresholdUpper,hysteresisUpper,...
thresholdLower,hysteresisLower,channel,thresholdMode]);
nProperties=1; %only one set of properties
auxEnable=0;
autoTrig=0;
STATUS=calllib('ps6000Wrap','SetTriggerProperties',data.unithandle,pTriggerProperties,...
nProperties,auxEnable,autoTrig);
pTriggerConditions= libpointer('int32Ptr',[1 0 0 0 0 0 0]); %none but channel A care
nConditions=1;
STATUS=calllib('ps6000Wrap','SetTriggerConditions',data.unithandle,pTriggerConditions,...
nConditions);
STATUS=calllib('PS6000','ps6000SetTriggerChannelDirections',data.unithandle,...
2,2,2,2,2,2); %all set rising
Code: Select all
%% LOAD ENUMERATION AND STRUCTURE DATA
% Load information from prototype file
[ps6000Methodinfo, ps6000Structs, ps6000Enuminfo, ps6000ThunkLibName] = PS6000MFile;
%% OPEN UNIT
% Load library and open the unit
loadlibrary('PS6000.dll', 'PS6000MFile');
Code: Select all
%% SET TRIGGER
enableTrig = 1;
voltageRange = 2000; %2V (Change if voltage range changes)
direction = ps6000Enuminfo.enPS6000ThresholdDirection.PS6000_RISING;
delay = numPreTriggerSamples;
autoTriggerMs = 0;
maxADCValue = 32512;
triggerLevelMv = 800;
threshold = mv2adc(triggerLevelMv, voltageRange, maxADCValue);
[status.setSimpleTrig] = calllib('PS6000', 'ps6000SetSimpleTrigger', handle, enableTrig, channelA, threshold, direction, delay, autoTriggerMs);