PicoScope 7 Software
Available on Windows, Mac and Linux
Code: Select all
while(hasAutoStopped == PicoConstants.FALSE && status.getStreamingLatestValues == PicoStatus.PICO_OK)
Code: Select all
%% Connect
archStr = computer('arch');
try
addpath(strcat('./', archStr, '/'));
catch err
error('Operating system not supported');
set(handles.edit1,'String','Error : Operating system not supported');
end
addpath('../Functions');
addpath('..');
if ~libisloaded('ps4000')
loadlibrary('ps4000.dll','ps4000MFile');
if ~libisloaded('ps4000')
error('library file is not found')
set(handles.edit1,'String','Error : library file is not found');
end
end
[ps4000Methodinfo, ps4000Structs, ps4000Enuminfo, ...
ps4000ThunkLibName] = ps4000MFile;
ps4000DeviceObj = icdevice('picotech_ps4000_generic', '');
connect(ps4000DeviceObj);
%% Channel Setting
% Channel A
channelSettings(1).enabled = PicoConstants.TRUE;
channelSettings(1).coupling = 1;
channelSettings(1).range = ps4000Enuminfo.enPS4000Range.PS4000_5V;
% Channel B
channelSettings(2).enabled = PicoConstants.TRUE;
channelSettings(2).coupling = 1;
channelSettings(2).range = ps4000Enuminfo.enPS4000Range.PS4000_5V;
% Channel C
channelSettings(3).enabled = PicoConstants.FALSE;
channelSettings(3).coupling = 1;
channelSettings(3).range = ps4000Enuminfo.enPS4000Range.PS4000_5V;
% Channel D
channelSettings(4).enabled = PicoConstants.FALSE;
channelSettings(4).coupling = 1;
channelSettings(4).range = ps4000Enuminfo.enPS4000Range.PS4000_5V;
numChannels = get(ps4000DeviceObj, 'channelCount');
for ch = 1:numChannels
status.setChannelStatus(ch) = invoke(ps4000DeviceObj, 'ps4000SetChannel', ...
(ch - 1), channelSettings(ch).enabled, ...
channelSettings(ch).coupling, channelSettings(ch).range);
end
%% Trigger & Timebase
triggerGroupObj = get(ps4000DeviceObj, 'Trigger');
triggerGroupObj = triggerGroupObj(1);
[status.SimpleTrigger] = invoke(triggerGroupObj, 'setSimpleTrigger', 1, 1000, 2);
totalSamplingTime = 100*1e6;
[status.getTimebase, timeIntervalNanoSeconds, maxSamples] = invoke(ps4000DeviceObj, 'ps4000GetTimebase2', 3, 0);
BUFFER_SIZE = totalSamplingTime/timeIntervalNanoSeconds;
set(ps4000DeviceObj, 'numPreTriggerSamples', 0);
set(ps4000DeviceObj, 'numPostTriggerSamples', BUFFER_SIZE);
%% Run block
blockGroupObj = get(ps4000DeviceObj, 'Block');
blockGroupObj = blockGroupObj(1);
[status.runBlock] = invoke(blockGroupObj, 'runBlock', 0);
[~, ~, chA, ~] = invoke(blockGroupObj, 'getBlockData', 0, 0, 1, 0);
%% Processing data
TRIG_PER = 500e-6;
Fs = 1/(timeIntervalNanoSeconds*1e-9);
numCol = TRIG_PER/(timeIntervalNanoSeconds*1e-9);
Signal_DCX = chA-mean(chA);
Varied_Signal = reshape(Signal_DCX , numCol, []);
Varied_Signal((499/500)*numCol+1:numCol,1:numel(Varied_Signal)/length(Varied_Signal))=0;
final_Signal = Varied_Signal;
f1_num = 8*2^nextpow2(numel(final_Signal)/length(final_Signal));
f2_num=2^nextpow2(length(final_Signal));
Result_FFT2 = fft2(final_Signal,f2_num, f1_num);
absresult_FFT2 = fftshift(abs(Result_FFT2));
absresult_FFT2((f2_num/2)-120:(f2_num/2)+121,(f1_num/2)-20:(f1_num/2)+21)=10;
CalFig = figure;
figure(CalFig);
plot(absresult_FFT2);
%% Disconnent
status.stop = invoke(ps4000DeviceObj, 'ps4000Stop');
disconnect(ps4000DeviceObj);