frequency limits of tone() and PWM

Hi all

I need to generate sine waves (via a LPF) for about 80mS but the frequency must range between about 1KHz and 12KHz.
Anyone know the upper limit (frequency wise) of tone() and pwm for a Mega or Uno running at 16MHz?

Thank you.

But the tone function does not generate a sinwave?

I know, will make it go via a LPF.

UnoDueTre:
I know, will make it go via a LPF.

And it will not generate a sinewave.

You need to study "Direct Digital Synthesis". You can do this with an Arduino, though why you do not use an IC designed for the purpose such as an 8038, is hard to fathom.

Paul__B:

UnoDueTre:
I know, will make it go via a LPF.

And it will not generate a sinewave.

Yes it will:

Paul__B:
You need to study "Direct Digital Synthesis". You can do this with an Arduino, though why you do not use an IC designed for the purpose such as an 8038, is hard to fathom.

For two reasons:

  1. Cost of the extra hardware
  2. Extra size and cost of the pcb.

Yes it will:

So why are you posting then?
Assuming that your term LPF actually stands for low pass filter, what frequency do you propose to design it for to cover the range of 1KHz to 12KHz? The output will not be a very pure sin wave.

Yes lpf = low pass filter.

The reason I posted was to ask what the pwm resolution versus frequency would be.

The PWM resoloution is 8 bits, it changes with frequency but only downwards. It is not that simple because if you only want crude control of the PWM frequency then it is always 8 bits. That is if you just change the prescale registers.

See http://interface.khm.de/index.php/lab/experiments/arduino-dds-sinewave-generator/.

Thank you Grumpy_Mike and dc42.

Take a look
http://forum.arduino.cc//index.php?topic=179761.0
Reply #4 - blink without delay example for making lots of tones.

Nice one, thanks CrossRoads.

Also
http://forum.arduino.cc/index.php?topic=64217.10

Thanks mrburnette.