Shop OBEX P1 Docs P2 Docs Learn Events
Servos.. I am confused — Parallax Forums

Servos.. I am confused

RandiRandi Posts: 8
edited 2008-06-06 15:16 in BASIC Stamp
OK... I read these forums and couldn't find my problem, so I am stuck asking everyone.

I have the BS2 and some servos from Parallax.
I have been reading the microcontroller PDF with no luck.

Here is my problem...

If I do this...
counter VAR Word
FOR counter = 1 TO 150
PULSOUT 7, 750
PAUSE 20
NEXT


Which is from the PDF, the servo goes crazy back and forth.

If I just do this...
PULSOUT 7,750

It works most of the time.
It may go crazy for a few seconds but eventually stops in the right spot.

Ok... so what if I did this...
PULSOUT 7,750
PAUSE 3000
PULSOUT 7,550


Well... the first one works...pauses... then it goes crazy.
Back and forth until it totally screws up and I have to pull the battery.

Then.. if I do this whole code from the PDF...
counter VAR Word
DEBUG "Counterclockwise 10 o'clock", CR
FOR counter = 1 TO 150
PULSOUT 7, 1000
PAUSE 20
NEXT
DEBUG "Clockwise 2 o'clock", CR
FOR counter = 1 TO 150
PULSOUT 7, 500
PAUSE 20
NEXT
DEBUG "Center 12 o'clock", CR
FOR counter = 1 TO 150
PULSOUT 7, 750
PAUSE 20
NEXT
DEBUG "All done."
END


The servo goes nuts and the debug screen just keeps printing "Counterclockwise 10 o'clock" over and over.

I have the white wire hooked up to pin 7, the red going to VDD, and the black going to VSS.
What am I doing wrong? I don't get it.

It seems like everything should be good.

I do worry about this BS2, because I did buy it on eBay.
So am I not doing something right or could this stamp be bad?
Any ideas? Anyone?

Randi
·

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-06-06 05:05
    What's happening is that you have inadequate power available for both the servo motor and the Stamp. The servo can draw up to 1 Ampere peak current and an average when moving of maybe 1/4 Amp. Without adequate power, when the servo starts to move, the power supply voltage drops enough so the Stamp can't operate and it resets. This reduces the power drain enough so it can start up again and the whole cycle repeats. Ideally, you should have a separate battery for the Stamp and the servo with a common ground connection (required).
  • RandiRandi Posts: 8
    edited 2008-06-06 05:32
    Sure enough!

    I added another 9volt to the servo.
    Put the grounds together.
    And it works like a charm.

    Thanks a lot!!

    I sure don't know why it doesn't tell you to do that in the tutorials?
    Sure would have spared me.
    But what ever... I am back to being happy.

    Thanks again...

    Randi

    www.randirain.com
  • Lee HarkerLee Harker Posts: 104
    edited 2008-06-06 13:29
    Randi,

    There's one other thing that is often overlooked when working with servos. It's the time the servo takes to reach the new position. It takes about 1/4 second to turn from one end to the other. That seems pretty short but in the life of a microcontroller it is forever.

    Your examples mostly show an incremental movement so the servo will usually keep up. If you send a single command to·move·the servo to a position say 90 degrees from its current position, the pulse will be gone long before the servo gets there. The servo expects to be·refreshed every 20msec so it may only go part of the way to where you want it. The simple solution is to repeatedly send the·position pulse along with the 20msec delay until the servo gets to where you want it. You will have to figure this empirically since each model of servo is a bit different. Usually 10 iterations is enough.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-06-06 13:33
    9V Transistor Batteries are terrible for running servos. They have very little capacity, either for peak current output or for total current that can be supplied over time. They're fine for running a Stamp or a Stamp plus an LED. Servos can be damaged by voltages over about 7-7.5V. They're designed for use with 4 to 6 rechargable NiMH batteries (4.8V to 7.2V). Voltages higher than that increase the arcing of the brushes inside the motor (look up Brush Motor on the Wikipedia) and cause increased wear. A good battery pack is to use 4 or 5 AA alkaline battery cells like what's used in the BoeBot.
  • RandiRandi Posts: 8
    edited 2008-06-06 15:16
    Thanks Lee.

    Thanks Mike... I just used the 9v because it's what I had available at the time. I will switch to a AA pack.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Randi

    http://www.randirain.com
Sign In or Register to comment.