AnsweredAssumed Answered

Matlab bursted arb waveform 33522A

Question asked by lhornburg Employee on Apr 13, 2012
Here is a quick example which sets up a 33522A to burst an arbitrary waveform using an external trigger:

% clears all variables, closes all open files

clear all; close all; clc;

%opens and creates a visa session for communication with function generator

fgen = visa('AGILENT','USB0::0x0957::0x2307::MY50000705::0::INSTR');
set (fgen,'OutputBufferSize',2000000);

%Query Idendity string and report
fprintf (fgen, '*IDN?');
idn = fscanf (fgen);
fprintf (idn)
fprintf ('\n\n')

%Clear and reset instrument
fprintf (fgen, '*RST');
fprintf (fgen, '*CLS');

%Clear volatile memory

%create waveform
i = 1:1:100000;        % Set rise time (100000 points) */
z = (i-1)/100000;

    fprintf(fgen, 'FORM:BORD SWAP'); %swap the endian format
    binblockwrite(fgen, z, 'float32', 'SOURce1:DATA:ARBitrary testarb, '); %send the data using binary to the instrument

    fprintf(fgen, '*WAI');
     fprintf('Download Complete\n\n')

     %Set desired configuration.
    fprintf(fgen,'SOURce1:FUNCtion:ARBitrary testarb'); % set current arb waveform to defined arb we named testarb
    fprintf(fgen,'SOURCE1:FUNCtion:ARB:SRATe 400000'); % set sample rate
    fprintf(fgen,'SOURce1:FUNCtion ARB'); % turn on arb function

    fprintf(fgen,'SOURCE1:VOLT 2'); % set max waveform amplitude to 2 Vpp
    fprintf(fgen,'OUTPUT1:LOAD 50'); % set output load to 50 ohms
    fprintf(fgen,'SOURCE1:VOLT:OFFSET 1'); % set offset to 0 V
    fprintf(fgen,'TRIGGER1:SOURCE EXT'); %set the trigger source to external

     % Set up and turn on NCYCLE Burst with 1 cycle output
     % This burst will start on channel 1 when instrument receives a trigger
     fprintf(fgen,'SOURCE1:BURST:NCYCLES 1');
     fprintf(fgen,'SOURCE1:BURST:MODE TRIG');
     fprintf(fgen,'SOURCE1:BURST:STATe ON');

    %Enable Output
    fprintf(fgen,'OUTPUT1 ON'); % turn on channel 1 output

% Read Error
fprintf(fgen, 'SYST:ERR?');
errorstr = fscanf (fgen);

% error checking
if strncmp (errorstr, '+0,"No error"',13)
   errorcheck = 'Arbitrary waveform generated without any error';
   fprintf (errorcheck)
   errorcheck = ['Error reported: ', errorstr];
   fprintf (errorcheck)

%Save Arb to internal memory, titled test arb

fprintf(fgen, 'MMEM:STOR:DATA "INT:\TEST ARB.barb"');

%closes the visa session with the function generator