matlabdata-transferoscilloscope

Waveform transfer for Tektronix TBS 1052B


I am trying to transfer waveform data from the above specified oscilloscope and commanding it using MATLAB. Here's what my code looks like:

tbs1052b = visa('ni','USB0::0x0699::0x0368::C020742::INSTR');
fopen(tbs1052b);
fprintf(tbs1052b, 'ACQuire?')
out_1 = fscanf(tbs1052b)
fprintf(tbs1052b, 'DATa?')
out_2 = fscanf(tbs1052b)
fprintf(tbs1052b, 'DATa:WIDth 2')
fprintf(tbs1052b, 'DATa?')
out_3 = fscanf(tbs1052b)
fprintf(tbs1052b, 'DATALOGging?')
out_4 = fscanf(tbs1052b)
fprintf(tbs1052b, 'DATALOGging:SOURCE CH1')
fprintf(tbs1052b, 'DATALOGgING:STATE ON')
fprintf(tbs1052b, 'DATa:ENCdg ASCIi')
fprintf(tbs1052b,'DATa:STARt 1')
fprintf(tbs1052b, 'DATa:STOP 10')
fprintf(tbs1052b,'CURVe?')
out_5 = fscanf(tbs1052b)

The first 4 scan commands work and I get an answer for each of them. However I get a warning saying 'Unsuccessful read: VISA: Timeout expired before operation completed. ' for when I scan the last CURVe? command. I increased the timeout to the maximum value with the same result. Any ideas on what could be wrong?


Solution

  • Ok so I figured out what was going on. I did not specify the data source which is why Curve wasn't sure where to get the data from. So adding the following line fixed the issue:

    fprintf(tbs1052b, 'DATa:SOUrce CH1')
    

    Also some more edits involved acquiring data correctly, which is described by the following commands:

    fprintf(tbs1052b, 'ACQuire:STATE ON')
    fprintf(tbs1052b, 'ACQuire:MODe SAMple')
    fprintf(tbs1052b, 'ACQuire:STOPAfter RUNSTop')
    pause(10)
    fprintf(tbs1052b, 'ACQuire:STATE OFF')