Shop OBEX P1 Docs P2 Docs Learn Events
Servo stepping weirdness? — Parallax Forums

Servo stepping weirdness?

firestorm.v1firestorm.v1 Posts: 94
edited 2009-02-24 03:06 in BASIC Stamp
I'm a bit rusty at working with the servos so feel free to call me out on it. I've been working with the servos in setting up a 2 axis pan/tilt system for a laser pointer for the cats. (Been done before, but I wanted the experience of using CASE statements and subroutines.)

All three servos (the third pushes the button on the laser) behave erratically, despite all having been tuned properly.

Following the manual, I have the three servos tuned to where a 750usec pulse is zero. Anything less than should cause the servo to move one direction, anything more moves the other.

One thing I'm noticing is that even though I use the same offset, say -5 to move left and +5 to move right, the servos are more "eager" to turn one direction than the other. Below is the snippet for the move left and move right subroutines.
Xaxis is the pin of the servo, XPOS is a counter that will "home" the laser pointer on shutdown and is essentially not used for anything yet.

MoveLeft:
  DEBUG "ML",CR
  FOR counter= 1 TO 5
      PULSOUT Xaxis,746
      PAUSE 20
  NEXT
  Xpos=Xpos -1
  DEBUG "X=",DEC Xpos,CR
RETURN

MoveRight:
  DEBUG "MR",CR
  FOR counter= 1 TO 5
      PULSOUT Xaxis,753
      PAUSE 20
  NEXT
  Xpos=Xpos +1
  DEBUG "X=",DEC Xpos,CR
RETURN




Even with the lopsided offsets, if I run MoveLeft once, I have to run MoveRight twice to pass the same distance, and even then it's not exact. I'm not expecting laser-like accuracy, (pardon the pun) but when the target wall is less than 10 feet away, I would like to it be within a couple of inches. The values I'm sending are as close to 750 as the servos will respond to, anything closer and the servo does not move that direction.

Is there something I'm doing wrong? Am I not sending the right pulses?

Thanks for your help!

Comments

  • stamptrolstamptrol Posts: 1,731
    edited 2009-02-23 15:38
    The servos expect to be refreshed every 20 mSec, I believe.

    Try your program without any Debugs and reducing the PAUSE statements.

    Also, you're looking for a lot of precision from a relatively small change of variable. Can you arrange some gearing so the servo turns 90 deg or so as the laser moves in a smaller arc?

    Cheers,

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tom Sisk

    http://www.siskconsult.com
    ·
  • LilDiLilDi Posts: 229
    edited 2009-02-23 17:43
    Firestorm,
    Two things to consider. Servo pulses are from 1 millisecond to 2 millisecond with 1.5 milliseconds being center. The pulses should be every 20 milliseconds to hold the servo in position. You are sending 750 microsecond pulses, not 1.5 millisecond pulses to center the servo.
    Also each of the Basic Stamp modules has a different unit duration for PULSOUT. See the syntax guide for details.

    Interesting thing to note: If you are using a BS2, BS2e, or BS2pe then "PULSOUT pin,750" is indeed 1.5ms. If you are using a BSsx, BS2p, or BS2px then "PULSOUT pin,750" is actually 600us.

    Post Edited (LilDi) : 2/23/2009 5:57:51 PM GMT
    1283 x 1013 - 309K
  • firestorm.v1firestorm.v1 Posts: 94
    edited 2009-02-24 00:55
    @ LilDi I'm using a BS2 (formerly my Boe-bot) and I got the timings from the Boe-bot manual.

    @stamptrol I'm not concerned about the "accuracy" per se, but if I hit the right button and the laser moves right 3 degrees, I would at least expect the laser to move left 3 degrees when I hit the left button. (implemented elsewhere). Even when using the same timing offset. (-5, +5) the servos still moved different distances.

    Regardless of the timings, it always seems that the servo would travel farther in one direction than it would the other and that is the concern I have. I don't know if I need to re-calibrate the servos or what else could be amiss. The code is the same as the code used in the Boe-Bot and in the original Basic Stamp homework board.

    I thank you both for the quick replies, if there's anything I can try please let me know.
  • FranklinFranklin Posts: 4,747
    edited 2009-02-24 03:06
    If you are using continous rotation servos you will not have any repeatability in your position and servos were never designed to be precise. they were designed to move in response to a signal and be controlled by human feedback. If you are using normal servos the repeatability is better but not great.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
Sign In or Register to comment.