python-ivi / python-ivi

A Python implementation of the Interchangeable Virtual Instrument standard.
MIT License
218 stars 124 forks source link

How to capture live running traces from MSO7104B oscilloscope with the help of MATLAB without any delay? #85

Open imgb27 opened 1 year ago

imgb27 commented 1 year ago

I need to capture live running traces from oscilloscope without any delay and store it in MATLAB. Without the presence of any reference signal, i need to capture the whole traces from it's start till it's end. I tried various codes but still it fails. Can you please guide me in sorting out this issue?

jrast commented 1 year ago

What did you try so far?

imgb27 commented 1 year ago

Thank you for the reply. I tried it capturing using the below code. But the oscilloscope states it is "Data out of range", "undefined header", "Query interrupted" and also mainly it say that the input buffer size is greater than that of the output buffer size. My main requirement is to capture the entire waveform present in the horizontal channel (not the only data shown on the display of the oscilloscope). ` Create instrument object for Agilent oscilloscope oscilloscope = visa('agilent', 'GPIB0::9::INSTR'); % Change the VISA address as per your oscilloscope configuration

% Set communication parameters set(oscilloscope, 'InputBufferSize', 1024); set(oscilloscope, 'Timeout', 10);

% Open communication with the oscilloscope fopen(oscilloscope);

% Configure oscilloscope settings fprintf(oscilloscope, ':WAVEFORM:FORMAT WORD'); % Set waveform format to WORD fprintf(oscilloscope, ':WAVEFORM:UNIFORM:ENABLE 1'); % Enable uniform waveform data fprintf(oscilloscope, ':WAVEFORM:POINTS 10000'); % Set the number of points to capture fprintf(oscilloscope, ':WAVEFORM:SOURCE CH1'); % Select the waveform source (e.g., Channel 1) fprintf(oscilloscope, ':WAVEFORM:DATA?'); % Request waveform data

% Read and process the waveform data continuously isCapturing = true; while isCapturing % Read waveform data waveformData = binblockread(oscilloscope, 'int16'); % Read waveform data as int16 waveformData = waveformData'; % Transpose the data for easier processing

% Perform processing or analysis on the waveformData
% Example: Calculate the maximum value of the captured waveform
maxValue = max(waveformData);

% Plot the captured waveform in real-time
plot(waveformData);
drawnow;

% Check for an exit condition (e.g., press a key to stop capturing)
if kbhit  % Check if a key is pressed
    isCapturing = false;
end

end

% Close communication with the oscilloscope fclose(oscilloscope);

% Clean up the instrument object delete(oscilloscope); clear oscilloscope; `

jrast commented 1 year ago

This does not look like python code, so I think this is the wrong place to search for help. You might find help in the Matlab Community.