%% AWG5000 MATLAB ICT Send Waveform 1 % Date: 10-13-2008 % ================== % Send 14 bit waveform data to an AWG5000. % % PREREQUISITE EXAMPLES % ================== % MATLAB ICT Control 1 (Hello World) % ================== % % COMPATIBILITY % ================== % AWG5000, AWG5000B % ================== % % TESTED & DEVELOPED % ================== % Microsoft Windows XP SP2 % TekVISA 3.3.0.14 % MATLAB Version 7.6.0.324 (R2008a) % Instrument Control Toolbox Version 2.6 % Ethernet: Static IPs % AWG5012 FW 2.1 w/ TekVISA 3.3.0.14 % ================== % % Tektronix provides the following example "AS IS" without any guarantees % or support. This example is for instructional guidance only. %% variables visa_vendor = 'tek'; visa_address = 'TCPIP::192.168.0.6::INSTR'; % example waveform: sin wave using 12 sample points % hex notation is easier to verify on the AWG wave = {'2000' '2FFF' '3BB6' '3FFF' '3BB6' '2FFF' '2000' '1000' '0449' ... '0000' '0449' '1000'}; wave = hex2dec(wave); %% pre-processing % encode the data for AWG binblock = zeros(2*length(wave),1); binblock(1:2:end) = bitand(wave,255); binblock(2:2:end) = bitshift(wave,-8); binblock = binblock'; % build binblock header bytes = num2str(length(binblock)); header = ['#' num2str(length(bytes)) bytes]; %% instrument communication awg = visa(visa_vendor, visa_address); fopen(awg); fwrite(awg,'*rst;'); fwrite(awg,'*cls;'); % create the waveform fwrite(awg,[':wlist:waveform:new "newwave1",' num2str(length(wave)) ... ',integer;']); % send the data to new waveform fwrite(awg,[':wlist:waveform:data "newwave1",' header binblock ';'], ... 'uint8'); %data transmission % set channel 1 to new waveform fwrite(awg,':source1:waveform "newwave1";'); % turn on channel 1 fwrite(awg, ':output on;'); % have AWG begin playback fwrite(awg, ':awgcontrol:run;'); % gracefully disconnect fclose(awg); delete(awg); clear awg;