- does your signal amplitude be scaled before passed to you FG ? sometimes you have to make sure it's within -1 to +1 range for example
- fs is actually not 2MHz (what is claimed in your comment), but 9.4250 MHz , again any limitations or recommendations from Agilent about what fs is supported ?
- why divide fs by length(y) here : myFGen.Frequency = fs/length(y); % Set waveform frequency
Loading Arbitrary Waveform to Agilent 33220A using fgen
12 views (last 30 days)
Show older comments
Hi there,
I am trying to load arbitrary waveforms to an Agilent 33220A arbitrary waveform generator. Each waveform is a summation of two sine waves with different frequencies (f1 and f2). The first sine wave with frequency f1 has a phase shift applied to it before being summed with the second sine wave. The applied phase shift varies from 0:5:50 degrees, in total giving 11 different waveforms.
The problem is I sometimes get an error on the function generator when trying to load a waveform depending on the phase shift value. For example, when I have a phase shift of 10 degrees and a sampling frequency = f2*50, the signal loads to the function generator without any issues. However, when I change the phase angle to be 15 degrees and keep the sampling frequency = f2*50, I get the error 'Error generated by remote interface command.', and the waveform doesn't load onto the machine.
My script is as follows:
%% Set-up arbitrary waveform properties
f1 = 71125; %frequency 1
f2 = 188500; %frequency 2
fs = f2*50; %sampling frequency of 2MHz
ts = 1/fs; %sampling period
t = 0:ts:2000*ts; %time array
ratio1 = 1.005; % Amplitude of first sine wave
ratio2 = 1; % Amplitude of second sine wave
F1PhsAng = 10; % Phase angle in degrees of first sine wave
F2PhsAng = 0; % Phase angle in degrees of second sine wave, always = 0
F1TimeShift = F1PhsAng / (f1 * 360); % Time shift of f1
F2TimeShift = F2PhsAng / (f2 * 360); % Time shift of f2, always = 0
% Plot the combined sine waveform
figure;
y = ratio1 *(sin( 2*pi*f1*( t - F1TimeShift ) ) ) + ratio2*(sin( 2*pi*f2* ( t - F2TimeShift ) ) ); %combined sine wave
plot(t,y);
title('Arbitrary signal of 70kHz and 190kHz');
ylabel('Amplitude');
xlabel('Time(s)');
%% Connect to function generator
myFGen = fgen; %create instance of fgen class
getResources(myFGen) %search availible resources - shown in command window
myFGen.Resource = 'USB0::0x0957::0x0407::MY44021125::0::INSTR'; %Available resource
connect(myFGen); %establish connection to signal generator
display(myFGen) %display siggen info in command window
selectChannel(myFGen, '1'); %specify channel of generator to use
myFGen.Waveform = 'Arb'; %set type of waveform to arbitrary
myFGen.Frequency = fs/length(y); % Set waveform frequency
h1 = downloadWaveform(myFGen, y); %download waveform to generator
selectWaveform(myFGen, h1);
enableOutput(myFGen); %enables the output of the generator to oscilloscope.
Does anyone know what could be causing this problem of sometimes getting an error and sometimes having no issue? I have been over the code many times and the only solution I can see is that if I change the sampling frequency to be different for each waveform I can eventually get each one to load to the machine, but this isn't practical and I would really like to understand the reason for this error to occur in the first place.
Thank you very much in advance.
Laura
1 Comment
Mathieu NOE
on 15 Dec 2020
hello Laura
just a few points I am thinking of :
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!