PDA

View Full Version : pulseout resolution



cpayne
- 6th October 2005, 17:54
I am trying to control a servo. Its actually a sail winch servo that turn 4 360 degree turns. With an RC controller I can adjust the servo in very small increament (~1-2 degrees). With a pulseout command of the PIC I can not acheive the same resolution. Is there way or a trick to sending out like a 152.4 ms pulse as an example? perhaps I should use the PWM? any ideas?

Thanks
Charlie

Darrel Taylor
- 6th October 2005, 20:01
Hi Charlie,

At 4Mhz OSC, the resolution of PULSOUT is 10us.

The range of pulses required for servos is from 1.05ms - 1.95ms. That's a difference of 900uS. With 10us resolution you will get 90 steps of about 16 degrees each. Assuming a 4-turn rotary.

At 20mhz the resolution is 2us, which will give 450 steps of about 3.2 degrees per step.

At 40mhz you can get 900 steps of about 1.6 deg/step.

Or, at 4mhz you can use this program to get 900 steps too.
PWPS (Pulse Width Position Servo)
http://www.pbpgroup.com/modules/wfsection/article.php?articleid=2

HTH,
  Darrel

cpayne
- 6th October 2005, 20:31
The PIC is going to be doing some serial receipts, so I would prefer not to do the interupts of the PWM example. Anyway of using the hardware PWM? Or what about a timer to hold a pin open? I don't need to hold the servo, just set it.

Although zooming the PIC at 40MHz may be the way. I was planning on using the 16F1628 and utilize its internal oscillator...

Darrel Taylor
- 6th October 2005, 20:58
If you're going to be doing serial comms with a 16F628. Then all the more reason to use the interrupt driven version. I could see it if you could only use SEROUT2, but the 628 has a USART. With the PWPS program, it all happens in the background, leaving you to do HSERIN/OUT at your leasure, without having to worry about timing the serial stuff in-between the pulses.
<br>