# Best way to get a smooth 5-15 Hz sinusoidal wave PWM

Does anyone know how to change PWM freq output and what is the fastest that arduino can reach? I need the freq as fast as possible to make my output smooth. (I need to make 12 Hz sinusoidal wave very smooth) I consider to buy either Arduino Due or Mega for this project. Can anybody help me?

maybe rephrase the subject line ?

best way to get a smooth 12 Hz sinusoidal wave

also list the reason that what you have gotten is not smooth enough.

http://playground.arduino.cc/Code/PwmFrequency

62.5kHz is the fastest you can get.

dave-in-nj: maybe rephrase the subject line ?

best way to get a smooth 12 Hz sinusoidal wave

also list the reason that what you have gotten is not smooth enough.

so actually I have not bought any arduino for this project. I use waveform generator that can produce analogue signal which is very smooth. Now I want to use arduino board to produce this wave but since arduino can only do PWM, i am afraid that the signal is not good enough for my experiment. So i need some suggestion which arduino board is suitable for me and how to use it?

I am unconvinced as to why you need a "smooth" signal but for the best waveform generation get an Arduino Due, this has a built in D/A converter.

Really smooth signals require an analogue sine wave generator. Try to find one (diagram...) that can be programmed somehow, by e.g. switching an resistor or voltage. Also a PLL circuit may the the way to go, provided it's usable with your low frequencies.

Add an external DAC The more bits it has, the smoother the output will be and less filtering required.
If you have an 12-bit SPI DAC and update the output at 240 Hz rate, 20x the desired frequency, that will be pretty smooth.
Create a table in EEPROM that is 1/4 of the waveform - 0 to 90 degrees - and send those values to the DAC.
0 to 90, then 90 to 0, then inverted 0 to 90, and inverted 90 to 0. 60 values should do it. If not, increase thee update rate and use 120 values.
With a single voltage supply DAC, 0 to 90 will be 2.5V to 5V, then 5V to 2.5V, then 2.5V to 0, and finally 0 to 2.5.
Example of a 12-bit DAC with internal voltage reference.
http://www.digikey.com/product-detail/en/MCP4821-E%2FP/MCP4821-E%2FP-ND/951462

I need the freq as fast as possible to make my output smooth.

PWM is NOT smooth... A higher frequency doesn't automatically make PWM smooth (or smoother). It's always switching between 0 and 5V.

You need a low-pass filter... A simple RC low pass filter with a ~12Hz cutoff frequency should do a reasonable job of filtering-out the ~400Hz PWM switching-frequency. If that's not good enough, a higher PWM frequency or a higher-order filter will give you better filtering/smoothing.

PCM from a regular DAC gets smoother with a higher sample rate or higher resolution (more bits) but it still the job of the filter to make a smooth-analog waveform.

It should be very easy to make a ~12Hz sine wave with any Arduino and an (8-bit) R/2R ladder network.
The analogue filter you use behind it makes it smooth.
Many examples if you enter something like “sine wave generator” in the search box on top of this page.
I think we all want to know what you want to do with this very low frequency.
Leo…

I just want to run the motor with sinusoidal movement back and forth, but i need smooth movement for measurement of forces :) so I guess the best solution I need the analogue filter for PWM or DAC 12 bit if I want to make smooth sine wave? and the best arduino I can buy is Due?

CrossRoads: Add an external DAC The more bits it has, the smoother the output will be and less filtering required. If you have an 12-bit SPI DAC and update the output at 240 Hz rate, 20x the desired frequency, that will be pretty smooth. Create a table in EEPROM that is 1/4 of the waveform - 0 to 90 degrees - and send those values to the DAC. 0 to 90, then 90 to 0, then inverted 0 to 90, and inverted 90 to 0. 60 values should do it. If not, increase thee update rate and use 120 values. With a single voltage supply DAC, 0 to 90 will be 2.5V to 5V, then 5V to 2.5V, then 2.5V to 0, and finally 0 to 2.5. Example of a 12-bit DAC with internal voltage reference. http://www.digikey.com/product-detail/en/MCP4821-E%2FP/MCP4821-E%2FP-ND/951462

Can you help me, how exactly to do all this things? I am still newbie about this circuitry and controller things, do you have any reference?

I'm thinking XY Problem here.....

The ratio between 12Hz and 490Hz (standard arduino pwm) is about 40 which translates to 5,35 octaves. A standard 1st order rc filter gives you 6dB/octave which means that residues from 490Hz will be 32dB down. There are a number of ways to increase this.

• Increase the ratio between pwm frequency and generated frequency. This can be done by modifying the hardware registers but this can cause other functions to behave erratically
• Use a higher order filter
• Use a different method. DAC has been suggested but you could examine sigma/delta modulation