MATLAB Answers

Agilent 33250a Function Generator. How to get the waveform via serial port?

24 views (last 30 days)
Justinas Lialys
Justinas Lialys on 2 Aug 2020 at 16:41
Commented: Justinas Lialys on 4 Aug 2020 at 0:11
I am trying to use MATLAB to control my Agilent 33250a Function generator. I am completely new to this stuff so sorry for my improper lingo. I have scrambled something like this so far using some other codes and information on internet.
%%
clear all; close all; clc;
%%
fgen = visa('NI', 'GPIB0::11::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');
%Set desired configuration.
fprintf(fgen,'FUNCTION SQUARE'); %set waveform (example: SQUARE, PULSE, SINE...)
fprintf(fgen,'VOLTAGE:LOW 0'); % set min waveform amplitude
fprintf(fgen,'VOLTAGE:HIGH 2'); % set max waveform amplitude
fprintf(fgen,'OUTPUT:LOAD 50'); % set output load to 50 ohms
fprintf(fgen,'FREQ 10000'); %enable output
fprintf(fgen,'OUTPUT ON'); %enable output
pause(2)
%% Voltage level Iteration Loop
for i=1:1:3
V=(i)*1;
y=num2str(V);
s = sprintf('VOLTAGE:HIGH %s', y);
fprintf(fgen,s); %set High Voltage
pause(5)
end
%%
fprintf(fgen,'OUTPUT OFF'); %enable output
%%
fclose(fgen);
I need a command if it exits to get the waveform from the function generator via serial port. Any info regarding coding is appreciated

  2 Comments

Walter Roberson
Walter Roberson on 2 Aug 2020 at 20:45
The code you posted looks plausible. Is there a reason you need to skip the visa layer and go directly to serial port?
Justinas Lialys
Justinas Lialys on 2 Aug 2020 at 20:53
This works fine for adjusting parameters. However, is there any way to get the output wave from the waveform generator as a string sequence?

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 3 Aug 2020 at 0:37
I seldom look at waveform generators, several years apart... but it happens that someone else asked me about them this morning, so I had happened do enough reading this morning to be able to know what to look for to answer the question.
The answer is NO, that particular device has no ability to dump waveform data over the control ports.
Some devices do have that ability. However, you are dynamically modifying the waveform, so it would not be enough for the system to dump the current parameters: you would need it to be recording the waveform in order to have a possibility of copying back the waveform.
You apply a 10000 hz signal for 2 seconds and then alter the voltage three times, holding for 5 seconds each time, for a total of 17 seconds of 10000 hz, for a total of 170000, times samples per Hz (which would have to be at least 2, due to nyquist frequency concerns), thus requiring 340000 samples However, the maximum number of samples for that model is 65535 per storage slot, so even if it had a record function you would be overfilling it.
I do not know if it would be useful for your purposes, but that device has four nonvolatile slots. You could preprogram them with the base voltage and three modified voltages, and then to switch between them you would just tell the device which of the four to activate. Perhaps that will help you, perhaps not.
I had earlier read about a Tektronix waveform generator: the documentation for it talked in terms of using an oscilloscope to record waveforms and download them to the generator -- implying that the generator did not have any ability to record external inputs (but not, in itself, saying anything about ability to dump stored signals)