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

0 Members and 1 Guest are viewing this topic.

Offline airman00Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,650
  • Helpful? 21
  • narobo.com
    • Narobo.com - Mechatronics and related
8 bit Timer - Hardware Servo Control
« on: January 22, 2009, 07:25:43 AM »
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 ?
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline want2learn

  • Robot Overlord
  • ****
  • Posts: 189
  • Helpful? 4
Re: 8 bit Timer - Hardware Servo Control
« Reply #1 on: January 22, 2009, 04:00:24 PM »
I have very little experience here but I'm going to throw in my tuppence anyway.

Does it really matter if the timer is 8 or 16 bit? I thought 16 bit was only really necessary for software pwm.

I thought the clock speed and timer speed (set with a prescaler right?) were what was important here. After all controlling the servos means generating a 1-2ms pulse at 50Hz.

I know I must be missing something
The question that drives me hazy:

Am I, or the others crazy?

Offline TrickyNekro

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,208
  • Helpful? 15
  • Hardware and Firmware Designer
    • The Hellinic Robots Portal
Re: 8 bit Timer - Hardware Servo Control
« Reply #2 on: January 22, 2009, 04:34:11 PM »
Set the prescaler so you have a near 50Hz signal and do some math!!! :P

Suppose you have 20ms at 255 (overflow)
When it's 1ms you have.... well x =~ 13 and
When 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 :-X
For whom the interrupts toll...

Offline airman00Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,650
  • Helpful? 21
  • narobo.com
    • Narobo.com - Mechatronics and related
Re: 8 bit Timer - Hardware Servo Control
« Reply #3 on: January 22, 2009, 06:08:31 PM »
But you have to generate the pause with software... sorry again...
is there anyway to have the pause to make a 20ms from hardware?
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline airman00Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,650
  • Helpful? 21
  • narobo.com
    • Narobo.com - Mechatronics and related
Re: 8 bit Timer - Hardware Servo Control
« Reply #4 on: January 22, 2009, 06:32:26 PM »
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
    • Webbot stuff
Re: 8 bit Timer - Hardware Servo Control
« Reply #5 on: January 22, 2009, 08:57:38 PM »
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.
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline want2learn

  • Robot Overlord
  • ****
  • Posts: 189
  • Helpful? 4
Re: 8 bit Timer - Hardware Servo Control
« Reply #6 on: January 22, 2009, 11:46:46 PM »
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
« Last Edit: January 23, 2009, 03:01:28 PM by want2learn »
The question that drives me hazy:

Am I, or the others crazy?

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
    • Webbot stuff
Re: 8 bit Timer - Hardware Servo Control
« Reply #7 on: January 25, 2009, 01:09:11 PM »
Yeah, hardware PWM means no pauses, you just set up the PWM frequency and from then on you just write one register to change the servo pulse length. Other reading: http://www.societyofrobots.com/member_tutorials/node/228

Quote
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.
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline want2learn

  • Robot Overlord
  • ****
  • Posts: 189
  • Helpful? 4
Re: 8 bit Timer - Hardware Servo Control
« Reply #8 on: January 25, 2009, 03:08:05 PM »
Thanks Webbot, was wearing my confused hat over in the corner for a while.
The question that drives me hazy:

Am I, or the others crazy?

 


Get Your Ad Here