Maker Pro
Maker Pro

Need DDS module, 2nd round

N

Nico Coesel

using the usual fixed point phase accumulator and then doing sin()
in float makes sense

but doing the phase accumutation in floats I'm not so sure about,
forever doing an accumulation modulo 2*pi sounds iffy
with fixed point it is exact since 2^n is defined to be 2*pi

Floating point is always an approximation just like a fixed point
integer. In this case top few bits of a float will vary between 0 and
2pi. The top bits of an integer phase accumulator will vary between 0
and the length of the lookup table.
 
S

Spehro Pefhany

Yes, but not transcendental calcs.
As compared to 1 cycle for add/sub/shift/mul on an ARM.

STM32F2 is an ARM Cortex M3.
There's no reason to use any floats in a DDS sinewave generator.

No, but it might make calculating the frequencies during a sweep a bit
easier.

I'd be interested in how long a sin(x) or tan(x) (probably about the
same) takes for non-trivial angles. Or ln(x)/exp(x).
 
Floating point is always an approximation just like a fixed point
integer. In this case top few bits of a float will vary between 0 and
2pi. The top bits of an integer phase accumulator will vary between 0
and the length of the lookup table.

how would you do it?

float phase += (f/fsample)*2*pi;

if(phase > 2*pi) phase -= 2*pi;

output = sin(phase);

or?

int phase += (f/fsample)*2^32;

output = sin(2*pi*phase/2^32);



-Lasse
 
N

Nico Coesel

On Mar 4, 1:05=3DA0pm, [email protected] (Nico Coesel) wrote:


how would you do it?

float phase +=3D (f/fsample)*2*pi;

if(phase > 2*pi) phase -=3D 2*pi;

output =3D sin(phase);

or?

int phase +=3D (f/fsample)*2^32;

output =3D sin(2*pi*phase/2^32);

Its hard to say without a real project. My gut says the all float
implementation will be faster. Float to integer conversions are
'expensive'. So are doing too many calculations.
 
DAC = sine_table(int_phase >> 22)

Two lines of code!

I'd probably add the few lines of 2's complement trickery
so only one quadrant of sine table is needed or even use a taylor
series,
on a cpu with mul-acc is takes very few cycles

but the point was really that even if you use float to generate the
sine wave
I'd still use integers for the phase accumulator


-Lasse
 
N

Nico Coesel

I'd probably add the few lines of 2's complement trickery
so only one quadrant of sine table is needed or even use a taylor
series,
on a cpu with mul-acc is takes very few cycles

The sine table doesn't need to be that long. If every value of the DAC
is used then you'd have a sine table which has the maximum accuracy
you can ever achieve. With some math that comes to 2*pi* dac
resolution. So a 10 bit dac should need a 1024*2*pi=6434 samples.

The idea behind it is that every DAC value should be used at least
once to get the maximum accuracy and no values need to be
interpolated. This means you need to know the angle which causes a
difference of 1 LSB where a sine wave is the steepest (=in the zero
crossing). A simple approximation is: lsb_angle=arcsin(1/dac
resolution). The number of samples in the table is 2*pi/lsb_angle.
 
J

Joerg

Uwe said:
Hello,

Agilent has a DDS generator with FM:
http://cp.literature.agilent.com/litweb/pdf/5988-8544EN.pdf

programmable via GPIB, LAN or USB.

Well, yeah, I am using something like that from a Chinese manufacturer
right now. But that is not suitable because two of those would have to
go into a smallish analog interface box. When you open up one of those
generators the enclosure is quite full.

Currently I am hammering out an analog solution. Again. <sigh>
 
J

josephkk

Hi Folks,

Long story short, none of the DDS modules I've found so far has the
ability to be sweeped or FM-modulated. This one has a signal input
terminal block "SIN" but I received a response from the manufacturer
that it connects to nowhere, it has no function:

http://imall.iteadstudio.com/tools-and-equipment/im120723003.html

What I need in my case is DC-100Hz of sweep or FM bandwidth. Operating
frequency under 10kHz and sweep range up to 2kHz. Of course I can whip
up an analog solution but it won't be as precise and most of all not
really programmable.

Is there anything better? Cost is not a big issue but should be somewhat
small and a display would be nice.

So use the Armstrong method.

?-)
 
J

josephkk

Oh yeah, we had a bunch that came in kits best suited for starter
electronic people from a particular source that were packaging them.
.
Also, back then surplus centers were very popular and you could find
these chips there and more than likely they were seconds but they
made their way out there in equipment where they didn't belong..

These days things are laser trimmed and that isn't such an issue any
more.

With today's methods of fabbing chips, I would bet a chip like that
could be reproduce with a much better yield and precision.

Jamie

They were sweet chips for their time, but now they are up against DDS
chips with 14+ bit dacs for not all that much. They can't compete, except
in the hobbyist market which way too small.

?-)
 
N

Nico Coesel

josephkk said:
They were sweet chips for their time, but now they are up against DDS
chips with 14+ bit dacs for not all that much. They can't compete, =
except
in the hobbyist market which way too small.

Well, FM and sweep seems to be a problem :)
 
J

Joerg

John said:
I think ADI has a DDS chip that sweeps.

Why is it that ADI is the only outfit that makes DDS chips? I asked
one of their guys, and he didn't know.

The usuakl reason would be some sort of patent protection. But that's
just a guess.

We mostly do DDS in FPGAs.

But then they probably need 10x the power :)
 
J

Jamie

Nico said:
Well, FM and sweep seems to be a problem :)
i have a DDS function generator that does all of that and it
does not have any problems?

I think you'll find if you don't have a latency problem with the
serial link to the chip, you should be able to do all the FMing you
want..

Jamie
 
J

Joerg

Jamie said:
i have a DDS function generator that does all of that and it
does not have any problems?

So do I and it dopesn't have modulation problems. But these are too big
even if I'd remove the enclosure and power supply.

I think you'll find if you don't have a latency problem with the
serial link to the chip, you should be able to do all the FMing you
want..

The problem with the uC on these little boards is not the serial link.
Well, at least not if 100Hz sweeps suffice. The problem is that they are
too small to calculate the numbers on the fly and usually have to little
flash left to store them in a LUT. Plus that would be a major
time-consuming hack.
 
N

Nico Coesel

Michael A. Terrell said:
Here is a link to the demo software for the AD8950 that does sweep.
<ftp://ftp.analog.com/pub/www/techSupport/designTools/evaluationBoards/downloads/AD9850_51_V2.41_Win2KXP.exe>

I doubt that he can download it and get it to run, like so much other
software. I had it installed on another computer and it works. You can
use the parallel port to connect the demo board to the PC and see that
it works.

They have sample code for the 8051 processor

If its software then it is not a real sweep but a stepped sweep. If
you use that to test a resonator or a notch filter you might be in for
a nasty surprise.
 
N

Nico Coesel

Michael A. Terrell said:
That depends on the step size. Do you think modern network analyzers
are all analog?

No, but they won't use a dead slow 8051 either :) Probably some FPGA
or ASIC.
 
J

josephkk

using the usual fixed point phase accumulator and then doing sin()
in float makes sense

but doing the phase accumutation in floats I'm not so sure about,
forever doing an accumulation modulo 2*pi sounds iffy

with fixed point it is exact since 2^n is defined to be 2*pi

BAMS. It has been around for over 50 years. (Fraction portion) MSB is
180 degrees and so forth. It is not all that well known though.

?-)
 
J

josephkk

Yes, but not transcendental calcs.


STM32F2 is an ARM Cortex M3.


No, but it might make calculating the frequencies during a sweep a bit
easier.

I can even do that in fixed point. Select a reference frequency, say 100
Hz, then scale for frequency at beginning of sweep, and sweep step size
(may be negative for some cases), then each time you update the phase
register calculate the new value by adding step to current phase/step
value. loop until at stop frequency, reset phase step value to start and
go again.

If everything is fast enough you can even do high futility FM stereo
modulation at MHz carrier frequencies with an MP3 source. But at more
than 8 bits to the DAC you are looking at 200 MB/s, enough to choke a
single PCIe lane.
 
Top