Author
Topic: 8 bit Timer - Hardware Servo Control (Read 3206 times)

I know you have to use 16bit timers to control a servo , but I could have sworn that it is possible to use a 8 bit timer to control a servo as well through Hardware PWM. Can someone please tell me how to control it through 8 bit PWM and what kind of resolution I could expect for an 8 bit hardware PWM ?

Suppose you have 20ms at 255 (overflow)When it's 1ms you have.... well x =~ 13 andWhen it's 2ms you have.... mm x =~ 26.....So.... 13 steps.... quit poor... really....Consider you have a 255 for 2ms and 128 for 1ms your have a 128 steps... well that's better....But you have to generate the pause with software... sorry again...

Why don't you use a 16bit timer for many servo control via software and generic I/O

Logged

For whom the interrupts toll...

P.S. I've been inactive for almost a year... Don't give promises but I'll try to complete my tutorials. I'll let you know when..

As TrickyNero says - it is possible to use the 8 bit timers for hardware PWM but the total travel of your servo will be split down into about 13 steps. Most servos have a resolution of about 90 steps. If you dont require fine position control then 8 bit timers are ok.

I'm not trying to hijack this thread but I thought that with hardware pwm you set the timer to give as near as dammit 50Hz signal, so the timer will count up then down and each up/down cycle will take 20ms (50Hz), then all you have to do in software is generate the 1-2ms pulse to the servo everytime the counter comes back to 0.

The idea of hardware pwm is so you're not generating pauses in software which in a hard working mcu can be a bit off.How does this affect resolution ??

I have read up on this and thats my grasp, dunno if it's the wrong end of the stick again but I'm a bit confused now

Anyone suggest more reading material?

EDIT:- I answered my own questions with a bit of digging on SoR. Still, any suggested reading material would be appreciated. Thanks

The idea of hardware pwm is so you're not generating pauses in software which in a hard working mcu can be a bit off.How does this affect resolution ??

The problem is that if you've got a 20ms (50Hz frequency) set up then, with an 8 bit timer, then 0 would be mean no pulse and 255 would be a pulse of 20ms. For a servo: the active range (roughly) is a pulse between 1ms and 2ms ie a range of 1ms out of 20ms. So 1/20th of the total. 255/20 = 12.5 which means that there are only 12,or 13 thirteen, different speed/position settings you can use.