Servos.. I am confused
Randi
Posts: 8
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
·
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
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
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.
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