The Planted Tank Forum - View Single Post - Calling all DIY LED "Junkies" - Your opinions wanted!
View Single Post
post #30 of (permalink) Old 07-20-2012, 12:44 PM
Planted Member
Join Date: Apr 2011
Location: Philly, PA
Posts: 243
Originally Posted by O2surplus View Post
If I'm not mistaken, I believe the normal default setting for the PWM frequency coming from the Atmega chip is set at 5KHz. The Pwm frequency can be adjusted from there- using the programming software. It's just a matter of plugging in the appropriate numbers to the programming code.
I'm saying that I think the approach that most of the servo control guys take is simply to do something like:

Set N = 1.5ms (servos typically receive signals in the 1-2ms range @ ~60Hz)

Output a N ms pulse
Delay 18 ms
goto loop

So, if you adapted it to your purposes, you could do something like:

Set DutyCycle = 0.2

Output a (DutyCycle * 7) ms pulse
Delay for [(1 - DutyCycle) * 7] ms
goto loop

Obviously, you'd have to account for everything else you wanted the controller to be doing... but with low PWM's everything happens slowly enough that you can just manually program the pulse widths and delays.

I don't know much about Aurdino, so I'm not sure how tricky it will be to get all of the multitasking right... especially when you want to be able to vary all the way from 0 to 100% duty cycle. with servo control, you can count on having at least 18ms between pulses... with a fully variable duty cycle you have to adjust where you get your extra clock cycles depending upon the desired duty cycle.
d3snoopy is offline  
For the best viewing experience please update your browser to Google Chrome