Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Function Generator Agilent 33220A Arbitrary Waveform using Matlab

181 views
Skip to first unread message

bowo

unread,
Apr 18, 2011, 9:40:49 AM4/18/11
to
Dear all,

I want to use the function generator to generate sine wave with
driving of 220 KHz (350mVp-p) for 5 seconds, and immediately after
that (without delay) 28 KHz (500mVp-p). I can't do it with ordinary
ways (Frequency modulation etc) since both frequency and amplitude
need to be be changed.

Then, I tried Arbitrary waveform function. I made my own waveform
using Matlab, then convert it into csv file and then using Agilent
Waveform Editor I can save it inside the function generator. However,
since probably there's many points to make smooth sine waves as long
as 6 seconds in total (220 KHz and 28 KHz) I need many data points. It
didn't work with that many data points.

Anyone has solution for this? Is there any other way to accomplish my
goal?

Thanks

Vinod Cherian

unread,
Apr 18, 2011, 2:12:19 PM4/18/11
to
bowo <firdaus...@gmail.com> wrote in message <dcf1577e-7c91-40ab...@a21g2000prj.googlegroups.com>...

Firdaus,

You might want to take a look at what they do here:

http://cp.literature.agilent.com/litweb/pdf/5990-3465EN.pdf

That will eliminate the need for CSV-files, Waveform editor and any software other than MATLAB and Instrument Control Toolbox.

Hope that helps,
-Vinod

bowo

unread,
Apr 19, 2011, 12:27:56 AM4/19/11
to
Thanks for the link, Vinod.

From the link, the maximum Agilent 33220A can save is 64K points in
vertical axis. Is there any way to make a smooth looking sine wave for
a period of 6 seconds consist of high frequencies (220 KHz and 28
KHz)? I think it would take more data points...

On Apr 19, 2:12 am, "Vinod Cherian" <vcher...@mathworks.com> wrote:
> bowo <firdaus.prab...@gmail.com> wrote in message <dcf1577e-7c91-40ab-af86-b191923d1...@a21g2000prj.googlegroups.com>...

bowo

unread,
Apr 19, 2011, 4:50:38 AM4/19/11
to
Oops, I mean 64K points in length / horizontal axis (time axis)

Vinod Cherian

unread,
Apr 19, 2011, 10:51:04 AM4/19/11
to
bowo <firdaus...@gmail.com> wrote in message <ffc8a5f8-572c-4f62...@j35g2000prb.googlegroups.com>...

> Oops, I mean 64K points in length / horizontal axis (time axis)
>

Firdaus,

The following code shows you how to create a waveform with two components that will fit into the function generator's memory:

Amp1 = 0.2; % Amplitude for each component of waveform
Amp2 = 0.7;
frequency1 = 220e3; % Frequency for each component of waveform
frequency2 = 28e3;
overSampleFactor = 1e2; % Sample at 100 times the smallest frequency component
samplingFrequency = overSampleFactor*min(frequency1, frequency2);
stopSample = lcm(frequency1,frequency2)/max(frequency1,frequency2)/samplingFrequency;
time = 0:1/samplingFrequency:stopSample*overSampleFactor;
wave1 = Amp1*sin(2*pi*frequency1*time(1:end-1)); % Waveform component 1
wave2 = Amp2*sin(2*pi*frequency2*time(1:end-1)); % Waveform component 2
wave = wave1 + wave2 ; % combination of individual waveforms
wave = (wave./max(wave))'; % Normalize so values are between -1 to + 1
% Visualize the signals
plot(time(1:end-1),wave1,'m',time(1:end-1),wave2,'k');
hold on; plot(time(1:end-1),wave,'b','Linewidth', 2.5)
xlabel('Time (s)'); ylabel('Voltage (V)'); axis tight;
legend('Component 1','Component 2','Combination of components')

You can download the resulting waveform to the 33220A following the steps in the PDF linked in my previous email. Note that this will continuously generate the waveform. You can control the function generator from MATLAB to stop generation after 6 seconds, if your requirement is to only generate the waveform for a period of 6 seconds.

HTH,
-Vinod

Vinod Cherian

unread,
Apr 19, 2011, 12:31:04 PM4/19/11
to
"Vinod Cherian" wrote in message <iok7go$po1$1...@fred.mathworks.com>...

> bowo <firdaus...@gmail.com> wrote in message <ffc8a5f8-572c-4f62...@j35g2000prb.googlegroups.com>...
> > Oops, I mean 64K points in length / horizontal axis (time axis)


Properly parametrized MATLAB code to generate the waveform:

Amp1 = 0.2; % Amplitude for each component of waveform
Amp2 = 0.7;
frequency1 = 220e3; % Frequency for each component of waveform
frequency2 = 28e3;
overSampleFactor = 1e2; % Sample at 100 times the smallest frequency component

samplingFrequency = overSampleFactor*max(frequency1, frequency2);
stopSample = overSampleFactor*lcm(frequency1,frequency2)/min(frequency1,frequency2);
time = (0:1:stopSample)/samplingFrequency;


wave1 = Amp1*sin(2*pi*frequency1*time(1:end-1)); % Waveform component 1
wave2 = Amp2*sin(2*pi*frequency2*time(1:end-1)); % Waveform component 2
wave = wave1 + wave2 ; % combination of individual waveforms
wave = (wave./max(wave))'; % Normalize so values are between -1 to + 1
% Visualize the signals
plot(time(1:end-1),wave1,'m',time(1:end-1),wave2,'k');
hold on; plot(time(1:end-1),wave,'b','Linewidth', 2.5)
xlabel('Time (s)'); ylabel('Voltage (V)'); axis tight;
legend('Component 1','Component 2','Combination of components')

Control of the function generator can be accomplished using Instrument Control Toolbox (as in the app note linked previously) and timer objects in MATLAB.

bowo

unread,
Apr 19, 2011, 1:14:50 PM4/19/11
to
Thanks for the script, Vinod.

However, one cycle of my waveform should be 5 seconds sine wave of
220KHz (350mVp-p) continued directly with 28KHz (500mVp-p) for 1
seconds.
In script, should be like:

t1=0:1/(100*220e3):5e-4;
t2=t1(end)+1/(100*220e3):1/(100*28e3):6e-4;
wave1=0.35*sin(2*pi*220e3*t1);
wave2=0.5*sin(2*pi*28e3*t2);
wave=[wave1 wave2];
time=[t1 t2];
plot(time,wave)

Here I use a very short time (5e-4 + 1e-4 seconds), since it would be
too many samples if I use 5 and 1 seconds (which I acually need). The
problem is, I need one cycle to be that long (6 seconds in total) not
as the code I wrote above. If I can save a single arbitrary wave into
Matlab with that specified form and length i would be good, since I
can just adjust the frequency or using burst mode etc. However, I
think it's not possible to save a single waveform with that many
points (64K points limit).

Is there any solution for this?

Thanks.

On Apr 20, 12:31 am, "Vinod Cherian" <vcher...@mathworks.com> wrote:
> "Vinod Cherian" wrote in message <iok7go$po...@fred.mathworks.com>...
> > bowo <firdaus.prab...@gmail.com> wrote in message <ffc8a5f8-572c-4f62-9430-fd44369f4...@j35g2000prb.googlegroups.com>...

bowo

unread,
Apr 19, 2011, 1:36:25 PM4/19/11
to
Thanks for the code, Vinod.

However, what I mean is the waveform that I want to make consists of
the both frequencies and amplitudes, but not a superposition wave,
since they appear at different times. In script it would be something
like:

t1=0:1/(100*220e3):5e-4;
t2=t1(end)+1/(100*220e3):1/(100*28e3):6e-4;
wave1=0.35*sin(2*pi*220e3*t1);
wave2=0.5*sin(2*pi*28e3*t2);
wave=[wave1 wave2];
time=[t1 t2];
plot(time,wave);

Here I use very short times for the purpose of elucidation, since the
actually needed time for the first frequency is 5s and the 1s would be
just too large. The full 6 seconds will consists of one cycle of my
waveform, then later I would be able to repeat it (for around 10
cycles) using many ways, for example burst mode. However, even to make
a cycle would exceeds he 64K points limitation in Agilent 33220A.

Is there any better solution? Or is it possible just to ener the
waveform like my above code, and then set the actual timing of the
cycle in a different way (of course without altering the frequencies).

Thanks

On Apr 20, 12:31 am, "Vinod Cherian" <vcher...@mathworks.com> wrote:
> "Vinod Cherian" wrote in message <iok7go$po...@fred.mathworks.com>...
> > bowo <firdaus.prab...@gmail.com> wrote in message <ffc8a5f8-572c-4f62-9430-fd44369f4...@j35g2000prb.googlegroups.com>...

Vinod Cherian

unread,
Apr 19, 2011, 4:49:04 PM4/19/11
to
bowo <firdaus...@gmail.com> wrote in message <a1525b54-0c85-4872...@r4g2000prm.googlegroups.com>...

You're running into a limitation of the instrument's memory with your current approach.

I'm not sure if the instrument you are using allows sequencing. If so you could try something like what is done in these examples:

https://forums.tm.agilent.com/community/viewtopic.php?f=536&t=25245

Essentially you would create a couple of waveforms (each <64k in length) and string them together to make a sequence.

0 new messages