Hello,
I'm trying to run an experiment but after some time the system crashes. The measurement is performed with at Tektronix DPO2014. The problem seems to be in the binblockread() function. Based on another MATLAB answer I turned the header off. To make sure the terminator character is cleared, I also added a clrdevice(). However, I still get the following error.
Warning: Unsuccessful read: A binblock is not available to be read. Warning: Unsuccessful read: A binblock is not available to be read. Warning: Unsuccessful read: A timeout occurred before the binblock was read. Subscripted assignment dimension mismatch.Error in measure (line 71) RawSignal(:, p) = ymult * (curve - yoff) - yzero;Error in test (line 16) measure
The measure.m script:
% DPO2014 measure
if Test == 1 && Iteration == 1 dpo2014 = visa('ni', 'USB0::0x0699::0x0373::C010615::INSTR'); dpo2014.InputBufferSize = 10000000; fopen(dpo2014); fprintf(dpo2014, 'HEAD %s\n', 'OFF'); endif Iteration == 1 RawSignals = [];end% Setup acquisition
fprintf(dpo2014, 'ACQ:MOD %s\n', 'AVE');fprintf(dpo2014, 'ACQ:NUMAV %d\n', Averages);fprintf(dpo2014, 'HOR:DEL:MOD %s\n', 'OFF');fprintf(dpo2014, 'HOR:POS %d\n', 0);fprintf(dpo2014, 'HOR:RECO %d\n', RecordLength);RecordLength = query(dpo2014, 'HOR:RESO?', '%s', '%d');for i = 1 : 4 fprintf(dpo2014, 'SEL:CH%d?\n', i); active = fscanf(dpo2014, '%d'); if active == 1 fprintf(dpo2014, 'CH%d:POS %d\n', [i 0]); fprintf(dpo2014, 'CH%d:SCA %d\n', [i 10]); end endfprintf(dpo2014, 'TRIG:A:TYP %s\n', 'EDG');fprintf(dpo2014, 'TRIG:A:EDGE:SOU %s\n', TriggerSource);fprintf(dpo2014, 'TRIG:A:EDGE:SLO %s\n', TriggerSlope);fprintf(dpo2014, 'TRIG:A:LEV %d\n', TriggerLevel);% Run acquisition
fprintf(dpo2014, 'ACQ:STOPA %s\n', 'SEQ');fprintf(dpo2014, 'ACQ:STATE %s\n', 'RUN');% Wait until the acquisition stops
fprintf(dpo2014, '%s\n', '*WAI');% Fetch waveform
fprintf(dpo2014, 'DAT:ENC %s\n', 'SRI');fprintf(dpo2014, 'DAT:WID %s\n', 2);RawSignal = zeros(RecordLength, 2);p = 1;for k = 1 : 4 fprintf(dpo2014, 'SEL:CH%d?\n', k); active = fscanf(dpo2014, '%d'); if active == 1 channel = sprintf('CH%d', k); fprintf(dpo2014, 'DAT:SOU %s\n', channel); fprintf(dpo2014, 'DAT:STAR %d\n', 1); fprintf(dpo2014, 'DAT:STOP %d\n', RecordLength); fprintf(dpo2014, '%s\n', 'CURVE?'); curve = binblockread(dpo2014, 'int16'); clrdevice(dpo2014); ymult = query(dpo2014, 'WFMO:YMU?', '%s', '%e'); yoff = query(dpo2014, 'WFMO:YOF?', '%s', '%e'); yzero = query(dpo2014, 'WFMO:YZE?', '%s', '%e'); RawSignal(:, p) = ymult * (curve - yoff) - yzero; p = p + 1; end endRawSignals = [RawSignals; RawSignal];if Iteration == Measurements save(File, 'RecordLength', 'Averages', 'RawSignals') clear File RecordLength Average RawSignals endif Iteration == Measurements && Stop == 1 fclose(dpo2014); delete(dpo2014); end
Does anybody have a suggestion to make this work?
Best Answer