Author Topic: how arbitray waveforms are generated  (Read 4299 times)

0 Members and 4 Guests are viewing this topic.

Offline ant17Topic starter

  • Regular Contributor
  • *
  • Posts: 95
how arbitray waveforms are generated
« on: November 22, 2019, 11:14:46 pm »
Hi guys i have a question thats been bugging me. I want to build a arbitrary waveform generator and have been  looking at some proffesional ones. like the ones from keysight and others most of them load their arbitrary waveforms from what they call waveform memory Then to some sort dac but .My question is how are the values calculated for a given waveform for the represented digital values in memory and even in dds how the values calculated can anyone help.
 

Online MarkF

  • Super Contributor
  • ***
  • Posts: 2671
  • Country: us
Re: how arbitray waveforms are generated
« Reply #1 on: November 23, 2019, 01:56:44 am »
I'll give you a rough idea how to do it. 
But, the real problem comes into being able to send out the samples fast enough.

- To start, you generate a table of samples that represents one period of the waveform.
- Then, you will write each sample to a DAC at a fixed rate between each write. 
     Repeating the table when you reach the end.
- The rate you write the samples will determine the frequency of the waveform.
- Then, the DAC output would go to an op-amp for scaling and DC offset.

As an example:
Consider a single cycle of a sine wave which you would write to a 8-bit DAC.
Assuming a DAC like an MCP4802 which outputs a 0 to 4 volt signal.

As you sequence through the table, the DAC will generate the sine wave one cycle at a time. 
Where writing a 0 to the DAC outputs 0 volts and writing a 255 to the DAC outputs 4 volts.

The table represents one cycle of the waveform which will be repeated.
You can put any waveform shape you wish to generate into the table (hence "arbitrary" waveform).

Like I said, the frequency is a function of the rate you sequence through the table.
There are two ways to change the frequency. 
- One is the rate you write each sample to the DAC. 
- The second, is by using a constant sample rate but skipping samples (i.e. every other sample or every third sample).
- Or a combination of both depending on how fine the samples are.

This works fairly well for a micro-controller to clock the samples to a DAC to generate audio frequencies.  For higher frequencies, the process really needs to be done in hardware (like a AD9834 DDS chip for instance).  In order to generate a frequency, you would want to have at least 10 samples per cycle.  Therefore, the rate you write samples would be at least 10 times faster than the frequency you want to generate.

In my opinion, arbitrary waveforms are over rated.  In the majority of cases, a sine, triangle or square wave will satisfy test conditions.
 
The following users thanked this post: ant17

Offline rs20

  • Super Contributor
  • ***
  • Posts: 2320
  • Country: au
Re: how arbitray waveforms are generated
« Reply #2 on: November 23, 2019, 01:58:41 am »
 
The following users thanked this post: ant17

Online joeqsmith

  • Super Contributor
  • ***
  • Posts: 11939
  • Country: us
Re: how arbitray waveforms are generated
« Reply #3 on: November 23, 2019, 02:06:16 am »
Hi guys i have a question thats been bugging me. I want to build a arbitrary waveform generator and have been  looking at some proffesional ones. like the ones from keysight and others most of them load their arbitrary waveforms from what they call waveform memory Then to some sort dac but .My question is how are the values calculated for a given waveform for the represented digital values in memory and even in dds how the values calculated can anyone help.

Looking at your question form a completely different angle, I don't always calculate the values.  Sometimes I will capture live signals with a DSO (or other means) and use that to drive the Arb.    I designed my first Arb and would draw the waveforms on paper and scan them in.    Nowdays, I use Labview to create the waveforms. 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9935
  • Country: us
Re: how arbitray waveforms are generated
« Reply #4 on: November 23, 2019, 02:09:54 am »
The values are given in a waveform file.  The real question is 'how is the file created?'.  First, the format needs to match the file requirements but let's assume that's no big deal.

As to the values:  Compute them with Fortran, C or <whatever>.
 
The following users thanked this post: ant17

Offline ant17Topic starter

  • Regular Contributor
  • *
  • Posts: 95
Re: how arbitray waveforms are generated
« Reply #5 on: November 23, 2019, 02:17:27 am »
hi guys thanks for your reply i planned on using an fpga. With a external dac at 2Gs/s for an analog bandwidth of 400Mhz. I have seen that matlab has a function where you can make your own waveforms but something like a sawtooth. I don't understand how you know where each part of the waveform is suposed to go. Is there a formula or is it trigonometery can someone please explain
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: how arbitray waveforms are generated
« Reply #6 on: November 23, 2019, 02:49:36 am »
What do you mean where each part of the waveform is supposed to go? The samples are just stored in sequence, each is a binary number representing a voltage, you send them in sequence to the DAC and out comes your waveform. Fundamentally it's no different than playing raw uncompressed digital audio.
 
The following users thanked this post: ant17

Online MarkF

  • Super Contributor
  • ***
  • Posts: 2671
  • Country: us
Re: how arbitray waveforms are generated
« Reply #7 on: November 23, 2019, 02:57:42 am »
It doesn't matter.
You sample memory (table) is a circular buffer.  The last sample wraps around to the first sample.
In order to avoid a discontinuity, you do not want a big amplitude difference between the last and first sample.

Imagine three cycles of a repeating waveform.
Then, lay a selection window of one complete cycle over the three. 
You can slide your window ANY where over the three cycles for your pick of one complete cycle.
(You will repeat the samples when writing to the DAC.  Hence, it does not matter where in the cycle your first sample starts.)
 
The following users thanked this post: ant17

Online MarkF

  • Super Contributor
  • ***
  • Posts: 2671
  • Country: us
Re: how arbitray waveforms are generated
« Reply #8 on: November 23, 2019, 03:03:48 am »
If you want to be able to synchronize your output, you could output a trigger pulse on another pin when you wrap around the end of the sample memory.
 
The following users thanked this post: ant17

Offline ant17Topic starter

  • Regular Contributor
  • *
  • Posts: 95
Re: how arbitray waveforms are generated
« Reply #9 on: November 23, 2019, 05:22:39 am »
sorry i mean i don't understand what actually generates the point or samples in the memory for given waveform. i don't understand sorry like do you generate the waveform in somthing like matlab and then load it into memory does it happen like that
 

Offline AG6QR

  • Frequent Contributor
  • **
  • Posts: 865
  • Country: us
    • AG6QR Blog
Re: how arbitray waveforms are generated
« Reply #10 on: November 23, 2019, 05:29:43 am »
hi guys thanks for your reply i planned on using an fpga. With a external dac at 2Gs/s for an analog bandwidth of 400Mhz. I have seen that matlab has a function where you can make your own waveforms but something like a sawtooth. I don't understand how you know where each part of the waveform is suposed to go. Is there a formula or is it trigonometery can someone please explain

You generate the table of values however you want and put the parts wherever you want.  That's why they call it an arbitrary waveform generator.

If you have a particular purpose or set of requirements that you want the waveform to meet, of course you generate the table of values to meet those requirements.
 
The following users thanked this post: ant17

Offline ant17Topic starter

  • Regular Contributor
  • *
  • Posts: 95
Re: how arbitray waveforms are generated
« Reply #11 on: November 23, 2019, 07:10:52 am »
so if i want to generate a sawtooth of say 400Mhz with certain period how would that be generated thanks
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: how arbitray waveforms are generated
« Reply #12 on: November 23, 2019, 07:22:10 am »
This is one of those things where if you have to ask, you're a long way from getting something workable. You generate a sawtooth like you generate any other waveform. You draw one cycle as a series of dots, the vertical position of each dot represents the value of that sample. If you want 400 MHz you have to clock the samples into the DAC at 400MHz times the number of samples, which is probably going to be 20-30 minimum. If you do the math you'll quickly see why AWGs are typically not anywhere near 400MHz.

Also frequency and period are inextricably linked, it makes no sense to specify both the frequency and the period, you can't change one without changing the other.
« Last Edit: November 23, 2019, 07:23:55 am by james_s »
 
The following users thanked this post: ant17

Offline ant17Topic starter

  • Regular Contributor
  • *
  • Posts: 95
Re: how arbitray waveforms are generated
« Reply #13 on: November 23, 2019, 08:35:03 am »
ok thanks
 

Offline oPossum

  • Super Contributor
  • ***
  • Posts: 1452
  • Country: us
  • Very dangerous - may attack at any time
Re: how arbitray waveforms are generated
« Reply #14 on: November 23, 2019, 08:45:19 am »
Any periodic waveform can be created from a sum of sines. (Fourier synthesis).

Sawtooth for example... https://web.njit.edu/~matveev/Courses/M331_F17/html/FourierSawToothSine.html
 
The following users thanked this post: ant17

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9935
  • Country: us
Re: how arbitray waveforms are generated
« Reply #15 on: November 23, 2019, 05:46:24 pm »
Attached is a plot of cos(x) in with 10 steps per waveform (blue with circles) and 100 steps per waveform (orange with dots).  The difference is pretty noticeable.

So, if you want a 1 MHz clean looking sine wave, you might want to sample at 100 MHz.  You only need 100 values in the file but you have to clock pretty fast.  If you are going to implement phase shifting, you simply start reading the file from some point other than t=0 and wrapping around.

The MATLAB code looks like:
Code: [Select]
x=0:2*pi/10:2*pi;
y=cos(x);
plot(x,y,'-o')
hold on
x=0:2*pi/100:2*pi;
y=cos(x);
plot (x,y,'-.')
ylabel('Cosine Function')
legend('10 samples','100 samples')
title('COS(x)')
axis([0 2*pi -1.5 1.5])
shg
[/font]

The sample spacing is done here:
x=0:2*pi/10:2*pi;

At line 1, x is a vector starting at 0 and extending to 2*pi with intervals of 2*pi/10 or 11 samples (fence post problem).  The first and last should be the same.
At line 2, y is also a vector containing the cos(x) and it too has 11 values.  You can see that with the blue circle at the far right end of the plot.
Lines 5 & 6 do the same thing but they produce 101 samples for the orange plot.

Don't have MATLAB? No problem, the code works perfectly on Octave and Octave is free.  It's a very good clone of MATLAB.

If you want to see the x and y values, numerically, just remove the semicolon from the end of the appropriate line (1,2,5 or 6).
« Last Edit: November 23, 2019, 06:51:36 pm by rstofer »
 
The following users thanked this post: ant17

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9935
  • Country: us
Re: how arbitray waveforms are generated
« Reply #16 on: November 23, 2019, 06:07:12 pm »
This is one of those things where if you have to ask, you're a long way from getting something workable. You generate a sawtooth like you generate any other waveform. You draw one cycle as a series of dots, the vertical position of each dot represents the value of that sample. If you want 400 MHz you have to clock the samples into the DAC at 400MHz times the number of samples, which is probably going to be 20-30 minimum. If you do the math you'll quickly see why AWGs are typically not anywhere near 400MHz.


Even an 80 MHz Siglent (the maximum range my budget would allow) won't produce an 80 MHz square wave, 25 MHz is as far as it goes.  I guess they don't implement it as a simple step function in the middle of the period.  That SDG2082X is $619 plus shipping so AWGs get pretty expensive even for low frequencies.  It samples at 1.2GSa/s

There is a lot of educational material re: the Analog Discovery 2 over at Digilent.  They talk about the AWG and how it is implemented.  It is only 12 MHz bandwidth with 100 MSa/s sampling:

See Section 3 here:

https://reference.digilentinc.com/reference/instrumentation/analog-discovery-2/reference-manual

I'm pretty sure 400 MHz sounds neat when you write it down but I'm not sure it is realizable by mere mortals.  With a 1 GSa/s rate, there would only be 2.5 samples per waveform.  I didn't produce a plot like that but it would be pretty hideous.
 
The following users thanked this post: ant17

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9935
  • Country: us
Re: how arbitray waveforms are generated
« Reply #17 on: November 23, 2019, 06:18:02 pm »

Fun times.   I constructed an engine simulator and needed to have different waveforms for the various sensors.  I wanted to be able to control the frequency as well as AM and FM modulate so I used an FPGA to do everything.

I like analog computing and simulating the suspension of a vehicle (at least one front tire) is a classic problem since it is essentially a mass-spring-damper problem and those are well understood.  But what if the ground under the tire contains a chuck-hole?  I have toyed with the idea of using an AWG to generate the surface.  I could do this quite easily with the Analog Discovery 2.  I could even model those nefarious speed bumps!

Other than sheer laziness, I don't know why I haven't done it yet.

AWGs could be a lot of fun to play with but I'm just guessing that the frequency is going to be a whole lot less than 400 MHz.  For my suspension project, even the 12 MHz bandwidth of the Analog Discover 2 is FAR more than required.  Nothing on the chassis is working in microsecond time scales.  If it does, I guess we move to Euler's Method.
 
The following users thanked this post: ant17

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9935
  • Country: us
Re: how arbitray waveforms are generated
« Reply #18 on: November 23, 2019, 06:28:26 pm »
When creating the sample file, there would be a tendency to want to use ASCII representations of the values.  Simply, these are user readable values.
At some point, there needs to be logic in the FPGA to read the file, convert the values to binary and store them in a samples table in BlockRAM.

It might be worth creating a small CPU core because there will be more to do than just read values.  There will be some kind of UI (switches, knobs and dials).  I suppose the core might as well be the Xilinx MicroBlaze since there is a set of tools for writing code in C and so forth.

Generating the signal, that is, stepping through BlockRAM, grabbing the values and stuffing them into the DAC is the easiest part of the job.

Coming up with a highly variable sample clock is going to be a challenge.  The alternative is to use a very fast sample clock but that implies a LOT of samples for slow signals.  A 1 Hz signal with a 1 GHz sample clock is going to need a billion samples.  Yup!  Generating the sample clock for various realizable signals and speeds is going to be a bit of work and some arithmetic.

« Last Edit: November 23, 2019, 06:31:17 pm by rstofer »
 
The following users thanked this post: ant17

Online gf

  • Super Contributor
  • ***
  • Posts: 1342
  • Country: de
Re: how arbitray waveforms are generated
« Reply #19 on: November 23, 2019, 09:34:45 pm »
Coming up with a highly variable sample clock is going to be a challenge. The alternative is to use a very fast sample clock but that implies a LOT of samples for slow signals.

"Classical" DDS generators are usually based on a fixed (fast) clock.
[ Some commercial AWGs use more sophisticated algorithms, though, than plain DDS, in order to overcome some limatations of DDS. ]

Quote
A 1 Hz signal with a 1 GHz sample clock is going to need a billion samples.

Not really a problem, though. Just spend a sufficient number of bits for the DDS generator's accumulator and you can even generate sub-Hz signals. You don't need a waveform memory which can store a billion samples, but it can be much smaller (-> keyword "phase truncation").

gf
 
The following users thanked this post: ant17

Offline ant17Topic starter

  • Regular Contributor
  • *
  • Posts: 95
Re: how arbitray waveforms are generated
« Reply #20 on: November 23, 2019, 11:37:38 pm »
ok thanks to all that have contributed i am going tohave to have a look at all the posts and think about it thanks agian
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9935
  • Country: us
Re: how arbitray waveforms are generated
« Reply #21 on: November 23, 2019, 11:58:57 pm »
Coming up with a highly variable sample clock is going to be a challenge. The alternative is to use a very fast sample clock but that implies a LOT of samples for slow signals.

"Classical" DDS generators are usually based on a fixed (fast) clock.
[ Some commercial AWGs use more sophisticated algorithms, though, than plain DDS, in order to overcome some limatations of DDS. ]

Quote
A 1 Hz signal with a 1 GHz sample clock is going to need a billion samples.

Not really a problem, though. Just spend a sufficient number of bits for the DDS generator's accumulator and you can even generate sub-Hz signals. You don't need a waveform memory which can store a billion samples, but it can be much smaller (-> keyword "phase truncation").

gf

Are you thinking of periodic signals?  I'm not...  I'm thinking of arbitrary signals with weird patterns.  As a trivial example:  A car moving down the road with the normal bumps and bruises followed by a chuck-hole and perhaps a curb.  Periodic signals are easy, arbitrary maybe not so simple.
 
The following users thanked this post: ant17

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: how arbitray waveforms are generated
« Reply #22 on: November 24, 2019, 04:36:22 am »
AWGs produce periodic signals, at least the few I've played with did. The shape of a cycle is arbitrary but the cycle plays repeatedly as the selected frequency. I don't actually know what people typically use them for, other than playing around I never found a need for anything other than the usual sine, square and triangle waves.
 
The following users thanked this post: ant17

Online gf

  • Super Contributor
  • ***
  • Posts: 1342
  • Country: de
Re: how arbitray waveforms are generated
« Reply #23 on: November 24, 2019, 09:47:42 am »
Are you thinking of periodic signals?  I'm not...

Well, the OP talked about 400MHz sawtooth, which is presumedly periodic (For a reasonable reproduction, this will require a pretty high sampling rate in the microwave range, though.)
 
The following users thanked this post: ant17

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9935
  • Country: us
Re: how arbitray waveforms are generated
« Reply #24 on: November 24, 2019, 04:25:14 pm »
It's common to think about repetitive waveforms but that doesn't have to be the case for an 'arbitrary' waveform.  The waveform will repeat but the experiment may be over before it does.
In the case of the Siglent SDG2082X, the device supports sample memory from 8 points up to 8 megapoints and sample rates from 1 uSa/s up to 75MSa/s in what they call TrueArb mode.  In DDS mode the sample rate is 300 MSa/s.  And then they claim a sample rate of 1.2GSa/s using 4x interpolation.
TrueArb mode is point by point, every output voltage comes from sample memory.

DDS will generate most common waveforms and most AWGs have a large menu of built-in waveforms.  TrueArb is different in that there are discrete samples for every time tick.

There is some very useful iinformation in the SDG2000 datasheet:
https://mediacdn.eu/mage/media/downloads/SDG2000X_DataSheet.pdf

About page 6, they talk about the EasyWave software which allows for manual drawing, line-drawing, equation-drawing, coordinate-drawing and so forth.

User Manual:
https://mediacdn.eu/mage/media/downloads/SDG2000X_UserManual.pdf

Starting on page 40, there is a list of built-in functions extending for 4 pages.  There are a LOT of built-ins.

 
The following users thanked this post: ant17


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf