 DDS Lookup table length

Hey guys, i’m just wondering when it comes to DDS, what sort of table length should I be looking at? I’d think that the longer, the better but that seems a tad silly, should a table be the length of the minimum frequency you’re trying to produce?

Using the brilliant tutorial on DDS for arduinos (http://interface.khm.de/index.php/lab/experiments/arduino-dds-sinewave-generator/), they use a table of length 256. The sample rate is 31.25kHz meaning that if the phase accumulator increments 1 every time, you’re going to get a frequency of 31250/256 = ~122Hz. If I wanted to produce a frequency lower than this, some form of interpolation would be required right? For any frequency higher than this, is interpolation really needed, as you’d be skipping loads of table entries anyway?

Say I wanted a frequency of 500Hz, my tuning word would be:

2^32*500/31250, or 68719477, this would then be bit shifted down by 24 to be used for the 8 bit table length, giving an increment of about 4 every time, so going through the table, it would take the 4th value every time and skip the others right?

On the other hand, if I wanted to produce say 15Hz, the increment would be 0.122 meaning it would have to ‘stick’ on the first value for about 8 cycles of the interrupt which at this point, I see why interpolation is required because you’d get a very stepped waveform.

If I was to increase the look up table to say a length of 2048, the ‘increment of 1 per interrupt trigger’ frequency would be ~15.3Hz, meaning that the lowest frequency produced by this look up table without interpolation would be 15.3Hz, right?

Now adhering to the nyquist theorem says that I can reproduce up to fs/2, does the term “oversampling” mean that say for example 4x oversampling, the maximum that I would reproduce would be ~3906Hz?

By knowing these two facts gives a kind of size of look up table required right? Like if I wanted a sine frequency range of 50Hz to 500Hz with 4x oversampling, I would want the lookup table to be long enough that the increment of 1 per interrupt trigger would be below 50Hz yet the sample rate would be atleast 2kHz?

Am I right in these assumptions?

Cheers,
Harris

Hello,
Yes, all you say is right.
The Shannon theorem says that your sample rate must be more than twice the higher frequency.
So if you want sinusoidal signal from 50Hz to 500Hz, a sample rate at 1 kHz should be enough (higher is better).
Your table length should be 1 kHz / 50 Hz = 20.

I disagree a bit - if your output is 8-bit there is not much point in having higher resolution wavetables.

I assume that you want more than one output channel so even your 8 bit samples end up being around 6 bit resolution by the time they are down shifted into the output resolution.

If you have 12 bit or 16 bit output then yes it makes sense to have longer more detailed wavetables or to interpolate between samples in your tables, but with 8 bits, 256 is optimum.

Duane B

rcarduino.blogspot.com

Ah right ok, I see what you're saying.

So if I had a sample rate of 31.25kHz and I wanted to generate the frequency 40Hz, I would gain no advantages by having a wavetable longer than 1024 entries?