Servo not reaching full travel


Results 1 to 40 of 40

Threaded View

  1. #6
    Join Date
    Mar 2006
    Location
    China
    Posts
    266


    Did you find this post helpful? Yes | No

    Default Try this

    Hi,

    Hook up a 10k potentiometer (or whatever you have in your drawer) to i.e AN0. Vdd on one side of the pot. GND on the other and the wiper goes to AN0. Put a 0.1 uF cap between wiper and GND to reduce noice .Connect the servo on i.e PORTB.1 ... if you use a voltage meter on the wiper and adjust the voltage to ~3 V you should get a 1.5 ms pulse every 20ms. Now you can turn the pot and then you can try the end positions... your LCD will be great here.


    DEFINE ADC_BITS 8

    ' DEFINE YOUR LCD SETTINGS HERE

    SERVO1 Var PORTB.1
    AD0 var word
    SERVO1_Pulse var byte
    Total_Delay var word
    n var byte

    TRISA 255 ' PORTA to input
    ?????????? 'set up as analog CHECK DATASHEET for you PIC
    ?????????? ' turn off comparators CHECK DATASHEET

    n=0
    Goto main


    update_LCD:
    n=0 'reset LCD loop counter
    'Here you write your LCD code to send the Servo1_pulse value to your LCD
    RETURN

    main:

    ADCIN 0, AD0 'READ POT
    SERVO1_Pulse=AD0*10 'Scale value max = 2550 us
    SERVO1=1 'Start the servo pulse
    Pauseus(SERVO1_Pulse) 'wait a while
    CH1=0 'Stop the pulse
    Total_Delay=(20000-Servo1_Pulse) 'calculate loop delay so we
    Pauseus(Total_Delay) 'get approx 20 ms loop time
    N=n+1
    if n>=50 then gosub update_LCD 'update LCD every 50 loops i.e once per second
    goto main

    end


    try it and if it doesnt work let me know so I can help. This code is untested but should work if you set up the analog port correctly. After this you will atleast know how far your servo will travel.

    /me
    Last edited by Jumper; - 22nd December 2007 at 13:58.

Similar Threads

  1. More Servo Woes
    By chrisshortys in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 13th May 2009, 09:40
  2. Problem with 12F629, servo and EEPROM
    By Atom058 in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 1st March 2008, 10:53
  3. Servo does not move
    By ruijc in forum General
    Replies: 12
    Last Post: - 12th November 2007, 20:14
  4. Beginner + Servo
    By james in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 31st July 2007, 22:31
  5. Help with Servo Control Please!
    By wireman22 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 7th June 2007, 19:15

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