The best way to control a servo with a PIC


Closed Thread
Results 1 to 40 of 42

Hybrid View

  1. #1
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    Ive just done a quick bit of maths. I think if i set the timer to overflow when it reaches 39 (or start 39 before 255 ofcourse) then i should be able to get the resolution i want. I could in theory control quite a few servos by using almost identical code to the LED code. All i need to do is add that long pause in.

    Im always really ambitious so i might even try the origional plan again and control the servos from the same PIC as the LEDs. If i make the timer overflow every 39 instruction cycles that means it will run the PWM code every 7800ns. I can setup my own counter to only run the PWM code for the LEDs every 6 or 7 times the timer overflows. That should make the LED code run pretty much as normal. Now i can simply turn the servo output on then on each timer overflow count upto the servo value (plus a bit). The servo pulse range is 2000us so an overflow every 7.8us gives me a resolution of 256.41. If im not bothered about the 41 (and im not) then it matches the byte perfectly.

    I cant say if this method will work without trying it. It all depends on how many instruction cycles i have spare. I think its worth a try and i always have the seperate chip method if it fails.

    Edit: The type of servo im using seems happy to accept any length pulse i give it but if its outside of its range then it tries to turn too far and ends up buzzing at me
    Last edited by The Master; - 15th October 2008 at 09:32.

Similar Threads

  1. More Servo Woes
    By chrisshortys in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 13th May 2009, 08:40
  2. Help with Servo Control Please!
    By wireman22 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 7th June 2007, 18:15
  3. Servo control / UART / SPI help needed
    By Blackhawk in forum mel PIC BASIC
    Replies: 10
    Last Post: - 10th November 2006, 03:40
  4. How would i write this in pic basic pro (Servo controller)
    By Jhdgkss in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 10th February 2006, 08:21
  5. Control RC servo via Parallax Servo Control
    By cibotsan in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 17th September 2005, 08:18

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts