Servo problems
I'm an EE major and I've been issued a BS2 for my industrial automation class, been playing with it and having fun so today went to the RC store and get some servos (JR Sport ST47 47 ounce). Using the pulsout I can send the servo to a position easy enough but no matter how I write the code I can't make the position change during the program.
Like say I wanted it to rotate clockwise:
a VAR Word
FOR a = 350 TO 1250 STEP 10
PULSOUT 7, a
PAUSE 20
NEXT
Should do it right? What happens when I run that is the servo rotates to the PULSOUT 350 spot and just stays there.
It does the same thing if I use a DO WHILE with a counter variable or make a series of IF statements that accepts input from DEBUGIN to send it to routines to change position. It seems like whatever PULSOUT it encounters in the program first, it just stays there.
Any ideas what the problem is?
Thanks
Like say I wanted it to rotate clockwise:
a VAR Word
FOR a = 350 TO 1250 STEP 10
PULSOUT 7, a
PAUSE 20
NEXT
Should do it right? What happens when I run that is the servo rotates to the PULSOUT 350 spot and just stays there.
It does the same thing if I use a DO WHILE with a counter variable or make a series of IF statements that accepts input from DEBUGIN to send it to routines to change position. It seems like whatever PULSOUT it encounters in the program first, it just stays there.
Any ideas what the problem is?
Thanks
Comments
Are you sure it's not the 1250 spot?
By the looks of your program it is running correctly, however after 90 itterations or about 1.8 seconds· (1250-350)/10 = 90 * 20mS = 1.8 seconds
it·stops·and there is nothing to tell it to continue doing anything else.
Try something like this:· (Should "pan" the servo back-n-forth)
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
I'm powering the Stamp off a 9v and the servo off another 9v voltage divided down to about 5.5v, if that makes any differance
Also, are you sharing the ground supplies between the servo and the stamp? ....using the correct pin on the BS2? (pin#12)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Earlier I was trying to power the servo off pin 21 VDD, it was my understanding that when Vin was supplied with a voltage, this pin would be regulated to +5, after looking at my spec sheet it seems I was trying to power the servo with pin 22, Reset. Could this have damaged the servo or stamp?
Thanks for the help
-Brett
This is likely the culprit.· Your servos are going to require several mA of current,· and using a resistor divider is not going to be adequate
for this particular application.· Mainly because you have a varying load depending on what you are demanding of your servos,· that alone
will throw a resistor divider scheme out of whack.· While the regulated 5V from the Stamp "might" work, it's not something I would advise
for long term use, especially with any kind of respectable load on your servo.· The best thing to do is use an external voltage regulator such
as an LM7805 and make sure that the grounds are tied together.
If I were you, I would take a look at the "What's a Microcontroller"
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
In this way, the BasicStamp can provide power to a transistor, MOSfet, darlington, or UNL2003 that controls the motor without suffering sags from the motor starting or being stalls. If the sags are significant, the BasicStamp will often just loop through a reboot.
A voltage divider seems an easy way to provide an alternative power, but it is both quite wasteful of power and tricky to get right. A voltage regulator really is a much better solution than a divider as the votage will hold within a few percent over a wide range of flux.
If you can get LM2940-5 regulators instead of the 7805, you will find that they are more forgiving of mistakes [noparse][[/noparse]shorts and reversed polarity], operate at lower battery voltages, and can actually prevent a lot of frustration. They do require a larger capacitor on the output side.
They do come in other voltages - like the LM2940-3.3 for 3.3volts, LM2940-12 for 12.0 volts.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"If you want more fiber, eat the package.· Not enough?· Eat the manual."········