[TUT] ATMEGA328PB, 16-bit timer, servo, PWM, HXT900

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This is about connecting 2 servos to the 16-bit TIMER1 on the 328PB Xplained board.

 

 

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Looks like FastPWM is a better choice than Phase Correct for driving a servo.

 

Discussion:

 

Three Tutorials concerning controling a analog servo. The servo used for testing is the Hextronic XHT900.

 

The Tutorials:

 

[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.

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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

more focus.