This is about connecting 2 servos to the 16-bit TIMER1 on the 328PB Xplained board.
An interesting choice to make two threads. Couldn't the one thread have covered both 8bit then the step up to 16bit for finer granularity?
Looks like FastPWM is a better choice than Phase Correct for driving a servo.
Three Tutorials concerning controling a analog servo. The servo used for testing is the Hextronic XHT900.
[TUT] ATMEGA328PB, 8-bit timer, servo, pwm, HXT900
8-BIT TIMER not suitable for driving servo, except when only a few positions are needed,on 11 degree multiples, 1 step = 11 degrees. Advantage – replace 16-bit timer for a limited number of cases.
[TUT] ATMEGA328PB, 16-bit timer, servo, PWM, HXT900
16-bit TIMER with Phase Correct PWM. 11 steps/degree. Disadvantage – period
jitter on output wave form.*
[TUT] ATMEGA328PB, 16-bit timer, servo, FastPWM, HXT900
16-bit TIMER with FastPWM. 22 steps/degree.
It appears that the FastPWM Mode is the most useful for driving a servo. However, applications are
different. I would suggest that you write some small programs an test you application ideas.
* jitter happens when changing pulse width.
In reply to: clarson:
I don't necessarily agree. But in this case I was only interested in the 8-bit case. I was making sure that the 8-bit TIMER would work. It is a good fit for my project. Then avrcandies corrected my formulas and asked if I could do one for 16-bit. I did the Phase Correct first, no real reason, but I didn't like the jitter. Then the FastPWM, which seems to be the best solution for most cases.
By keeping the discussions separate, readers can choose what they are most interested in and not have to wade through all the differences.
I read the other PWM Tutorials and they seem to be trying to cover too much and not being complete. I don't mean to imply they aren't useful and I urge anyone interested in PWM to read them. I just wanted
© 2020 Microchip Technology Inc.