Tektronix Technical Forums are maintained by community involvement. Feel free to post questions or respond to questions by other members. Should you require a time-sensitive answer, please contact your local Tektronix support center here.

AWG70K MATLAB ICT Send Waveform Example

Questions in this forum area are community supported. Tektronix does not regularly monitor or guarantee responses in this area.
Post Reply
Grant B
Tektronix Applications
Tektronix Applications
Posts: 3
Joined: July 11th, 2012, 10:58 am

AWG70K MATLAB ICT Send Waveform Example

Post by Grant B » March 6th, 2014, 11:19 am

Code: Select all

%% Waveform Sample Data Calculation - Pure Matlab
freq = 10;
per = 1/freq;
cycles = 100;
SR = 100;
t = 0:1/SR:cycles*per-1/SR;
w = freq*2*pi;
a = sin(1/freq*pi*t);
y = single(a.*sin(w*t));
waveform_data = y;
%plot(t,y);

%% Opening VISA Session
visa_vendor = 'ni';
visa_address = 'TCPIP::134.62.36.57::INSTR';
buffer = 1024*4*10;
awg = visa(visa_vendor, visa_address, 'OutputBuffer', buffer);
fopen(awg);

%% Funtional Check
query(awg,'*idn?')
fwrite(awg, '*cls')
fwrite(awg, '*rst')

%% Pretest Error Check
query(awg,'*esr?')
query(awg,'syst:err?')

%% Waveform Send
waveform_name = 'test';
delete_waveform = sprintf('wlist:waveform:delete "%s"', waveform_name);
header = sprintf('#%d%d',length(num2str(length(waveform_data))), 4*length(waveform_data));
create_waveform = sprintf('wlist:waveform:new "%s", %d', waveform_name, length(waveform_data));
write_waveform_binblock = sprintf('wlist:waveform:data "%s", %s', waveform_name, header);
end_line = 10;
assign_waveform_ch1 = sprintf('source1:waveform "%s"', waveform_name);

fwrite(awg, delete_waveform);
fwrite(awg, create_waveform);
fwrite(awg, write_waveform_binblock);
fwrite(awg, waveform_data, 'single');
fwrite(awg, end_line);
fwrite(awg, assign_waveform_ch1);

%% Post Test Error Check
query(awg,'*esr?')
query(awg,'syst:err?')

%% End VISA session
fclose(awg);
delete(awg);
clear
Griz

Carl M
Tektronix Applications
Tektronix Applications
Posts: 797
Joined: July 30th, 2008, 4:45 pm
Country: United States

Re: AWG70K MATLAB ICT Send Waveform Example

Post by Carl M » September 4th, 2014, 11:07 am

found a bug

Code: Select all

header = sprintf('#%d%d',length(num2str(length(waveform_data))), 4*length(waveform_data));
should be:

Code: Select all

header = sprintf('#%d%d',length(num2str(4*length(waveform_data))), 4*length(waveform_data));
personally i'd add a line and variable to improve readability

Code: Select all

waveform_bytes = length(waveform_data) * 4;
header = sprintf('#%d%d', length(num2str(waveform_bytes)), waveform_bytes);
Tektronix Application Engineer

Post Reply

Return to “Older and Obsolete Signal Sources”

Who is online

Users browsing this forum: No registered users and 2 guests