Shop OBEX P1 Docs P2 Docs Learn Events
Question on ServoPal for various speeds — Parallax Forums

Question on ServoPal for various speeds

robot.girrlrobot.girrl Posts: 5
edited 2010-10-14 19:52 in Robotics
Good morning,

I am trying to use ServoPal for my boebot. I have tried to use it. I can make it turn - go forward and backward, but I am having a hard time adjusting the speed. Are you able to adjust the speed? I am trying to use it the same way I would using PULSOUT directly to the servos. If the values below should be running at different speeds then maybe the issue is in my code somewhere else.

How do you change the speed using ServoPal?

I tried using the following values for Move = FWD to change the speed, but it seems to be running at the same speed each time:

700, 800 forward
650, 850 forward
500, 1250forward
250, 1000forward
250, 1250forward



My code is similar to this:

Move = FWD 'Start BOE-Bot moving forward,
GOSUB DoMotor ' using the DoMotor routine.


DoMotor:
IF (Move = BKWD) THEN
PULSOUT nInp, 900
PULSOUT nInp, 600
ELSEIF (Move = LEFT) THEN
PULSOUT nInp, 600
PULSOUT nInp, 600
ELSEIF (Move = RIGHT) THEN
PULSOUT nInp, 900
PULSOUT nInp, 900
ELSE
PULSOUT nInp, 600
PULSOUT nInp, 900
ENDIF

RETURN


Thank you for your help

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-10-14 10:41
    The PAUSE 20 is not necessary with the ServoPAL, since the ServoPAL puts the pauses in for you. However, you do need to wait 2ms between commands to the ServoPAL. But that short of a delay is normally accommodated in the regular course of most PBASIC programs.

    If you're getting a velocity near the maximum speed, you may want to try values closer to 750.

    -Phil
  • ercoerco Posts: 20,256
    edited 2010-10-14 10:43
    Yes, you should have full command of servo speeds just like using pulsouts. Please post your exact code for best help.
  • robot.girrlrobot.girrl Posts: 5
    edited 2010-10-14 16:51
    Thank you for the quick response. I have tried various settings, so I think I might missing a concept is the process. Using Pulsout for the servos directly as the basis of my understanding here is what I think I understand (but most likely wrong about)
    *
    I believe that this peice of code initiates the ServoPal
    INPUT nInp********** 'Make sure nInp isn't being driven.
    DO UNTIL nInp******* 'Wait for ServoPAL to power up.
    LOOP
    LOW nInp************ 'Set pin to an output and hold it low
    PAUSE 100*********** ' for 100mS.
    HIGH nInp*********** 'Raise the pin.

    PULSOUT nInp, 2 <-- This line skips Servo 0
    PULSOUT nInp, 500 <-- This line sets Servo 1 signal to 1mS (CW Med)
    *
    I am presuming the following (which may be what I am misunderstanding)
    *
    value pulse width direction & speed
    ********** 250 0.5 CW Full
    ********** 500 1 CW Med
    ********** 750 1.5 Stopped
    ******* 1,000 2 *CCW Med*
    ******* 1,250 2.5 *CCW Full*
    *
    *
    so I am presuming that if I use:

    *
    PULSOUT nInp, 2 <-- This line skips Servo 0
    PULSOUT nInp, 1000 <-- This line sets Servo 1 signal to 2mS (CCW Med speed*)
    *
    and
    *
    PULSOUT nInp,*750 <-- This line stops Servo 0
    PULSOUT nInp, 750 <-- This line*stops Servo 1

    and
    *
    PULSOUT nInp,*250 <-- This line sets Servo 0 signal to .5mS CW Full
    PULSOUT nInp, 1250 <-- This line sets Servo 1 signal to 2.5mS CCW Full* -- so together Boe-Bot would move foward at full speed
    *
    and
    *
    PULSOUT nInp,*500 <-- This line sets Servo 0 signal to 1mS CW Med
    PULSOUT nInp, 1000 <-- This line sets Servo 1 signal to 2mS CCW Med -- so together Boe-Bot would move foward at medium speed
    *
    and
    *
    PULSOUT nInp,*700 <-- This line sets Servo 0 signal to* CW Slow
    PULSOUT nInp, 800 <-- This line sets Servo 1 signal to* CCW*Slow -- so together Boe-Bot would move foward at slow speed
    *
    *
    I have noticed the following results while adjusting the code
    nInp (servo 0) nInp (servo 1) direction ~ degrees
    600 700 turn left 120
    ******* 1,250 ********** 250 backward 0
    1250 1250 turn right 120
    250 250 turn left 120
    1250 750 Pivot back left 80
    750 250 Pivot back right 80
    ********** 750 750 *Stopped* 0
    ********** 600 600 *left* 120
    ********** 900 900 *right* 120
    ********** 250 600 *left* 120
    ********** 250 750 Pivot left 45
    ********** 500 750 Pivot left 60
    ********** 600 750 Pivot left 60
    ********** 700 ********** 800 forward 0
    ********** 650 ********** 850 forward 0
    ********** 500 1,250 forward 0
    ********** 250 1,000 forward 0
    250 1250 forward 0
    *
    Each time I changed the values I changed them in the same place and downloaded the code to the boe-bot. I was thinking the the last 5 cases would produce different speeds along with different degrees of turns, but instead boe-bot moved foward each time at the same
  • W9GFOW9GFO Posts: 4,010
    edited 2010-10-14 17:08
    I think you need to try values that are closer to 750.

    An example;

    Slow: 740, 760
    Medium: 720, 780
    Fast: 700, 800

    As you get further from 750 there will come a point where a greater value has no effect on the speed. That point is different for each servo so it will take some experimentation to find it. Right now, each of your speeds are far enough away from 750 that there may be no difference as far as the servo is concerned.

    Rich H
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-10-14 17:21
    robot.girrl.

    Off-topic, but I'm curious what you used to enter/edit the post with all the asterisks in it. These typically appear in vBulletin whenever a non-breaking space is entered then edited.

    BTW, it's much preferred if you put your program text between [noparse]
    and
    
    [/noparse] tags.

    Thanks,
    -Phil
  • robot.girrlrobot.girrl Posts: 5
    edited 2010-10-14 19:06
    I copied it from an email I wrote earlier, so I am not sure why it created the asterisks. But I did do so using my iPhone so I did not notice at the time.

    Thanks for the suggestions. I will give em a try tonight.

    I will use
    and
    
    tags next time.
  • robot.girrlrobot.girrl Posts: 5
    edited 2010-10-14 19:09
    I will use the code tags next time
    put code here
    

    :jumpin:
  • robot.girrlrobot.girrl Posts: 5
    edited 2010-10-14 19:52
    Thank you!!

    I used the following, and I could see a definite difference in the speeds. So I will go from there to see how far I can push it.

    Slow: 740, 760
    Medium: 720, 780
    Fast: 700, 800

    Thanks again. Boe-bot is off and rolling now :smilewinkgrin:
Sign In or Register to comment.