Author Topic: MATLAB Oscilloscope Plot and Measure using Tektronix TCP/IP Client  (Read 423 times)

0 Members and 1 Guest are viewing this topic.

Offline RonFred2Topic starter

  • Contributor
  • Posts: 25
  • Country: us
    • Biophysics Lab
I rewrote  the code (from blog post in 2020) for my Tektronix oscilloscope to use a recent version of MATLAB and Instrument Control Toolbox—i.e., no VISA, just the TCP/IP client from the scope.

The full article and code can be found here: https://www.biophysicslab.com/2024/08/01/matlab-script-for-tektronix-scope-plot-and-measure/

Because I include the pre-trigger sample number ('WFMOutpre:PT_OFF?'), the plot looks like the scope display - i.e., x=0 is not necessarily in the center of the plot.

Here are the SCPI commands used for accurate time and scale plotting:

Code: [Select]
%   ymult > SCPI command: 'WFMOutpre:YMULT?'
%   yzero > SCPI command: 'WFMOutpre:YZERO?'
%   yoff > SCPI command: 'WFMOutpre:YOFF?'
%   xincr > SCPI command: 'WFMOutpre:XINCR?'
%   xzero > SCPI command: 'WFMOutpre:XZERO?'
%   pre_trig_record > SCPI command: 'WFMOutpre:PT_OFF?'

Here is the setup code to demonstrate what features I baked into the MATLAB script:

Code: [Select]
%% User Inputs

 % Controls for oscilloscope
input_channel = 'CH3';
timeout = 10; % time allowed to complete operations in seconds
buffer_size = 3E6; % large enough to capture 2-byte int16 data
scope_vendor = "Tektronix";

% Controls for Matlab ICT tcpclient scope connect function
%   for troubleshooting:
%       - enter the IP address into a web browser (to get eScope utility)
%       - refer to scope menu: Utility > IO > Lan
TCPIP_address = "192.168.1.160";
TCPIP_port = 4000;

% Controls for saving data as an image, figure, or workspace mat
save_plot = false;
save_fig = false; % may take a long time
save_workspace = false; % may take a long time
save_plot_resolution = 300; % dpi
save_plot_extension = 'png'; % 'jpeg' | 'png' | 'tiff' | 'pdf' | 'eps' | ...
% example file name for saving data: scope_mso64b_channel1_07312024_131849

file_name_base = 'scope';
figure_name = "MATLAB script tcpclient_scope_demo.m";
plot_channel  = plot_channelname(input_channel);
plot_color = get_plotcolor();
% Position legend inside or outside the plot
%   my favorites: 'best' | 'northeast' 'northwest' [default] | 'eastoutside' | ...
plot_legend_position = 'northwest';
plot_fullsize = true; % false > use default plot size (~ 30% of screen)

% Control for user changeable scope and plot measurements
plot_measurements = true;

 
The following users thanked this post: Alex Eisenhut

Offline RonFred2Topic starter

  • Contributor
  • Posts: 25
  • Country: us
    • Biophysics Lab
Re: MATLAB Oscilloscope Plot and Measure using Tektronix TCP/IP Client
« Reply #1 on: September 02, 2024, 02:51:42 am »
I spent the last month updating my MATLAB Oscilloscope Plot and Measure script. The script now supports multiple channels, has improved zoom with meaningful time and voltage units, and has better legend management. Same link as before for discussion and code: https://www.biophysicslab.com/2024/08/31/matlab-script-for-tektronix-scope-plot-and-measure/
 
The following users thanked this post: ktgun

Offline ktgun

  • Contributor
  • Posts: 18
  • Country: ru
Re: MATLAB Oscilloscope Plot and Measure using Tektronix TCP/IP Client
« Reply #2 on: September 02, 2024, 09:26:03 am »
Great job!  :-+
Getting Matlab to draw normal waveforms in quasi-real time is always a headache.  ;D
 

Offline Alex Eisenhut

  • Super Contributor
  • ***
  • Posts: 3446
  • Country: ca
  • Place text here.
Re: MATLAB Oscilloscope Plot and Measure using Tektronix TCP/IP Client
« Reply #3 on: September 02, 2024, 05:13:18 pm »
Good job, I still have flashbacks from how terrible VISA was.
Hoarder of 8-bit Commodore relics and 1960s Tektronix 500-series stuff. Unconventional interior decorator.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf