Servo Control


Closed Thread
Results 1 to 8 of 8

Thread: Servo Control

Hybrid View

  1. #1
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    to make your back and forth stuff, if your motor don't need much current, it will be easier to use a H-Bridge driver IC like NJM2670 or else.

    By using 2 i/o, you'll be able to do it easy...

    will look something like this
    Code:
    TRISA = 255 ' set PORTA as input
    TRISB=0 ' set PORTB as output
    
    Motor1_a var PORTB.0  
    Motor1_b var PORTB.1
    
    PushButtonForward var PORTA.0 ' Push button connected 
    PushButtonReverse var PORTA.1 ' between vcc and PIC pin
    PushButtonStop Var PORTA.2
    
    PORTB=0
    
    Start:
         If PushButtonForward then 
              Motor1_a = 1
              Motor1_b = 0
         endif
    
         If PushButtonReverse then
              Motor1_a = 0
              Motor1_b = 1
         endif
    
         If PushButtonStop then
              Motor1_a = 0
              Motor1_b = 0
         endif
    
         goto start
    to measure the distance you'll have to use rotary encoder, opto devices or something who will provide you some pulses when motor/wheel is turning. By counting those pulse in background (on RA4 pin using internal Timer/Counter module) you'll have some numbers to do your maths

    For the speed...it's up to you... some will use PWM, some will vary the voltage accross the motor and probably there's many other way to do it... food for brain cells ;o]
    Last edited by mister_e; - 12th February 2005 at 16:06.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. More Servo Woes
    By chrisshortys in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 13th May 2009, 08:40
  2. Replies: 10
    Last Post: - 26th May 2008, 07:00
  3. Help with Servo Control Please!
    By wireman22 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 7th June 2007, 18:15
  4. Control RC servo via Parallax Servo Control
    By cibotsan in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 17th September 2005, 08:18
  5. Servo control with 12F629
    By achilles03 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 23rd June 2005, 23:34

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