Servo controller HELP!!
mphillips
Posts: 12
I am trying to make a robotic arm for my class project. I have made the experiment #25 Hobby servo conroller. So i have the one servo controlled by the 10K pot. I have modified the scale part of the program to get about 90 degrees of sweep on the one servo.
Now how do i go about writing a program to control 3 servos from 3 different 10K pots?
Im sure its just a little modifying to the program in experiment #25, But i dont know where to modify it
Now how do i go about writing a program to control 3 servos from 3 different 10K pots?
Im sure its just a little modifying to the program in experiment #25, But i dont know where to modify it
bs2
513B
Comments
To control two servos the same way, just duplicate the same code with different variable names and different I/O pin numbers with a single GOTO at the end so first one pair of pots are measured and one servo moved, then the other pair of pots are measured and the other servo moved, then the whole thing repeats. The single PAUSE 20 at the end will have to be made even smaller since you're now measuring 4 pots and doing a PULSOUT to two different servos.
You can probably repeat this process once more to control 3 servos and reduce the final PAUSE again to compensate for the time used for handling the third servo.
You may not be able to do four servos since all the measuring and controlling can take more than 20ms and you've run out of time.
BUT, if you want to go farther and make a programmable robot arm, a Stamp (or a programmable servo controller) is the way to go.
Did you build your own arm? We'd love to see pics of it. Here's what I did with 3 servos in one evening:
http://www.youtube.com/watch?v=-Z8lTSX4PHs
Like Gramps' Shadow-Bot!
Thanks for the quick reply. let me try to apply the different i/o pins and commands cause im new to the programming side of things. So i am not very keen on the whole programming lingo.
I have to use the stamp cause its a class project that im working on in digital class. I have not built anything mechanical yet. Im just trying to figure out how to program 3 servos and the weight that they are going to be able to handle before going into the build.
Ill put a few pics of the prototype first servo build so far.
I can pick up the pen at this distance no problem!
!!!!!!!!!!!!!!!!!!!!!! DANG!!!!! That's cool! Look at the smirk on his face!! "That's right, I'm the man and I know it"
I figured out how to control multiple servos now. I have two servos going now with two different 10k pots. Its pretty damn sweet. one is a little sluggish but that could be cause i dont have the right value capacitors and the resistors vary a little bit. I was just using what i had around the house. now im ready to build the mechanical side of things. ill keep everyone posted on the build.
Till then check out the program i have and tell me if i can make it any better. I was just tinkering with the program and it ended up working!! Thanx again everyone
Attachment not found.
You could run several 5V voltage regulators, one for each servo.....to keep heat to a minumum. or use a BEC (battery elimination circuit) or an ESC with a BEC (Electronic speed control, just wouldn't use the ESC part) both of which should be available at a hobby shop selling RC airplane Smile. The typical BEC will efficiently give you 4.8V at 5A a.k.a. without all the heat
FWIW: I use a 1200mA 4-cell NiMh pack for such things. I give $9 for it and have recharged the thing a hundred times. You COULD break open the 9.6V pack and remove four cells.... or break it in half and have two packs to play with your robot
For your code, try to put all pulsouts together to minimize dead time; you currently have two seperate "pause 10"s, something more like:
Main:
HIGH PotCW
HIGH PotCCW
HIGH Pot1CW
HIGH Pot1CCW
PAUSE 1
RCTIME PotCW, 1, rcRt
RCTIME PotCCW, 1, rcLf
RCTIME Pot1CW, 1, rcRt1
RCTIME Pot1CCW, 1, rcLf1
rcRt = (rcRT */ Scale) MAX 250
rcLf = (rcLf */ Scale) MAX 250
sPos = rcRt - rcLf
rcRt1 = (rcRT1 */ Scale) MAX 250
rcLf1 = (rcLf1 */ Scale) MAX 250
sPos1 = rcRt1 - rcLf1
PULSOUT servo, (750 + sPos)
PULSOUT servo1, (750 + sPos1)
PAUSE 10
GOTO Main
Some servos may not need that pause 10 at all, try and see.
Code is forever. If it was working as you intended, it should continue to function that way. You may have a wiring or hardware error in addition to battery issues.
But you may still have battery issues if you're just burning through 9V batteries. Try a big 6V lantern battery and you'll see an improvement.