Thread: Matlab bursted arb waveform 33522A


Permlink Replies: 0 - Pages: 1
lhornburg

Posts: 441
Registered: 01/15/10
Matlab bursted arb waveform 33522A
Posted: Apr 13, 2012 2:33 PM
Click to report abuse...   Click to reply to this thread Reply
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);
fopen(fgen);

%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
fprintf(fgen,'SOURce1:DATA:VOLatile:CLEar');


%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)
else
errorcheck = ;
fprintf (errorcheck)
end

%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
fclose(fgen);


Point your RSS reader here for a feed of the latest messages in all forums