I'm driving a coreless DC motor with PWM, and the motor's manufacturer recommends at least a 20 kHz PWM frequency. Arduino 003 provides a 32 kHz PWM frequency, but along with 004 adding the third PWM channel it changed the frequency to 1 kHz (nominally - I'm seeing 500 Hz on OC1A).
I'm guessing this means a pre-scaler of 32 or 64 using the 16 MHz clock. Does anyone have any thoughts on changing the pre-scale value back so I can take advantage of 004's features?
Thanks! I ended up directly assigning a new value to TCCR1B in setup and it worked. Making TCCR1B = 0x09 changes the timer to no pre-scaling and doesn't seem to have broken anything, though I haven't had a chance to test it extensively yet.
With the change, OC1A runs at 64 kHz at 50% duty cycle, and about 10 kHz at the lower and 25 kHz around the upper limit of the eight-bit range.
I have a question referred to the pwm frequency of the different pwm pins. I read that this frequency is generally 500Hz (see pwm site). But here Arduino Playground - PwmFrequency it says that the frequency is higher (62kHz for pin 5 and 6). Could anyone shed some lite into this issue.
Thanks everybody.
-izoard
izoard056, did you ever get this sorted out? I'm trying to simply drive a 12v pump with PWM, but want a frequency above 20khz or so that's not audible; I'm new to this and read that the pwm output on all pins is ~500hz, which contradicts what I'm reading in your post. Help? Thanks!
Thanks much, this is a very good (and complete and clear!) article. But we're looking for a simple way to do this so students can build it, and messing with the timers is too much I think. I'm about to decide there is no simple way to get >500hz, and am wondering if low freqs, like 20 or 30 hz would work with our little 12v pumps. The don't have a flywheel at all, but of course are nicely cushioned since they're only pushing on water.
This is for a non profit educational venture--any help much appreciated!
For better understanding Timers and their usage, I collected some knowledge and additional links (including georgew77 s link) in those two articles - hope it helps: How to set prescalers, some background on bit-Math, how to control a strong motor: http://www.embedded.arch.ethz.ch/Examples/TimerDcMotorBackground Use a photointerrupter as external clock at T1 and count the slots passed: http://www.embedded.arch.ethz.ch/Examples/Photointerrupter please do NOT post comments / improvements here, feel free to email (contact in articles) thanks.