%% AWG7000 MATLAB ICT Send Waveform 1 % Date: 11-03-2008 % ================== % Send an 8-bit waveform data to an AWG7000. % % PREREQUISITE EXAMPLES % ================== % MATLAB ICT Control 1 (Hello World) % ================== % % COMPATIBILITY % ================== % AWG7000, AWG7000B % ================== % % 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: DHCP % AWG7122B FW 3.0 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::tsc-awg7122b::INSTR'; % example waveform: sin wave using 12 sample points % hex notation is easier to verify on the AWG wave = {'80' 'BF' 'EE' 'FF' 'EE' 'BF' '80' '40' '11' '00' '11' '40'}; wave = hex2dec(wave); %% pre-processing % encode the data for AWG as defined in Programmer Manual binblock = zeros(2 * length(wave), 1); binblock(1:2:end) = bitshift(bitand(wave, 3), 6); binblock(2:2:end) = bitshift(wave, -2); 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 10], 'uint8'); % 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'); % close fclose(awg); delete(awg); clear awg;