|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
servo PWM sampling-what Fosc should I use?
Hi.
my goal is to sample a servo pulse from an R/C receiver, and I'm not sure what XTAL to use, I mean, what is the minimum Fosc I should use? 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? will a 20MHz XTAL be the answer? thanks, Ran. |
|
#2
|
|||||
|
|||||
|
Re: servo PWM sampling-what Fosc should I use?
Quote:
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.) |
|
#3
|
||||
|
||||
|
Re: servo PWM sampling-what Fosc should I use?
thank you very much!
![]() |
|
#4
|
|||
|
|||
|
Re: servo PWM sampling-what Fosc should I use?
Depending on what processor you are using, you might be able to convince the hardware to do it for you, rather than polling it. This will let you run it with a different sample frequency AND lets you do other stuff while you are waiting.
On the PIC, I think it is called the "Input Compare" or "Input Capture Compare". In any case, you are right in assuming that the resolution you can get is directly related to your crystal frequency. What processor are you using? |
|
#5
|
||||
|
||||
|
Re: servo PWM sampling-what Fosc should I use?
I'm using the PIC 16f690,
using the capture mode, I'm able to get the pulse's width ![]() but, Alan Anderson really solved the problem for me ![]() thanks anyway ![]() |
|
#6
|
||||
|
||||
|
Re: servo PWM sampling-what Fosc should I use?
3dude__2231 .... what exaclty are you building anyways?!
</raging curiosity> -q |
|
#7
|
||||
|
||||
|
Re: servo PWM sampling-what Fosc should I use?
actually, nothing too fancy.
(still working on the schematics, as the plan changes everyday). but the main idea is this: I'm transmitting to an R/C receiver, that receiver puts out PWM signals (X and Y axis). one PIC16f690 reads the X axis data, sending the motors reverse bits directly to the motor driver. and the forward bits to the second PIC16f690, that reads the Y data, and decides whether to send "1" and "0", 2 "1"s, or 2 "0"s. that's it ![]() </hoping to satisfy curiosity> Ran. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| What program should I use for website design? | radioshackkid | Website Design/Showcase | 35 | 03-02-2007 22:12 |
| Trying to use a new servo | team1500 | Electrical | 1 | 20-02-2006 21:27 |
| What size breaker should I use for the RC? | Excelsior | Electrical | 4 | 18-01-2006 07:34 |
| Did you use Auto Servo Mode? | Greg Marra | Programming | 8 | 27-04-2005 15:35 |
| What Motors Should I Use? | dddriveman | Motors | 20 | 16-07-2003 21:19 |