View Single Post
  #2   Spotlight this post!  
Unread 22-08-2007, 14:51
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: servo PWM sampling-what Fosc should I use?

Quote:
Originally Posted by 3dude_2231 View Post
if a 4MHz = 1MHz internal clock,
so with a 1:1 prescaler I should get 1 sample every 1 mS.
if I'm correct, a servo's pulse is between 0.9mS and 2.1 mS,
meaning I need something quicker, am I correct?
You've got the right idea, but the wrong numbers.

First correction: a standard hobby servo signal has a pulse width that varies from 1 to 2 milliseconds. If you want to measure that range with eight bits of precision, you'll need a resolution of 256 counts per millisecond.

Second correction: with the clock running at 1MHz, each cycle is one microsecond. That's almost four times as fast as the task requires. If the processor you're using can measure pulses using the raw clock speed, you'll be fine with a 4MHz crystal.

(If you're indeed using a different servo standard with only a 200 microsecond range from end to end, a 1MHz clock will still give you more than 7 bits of resolution.)