MATLAB ICT DPO/MSO2000/B Get Waveform

%% MATLAB ICT DPO/MSO2000/B Get Waveform

% Date: May 30, 2017

% This script demonstrates how to pull waveform data off of a DPO/MSO2000/B

% and scale it for a simple plot.

% Tektronix provides the following example "AS IS" without any guarantees

% or support. This example is for instructional guidance only.

% Find a VISA-USB object.

obj1 = instrfind('Type', 'visa-usb', 'RsrcName', 'USB0::0x0699::0x03A3::C020161::0::INSTR', 'Tag', '');

% Create the VISA-USB object if it does not exist

% otherwise use the object that was found.

if isempty(obj1)

obj1 = visa('NI', 'USB0::0x0699::0x03A3::C020161::0::INSTR');

else

fclose(obj1);

obj1 = obj1(1);

end

% Connect to instrument object, obj1.

fopen(obj1);

%% Disconnect and Clean Up

% The following code has been automatically generated to ensure that any

% object manipulated in TMTOOL has been properly disposed when executed

% as part of a function or script.

% Disconnect all objects.

fclose(obj1);

% Clean up all objects.

delete(obj1);

clear obj1;

%% variables

visa_brand = 'ni';

visa_address = 'USB0::0x0699::0x03A3::C020161::0::INSTR';

buffer = 2000 * 1024; %20 KiB

%% open instrument

dpo2k = visa(visa_brand, visa_address, 'InputBuffer', buffer, ...

'OutputBuffer', buffer);

fopen(dpo2k);

query(dpo2k, '*IDN?')

%% configure output

fwrite(dpo2k, 'wfmo:byt_n 1');

record = str2double(query(dpo2k, 'hor:reco?'));

fwrite(dpo2k, 'header 0')

fwrite(dpo2k, 'data:encdg rib') %signed integer, msb first

fwrite(dpo2k, 'data:source CH1')

fwrite(dpo2k, 'data:source CH2')

fwrite(dpo2k, 'data:source CH3')

fwrite(dpo2k, 'data:comp singular_yt') %see Appendix B of programmer's manual

fwrite(dpo2k, 'data:resolution full') %DPO/MSO2000/B series only. See Appendix B

fwrite(dpo2k, 'data:start 1');

fprintf(dpo2k, 'data:stop %i', record);

%% request sample data

fwrite(dpo2k, 'curve?');

%% read binary block header

waste = fread(dpo2k, 1); %discard '#' character

a = char(fread(dpo2k, 1));

bytes = char(fread(dpo2k, str2double(a))');

% read digital values into sample matrix

samples = fread(dpo2k, str2double(bytes), 'int8');

fread(dpo2k, 1); %discard linefeed character

%% get scaling values

x_incr = str2double(query(dpo2k, "wfmo:xincr?"));

x_zero = str2double(query(dpo2k, "wfmo:xzero?"));

y_incr = str2double(query(dpo2k, "wfmo:ymult?"));

y_off = str2double(query(dpo2k, "wfmo:yoff?"));

y_zero = str2double(query(dpo2k, "wfmo:yzero?"));

%% close instrument

fclose(dpo2k); % close connection

delete(dpo2k); % remove the ICT object

clear dpo2k; % remove the local MATLAB variable

%% scale samples for plot

x_range = record * x_incr;

x_max = x_range + x_zero;

time_base = linspace(x_zero, x_max, record);

scaled_samples = (samples * y_incr) + y_off;

%% simple plot

plot(time_base, scaled_samples);

%plot(samples);

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

happy_baymax

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值