Shop OBEX P1 Docs P2 Docs Learn Events
Servo controller HELP!! — Parallax Forums

Servo controller HELP!!

mphillipsmphillips Posts: 12
edited 2011-03-09 08:42 in BASIC Stamp
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

Comments

  • mphillipsmphillips Posts: 12
    edited 2011-03-06 12:29
    I just attached the program i have wrote so u know what im working with.
  • Mike GreenMike Green Posts: 23,101
    edited 2011-03-06 13:44
    First of all, you might have noticed with your sample program that the servo buzzes or stutters sometimes. A servo must receive about 50 control pulses per second or it shuts itself down until the next pulse comes in. When the servo is shut down, there's no power to the motor and, if there's a load on the motor (like you're trying to turn it), it slips while the power's off. Your program sits in a loop measuring the pot positions and this takes time. The higher the value returned by RCTIME, the longer it took to measure. Values greater than 500 are already taking more than a millisecond to measure. The PULSOUT used to control a servo will take 1ms to 2ms to execute. When you add a couple of PAUSE statements with one of them a PAUSE 20, you're now talking about maybe 25ms. That's getting near to where some servos may turn off. You have to reduce the PAUSE 20 to compensate for the time that the other statements take.

    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.
  • ercoerco Posts: 20,256
    edited 2011-03-06 15:41
    If you just want to "remote control" 3 or more servos using one pot per servo, you'd come out simpler & cheaper by building some 555-based "servo tester" circuits instead of using a Stamp.

    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
  • ercoerco Posts: 20,256
    edited 2011-03-06 16:42
    BTW, here's a very simple 555-based servo controller, the second one listed at http://www.555-timer-circuits.com/servo-tester.html You need one of these circuits for each servo. And a 556 timer contains 2 555 timers, FYI...
    300 x 220 - 4K
  • ercoerco Posts: 20,256
    edited 2011-03-06 16:50
    This guy's justifiably proud: http://www.youtube.com/watch?v=-XChu20hTxU&feature=related

    Like Gramps' Shadow-Bot!
  • mphillipsmphillips Posts: 12
    edited 2011-03-06 18:25
    I so far have not had any problems with the servo turning "off". It always holds its position when in idle state even with a load. If im understanding u right i am not having any problems with this aspect yet.

    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.
  • mphillipsmphillips Posts: 12
    edited 2011-03-06 18:39
    DSCN0383.jpg
    DSCN0382.jpg
    DSCN0384.jpg


    I can pick up the pen at this distance no problem!
    1024 x 768 - 151K
    1024 x 768 - 132K
    1024 x 768 - 123K
  • ercoerco Posts: 20,256
    edited 2011-03-06 20:03
    If you're powering your servos with that same 9-V battery, that's going to be a problem pretty quickly. A new 9V will barely last a few minutes driving several servos, and the voltage will drop, resetting your Stamp. You should power the servos from a seperate big battery, like a 6V from D-cells, a lantern battery, a gel cell, or an RC car battery. Connect the negative of your Stamp-only 9V to the negative of your servo battery.
  • Spiral_72Spiral_72 Posts: 791
    edited 2011-03-07 11:40
    erco wrote: »
    This guy's justifiably proud: http://www.youtube.com/watch?v=-XChu20hTxU&feature=related

    Like Gramps' Shadow-Bot!


    !!!!!!!!!!!!!!!!!!!!!! DANG!!!!! That's cool! Look at the smirk on his face!! :) "That's right, I'm the man and I know it"
  • mphillipsmphillips Posts: 12
    edited 2011-03-07 19:42
    Thanks for the tip on a bigger power source. Ill probly use a rc car battery. I have a 9.6 volt one that would work great

    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.
  • Spiral_72Spiral_72 Posts: 791
    edited 2011-03-08 07:24
    .....just to make sure you know: You can't run RC servos directly off a 9.6V supply. You'll need some voltage regulators in there Lest' ye' smoke thy servo.

    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 :)
  • ercoerco Posts: 20,256
    edited 2011-03-08 09:31
    6V is a safe max voltage for servo supply voltage. On rare occasions, I'll push to 7.2V if the loads are light and I "feel the need for speed".

    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.
  • mphillipsmphillips Posts: 12
    edited 2011-03-08 16:55
    ok i got the two servos working good. For about 60 seconds then they both stopped all of a sudden and the led turned off on the stamp. If i disconnect the battery for a sec then reconnect it one servo pulsates at a rate of about 2-3 pulses a second and rapidly slows to a stand still. than the stamp turns off again (led off). I used multiple new batteries so that isnt it. any ideas fellas???
  • mphillipsmphillips Posts: 12
    edited 2011-03-08 17:07
    I left it sit for 10 mins while i ate dinner and when i came back to it i powered it up and it works fine now. I checked for shorts, could it be my program is not right??
  • ercoerco Posts: 20,256
    edited 2011-03-08 17:30
    Could be lots of things, probably batteries. As stated, those 9V batteries are not good for servos for more than a minute or two. They recovered somewhat while you ate dinner. Their voltage will drop again and cause glitches. A short could also drain your batteries faster.

    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.
  • mphillipsmphillips Posts: 12
    edited 2011-03-08 17:36
    sorry It was a dead battery. a 9 volt battery only lasts about 2 mins with two sevos. Go figure!!! sorry again fellas
  • mphillipsmphillips Posts: 12
    edited 2011-03-08 19:26
    how can i speed up the servo???? its a little slow for my liking
  • ercoerco Posts: 20,256
    edited 2011-03-09 08:42
    Lower speed means higher torque and higher accuracy/repeatability. If you're building a robot arm to pick up things, you'll value torque & accuracy much more than speed. Wait & see, my young Padawan...

    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.
Sign In or Register to comment.