AnsweredAssumed Answered

Load an arb waveform in 33220a gen. in MATLAB (visa) with low sampling rate

Question asked by deboshree_roy22 on Feb 4, 2015
Latest reply on Feb 5, 2015 by lhornburg
I have been trying to load an arbitrary waveform in function generator using MATLAB (visa). However, I dont obtain the waveform that I have designed. The code used is given below. I initially tested the code with a simple sine wave of 1Hz. However, the wave generated is of very much higher frequency (of the order of kHz). I suspect it is due to much lower sampling frequency. The 50Mbps sampling rate of the function generator creates a huge amount of data, that cannot be handled by MAtlab. Also, I ultimately want to create a chirp with 1000 sec sweep time. For that, I need to *reduce the sampling rate of the generator* .Please provide me the commands for the same. The codes I used is given below-

fgen = visa('AGILENT','USB0::0x0957::0x0407::MY44048510::0::INSTR');
set (fgen,'OutputBufferSize',100000);

%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
     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];
    %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)
   errorcheck = ['Error reported: ', errorstr];
   fprintf (errorcheck)

%closes the visa session with the function generator

I used the following command to reduce the sampling rate- 
sRate = 100;
fprintf(fgen,'SOURCE1:FUNCtion:ARB:SRATe ' num2str(sRate))
The program shows an error at this line