how to change a sampling rate of a agilent function generator 33220a using matlab visa?

8 views (last 30 days)
I am interfacing a function generator (Agilent 33220a) using matlab visa to generate an arbitrary waveform (a chirp). The waveform is generated. However, I want to reduce the sampling frequency. This is required to increase the sweep time of the chirp. The current sampling rate of 50Mbps generates a maximum sweep time of 500sec. The code is given below-
if true
% code
%opens and creates a visa session for communication with function generator
fgen = visa('AGILENT','USB0::0x0957::0x0407::MY44048510::0::INSTR'); set (fgen,'OutputBufferSize',100000); 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');
% Create arb waveform with 8192 points of 0-1 data fprintf('Generating Waveform...\n\n')
sRate = 100;
ch = [];
for t = 0:1/sRate:10
c = sin(t);
y = num2str(c);
s5 = sprintf(', %s',y);
ch = [ch s5];
end
%combine all of the strings
% s = [rise width fall low];
s = [ch];
% combine string of data with scpi command
arbstring =sprintf('DATA VOLATILE %s', s);
%Send Command to set the desired configuration fprintf('Downloading Waveform...\n\n') fprintf(fgen, arbstring); %make instrument wait for data to download before moving on to next %command set fprintf(fgen, '*WAI'); fprintf('Download Complete\n\n')
%Set desired configuration. fprintf(fgen,'VOLT 2'); % set max waveform amplitude to 2 Vpp fprintf(fgen,'VOLT:OFFSET 0'); % set offset to 0 V fprintf(fgen,'OUTPUT:LOAD 50'); % set output load to 50 ohms fprintf(fgen,'FREQ 1'); %set frequency to 1KHz fprintf(fgen,'DATA:COPY TEST16385, VOLATILE'); fprintf(fgen,'FUNC:USER VOLATILE'); fprintf(fgen,'FUNC:SHAP USER');
%Enable Output
fprintf(fgen,'OUTPUT 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 \n'; fprintf (errorcheck) else errorcheck = ['Error reported: ', errorstr]; fprintf (errorcheck) end
%closes the visa session with the function generator fclose(fgen); end

Answers (0)

Categories

Find more on Troubleshooting in Instrument Control Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!