Help with Servo Control Please!


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Jun 2007
    Posts
    4

    Question Help with Servo Control Please!

    Hello,
    I am trying to control a servo using 3 buttons (1 for moving it left, one for centering it, and one for moving it right).

    Im following the example from the index help file where it talks about servos, but the buttons do not seem to make the servo respond at all. I know I am able to communicate with the servo by using this code to center it:


    DEVICE=16f818
    xtal=20

    DELAYMS 100
    DIM Pos as WORD
    SYMBOL PinA = PORTA.3

    PORTA=0
    TRISA = %00000001

    Again:
    SERVO PinA , 1500
    DELAYMS 20
    GOTO Again

    Im using a 16f818 with 20mhz crystal. The code below is from the help index and is supposed to move the servo like previously stated:

    DEVICE 16F628
    DIM Pos as WORD
    SYMBOL Pin = PORTA.3

    Pos = 1500

    PORTA = 0
    TRISA = %00000111

    ' ** Check any button pressed to move servo **
    Main:

    IF PORTA.0 = 0 Then IF Pos < 3000 Then Pos = Pos + 1 ' Move servo left
    IF PORTA.1 = 0 Then Pos = 1500 ' Centre servo
    IF PORTA.2 = 0 Then IF Pos > 0 Then Pos = Pos - 1 ' Move servo right

    SERVO Pin , Pos
    DELAYMS 5 'Servo update rate
    GOTO Main

    I was pretter sure this meant to connect one end of the buttons to gound and the other end to the corresponding pin on porta. The buttons don't seem to do anything at all, if in fact, interfere with the original code to center the servo. Im just learning pbp so any help would be great, thanks!

  2. #2
    Join Date
    Aug 2006
    Posts
    14


    Did you find this post helpful? Yes | No

    Default

    Hate to tell you, but you've got the wrong forum. Pic Basic Pro has no Servo command

    Proton Basic perhaps? (They're not the same)

  3. #3
    Join Date
    Jun 2007
    Posts
    4


    Did you find this post helpful? Yes | No

    Default snap

    Thanks, wow, I never even thought to look at that.

  4. #4
    Join Date
    Jun 2007
    Posts
    4


    Did you find this post helpful? Yes | No

    Default

    So proton uses pic basic then and not pic basic pro? I just got it today so am a little confused, thanks.

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by wireman22 View Post
    So proton uses pic basic then and not pic basic pro? I just got it today so am a little confused, thanks.
    Proton Basic <> PicBasicPro
    Different companies, different continents...

  6. #6
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Post

    Hi,

    No need to be a Proton expert to see the example is ... not so good !

    a closer look to your "Help file" example will show you there's some inconsistance ...

    1) Buttons are connected between inputs and ground, good ... BUT you must add 10k resistors between V+ and inputs to give some "pullup" ...

    2)

    Replace

    IF PORTA.0 = 0 Then IF Pos < 3000 Then Pos = Pos + 1 ' Move servo left
    IF PORTA.1 = 0 Then Pos = 1500 ' Centre servo
    IF PORTA.2 = 0 Then IF Pos > 0 Then Pos = Pos - 1 ' Move servo right

    by

    IF PORTA.0 = 0 Then IF Pos < 2200 Then Pos = Pos + 1 ' Move servo right
    IF PORTA.1 = 0 Then Pos = 1500 ' Centre servo
    IF PORTA.2 = 0 Then IF Pos > 800 Then Pos = Pos - 1 ' Move servo left

    This will prevent damaging your servo or having strange behaviour ... by overtravel !!!

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  7. #7
    Join Date
    Jun 2007
    Posts
    4


    Did you find this post helpful? Yes | No

    Default

    Thanks for all the help! even though i'm in the wrong forum :0. So any thoughts on which is better? Is proton a good software package. I got it without really knowing what else is out there? Thanks!

  8. #8
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by wireman22 View Post
    Thanks for all the help! even though i'm in the wrong forum :0. So any thoughts on which is better? Is proton a good software package. I got it without really knowing what else is out there? Thanks!
    Asking that in a Picbasic pro forum... you're probably going to get a slightly bias answer

    There are several languages that allow you to program PIC's, and then several variants with in those. Most will allow you to get started, some will allow you to progress better than others, most have excellent support, either direct or via forums like this one.

    Some, like MicroBASIC are free up to a limit of 2K of code, others can cost upwards of £200 (like PicBasic Pro) but then you are using a "professional" application which is very strong.

    I'm sure if you lurk over on the correct forum and post your questions there you will get as much support as you need.

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. Servo control woes
    By Eriswerks in forum mel PIC BASIC Pro
    Replies: 24
    Last Post: - 28th February 2006, 00:12
  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 : 1

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