Controlling multiple servos.
Gramps
Posts: 117
Hello!
Please give me a hand.
My Board of Ed. Stamp Board has 4 sets of servo pins, so I’m assuming we can
Control 4 servos.
Below is the code we have for one servo.
Each servo and pot gets a different set of pins, correct?
How do i rewrite the code to control 4 servos with 4 pots?
Thanks, Gramps
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
'What is your life?"
"It is even a vapor that appears for a
little time and then vanishes away."
Saint James 61 A.D.
Post Edited (Gramps) : 7/17/2010 12:43:44 AM GMT
Please give me a hand.
My Board of Ed. Stamp Board has 4 sets of servo pins, so I’m assuming we can
Control 4 servos.
Below is the code we have for one servo.
Each servo and pot gets a different set of pins, correct?
How do i rewrite the code to control 4 servos with 4 pots?
Thanks, Gramps
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
'What is your life?"
"It is even a vapor that appears for a
little time and then vanishes away."
Saint James 61 A.D.
Post Edited (Gramps) : 7/17/2010 12:43:44 AM GMT
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The Simple Servo Tester, a kit from Gadget Gangster.
Rich H
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The Simple Servo Tester, a kit from Gadget Gangster.
drive 16 servos;
read 8 pots and drive 8 servos
They may only give you 4 servo headers, but you can hook servos up to any I/O pin, power & ground.
If you want to read 4 pots and drive 4 servos, your software·has to multiplex (weave them together) sequentially and keep looping through. Each servo pause won't be 20 ms, it might be only 3 or 4 since you have 4 in sequence, plus at least 1 ms (typical) to charge your pot cap.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."
Ok, so you just list them in order? Pot 2 pin 8, pot 3 pin 9?
I see what needs to be accomplished, but don't see the code......):
How to separate the electronics power from the servo power? Red and black to servo power, and white and black to pins?
@erco,
Actually i want to drive 6 servo-pots for a total of 12 pins. So one Stamp will do this job,Correct?
Thanks! Gramps
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
'What is your life?"
"It is even a vapor that appears for a
little time and then vanishes away."
Saint James 61 A.D.
Anyway, you might be able to pick the values of the pots and capacitors so the reading of a value takes less than a millisecond, but your whole system has very marginal timing with six servos. It'll work most of the time, but some servos may shake at one extreme of their range. You might gain some advantage by setting up your pots so, when the servos are at the end of their range with the 2-2.5ms control pulse, the pots are at their lowest resistance, thus read the fastest.
Other ways of doing this "better" for six or more servos would be to use an 8-channel Analog to Digital Converter which can read the pot position faster. This is also the point where you might want to think about using a servo controller, like the ServoPAL (x 3) or a Propeller Servo Controller. Either would remove the timing constraint.
It's important to separate the servo power from the electronics power. First of all, servos are motors and can draw quite a bit of current when stalled or under heavy load, up to 1A or so. Secondly, they generate a lot of electrical noise which can get into the power supply if not isolated. Normally, servos are run directly from a 6V to 7.5V Vin rather than from Vdd. This isolates them from the regulated 5V supply and provides a bit more voltage to them. Note: they shouldn't be used with more than 7.2 to 7.5V ... it causes more arcing at the brushes and accelerates their wear. A lot more than that (like 9V or 12V) and you may damage the servos' electronics.
The best way to do this is to set the BOE jumper so you get Vin connected to the servo power pins. For more than 4 servos, you can get nice 3-pin male headers with long pins on both sides from Parallax and put them into your BOE breadboard, then run jumpers to ground, Vin, and an I/O pin, then plug the extra servo cables into the header.
Post Edited (Mike Green) : 7/17/2010 2:19:48 PM GMT
Each time through the FOR..NEXT loop it will use a different pin for the pot and servo. The first time through the loop "i" will be zero so (pot1 + i) will be 7, the next time "i" will be one and (pot1 + i) will be 8, and so on.
As for the power supply, if you are using a six volt supply (and you are using a BOE) you can switch the jumper between the servo pins 13 and 14 to VIN instead of the default VDD. That will bypass the regulator and send the input voltage right to the servo power pins. Higher than six volts is not recommended.
Otherwise, you can use a separate power source connected to the middle pin (power) of the servo, just be sure that the ground of the power source shares the ground with the rest of the board.
Rich H
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The Simple Servo Tester, a kit from Gadget Gangster.
PSEUDO (untested) CODE:
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Post Edited (Beau Schwabe (Parallax)) : 7/17/2010 4:07:18 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
'What is your life?"
"It is even a vapor that appears for a
little time and then vanishes away."
Saint James 61 A.D.
I'm currently building a robot arm with six servos, but I only plan actively control one or two servos at a time. So I'll slew to azimuth, set the shoulder and elbow, finally the wrist and gripper. Now this scheme lacks the flexibility of a propeller chip or a servo controller. But I'm hoping it will work.
I agree with OBC, it's time to move to the Prop. However, in testing the BS2 code that I provided, if you can adjust your R and C values used in the RCTIME so that it completes within 3 ms ... meaning the lines that read:
... the PAUSE 4 could be reduced to PAUSE 1, and the actual duration of RCTIME could be adjusted to 2 ms by the Resistor and Capacitor selection.
...THEN, doing all that the LOOP would update up to 6 servos at 42Hz to 53Hz (<-- roughly) depending on the assigned PULSOUT values.
The POTs would be interleaved so that they update 14 to 18 times a second.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Right now we're testing wrist and gripper functions so 2 servos is all we need.
ServoPAL looks like the ticket!
Gramps,
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
'What is your life?"
"It is even a vapor that appears for a
little time and then vanishes away."
Saint James 61 A.D.
Post Edited (Gramps) : 7/17/2010 9:02:36 PM GMT
I gather if I want to control...say 100+ servos, that the basic stamp can only do 4 reliably.
is there other controllers that would be better?
So, for a BS2 to output this signal, it's got to do a "PULSOUT" for the 1 to 2 mSec per servo -- using up 1 to 2 mSec per servo. So, really, one BS2 can only control 10 servo's, and then only if that's ALL it's doing. Usually you want to be able to talk to the BS2, or have it figure out a new servo position, or detect a collision, so controlling 10 servo's isn't really practical, but that's the upper limit.
Now, the other issue is current -- a servo when 'stalled' can pull 500 mA. Most BS2 boards have a single linear regulator rated at 1.0 to 1.5 amps -- so controlling 3 servo's is the most power that board can put out.
With the basic stamp it would be like Allen describes in that you are going to be very limited with speed and overhead processing. With the Propeller, by itself it could control up to 32 servos from one cog without any external hardware other than one resistor per servo.
There was a thread early on when the Servo32 object was first being put together and tested that explains how with a few external IC's a single propeller could drive up to 144 Servos, and in fact it could do more than 144, but with only 32 I/O's for the Propeller you are 'pin limited' to go any higher than 144 servos.
Here is the discussion thread from 32 to 48 to 96 to 144 servos from one Propeller:
http://forums.parallax.com/showthread.php?p=576634
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
I won't dispute that eventually the Stamp's dance card will be full if it is continuously monitoring N pots and pulsing N servos. There are only so many milliseconds in a day. But I question if everyone needs to perfectly synchronize all their servos simultaneously. In an 8-legged walker, yes, but most applications are simpler and more forgiving. I maintain that there are valid opportunities when a vanilla BS2's 16 I/O pins can read 8 pots and drive 8 servos, or drive 16 servos...
Not all pots & servos in all applications need continuous monitoring. There may be a preferred sequence which allows the Stamp to work with groups of 3 or 4 pots & servos at a time. If there is little or no load on a servo, then it's safe to assume that it will stay where last put, and once it's there you can stop sending pulses.
I've been accumulating lots of those cheap Ebay servos from China, planning a multi-servo robot arm and walker project. One thing I notice is that these Chinese servos aren't geared very low. That is, they have less gear reduction (yet curiously more friction, due to cheap gears) than some name brand servos. Bottom line is, different servos will vary in their power-off holding torque. If the torque is too high and back-drives your servo, you might be able to find a different servo that has more holding torque with no signal applied. As long as the applied torque at a servo joint is lower than this holding torque, it doesn't require continuous pulsing.
You just SET IT... AND FORGET IT! (Thanks to Ron Popeil)
I'm taking the liberty of reading between the lines of Gramps' posts: his Shadow-Bot Arm, and his giant hi-torque servos made from leadscrews and automotive power window motors. When he inevitably combines them makes a world-crushing exoskeleton, those joints will HOLD POSITION in a power-off state, I have no doubts. Especially when he uses a dynamic braking H-bridge! So if I read him correctly, I still say a Stamp is up to the task if the software is written to only read a few pots and drive a few servos at a time. Yes, a Prop is a better processor, but we knew that already. Almost sounds like overkill to me. I'm not happy unless I get the most out of my processor. And I still have LOTS of Stamps in my drawer to use up.
I have had up to 4 servos controlled by a BS1 in one project, only driving one servo at a time. Low loads, worked perfectly. A BS2 would have been overkill on that one!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."
“a world-crushing exoskeleton”
LOL
Yes, you are reading between the lines well. Been hesitant to post any pics because this crude hand functions so poorly. We see some places where some errors can be corrected and may not have to scrap this one and return to the drawing board.
A photo of efforts so far with limited budget, skills, and tools.
Truly the human hand is a marvel of design!
Gramps
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
'What is your life?"
"It is even a vapor that appears for a
little time and then vanishes away."
Saint James 61 A.D.
The Propeller is a bit more complicated to program for (though in the year since I last tried it, maybe they've fixed that) but MUCH faster and MUCH more resources.
Lots of motorized joints with gearboxes there, check this video where the guy uses a sprinkler for a gearbox. Clever!
http://www.youtube.com/watch?v=lDsq26PYhdY
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."
@erco, yes, using the gearbox from the sprinkler is a great idea!
Actually, this is turning into a father-son project.
I’ll be testing the arm using the BS2 here in FL.
OBC will be writing some code for the Prop. When we get together in Ohio
next month, we will attempt to get a demo set up by convention time, August 28.
Regards, Gramps
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
'What is your life?"
"It is even a vapor that appears for a
little time and then vanishes away."
Saint James 61 A.D.
Parallax has a answer to the problem of sending a signal to a servo then sending
signals to other servos and still get back in time to the first servo with a refreshing signal.
It is called a ServoPal item # 28824 ($14.99). I plugs in between the servo and BOE. Once you
send a signal to the ServoPal it keeps sending that same signal to the servo till you send another
signal to that ServoPal. This allows you to send a signal to a servo then go do something else or to another servo and come back later to the first servo.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
······ Joe Fishback
-Robots are my friends-
Yes, ServoPal was mentioned earlier in the thread and looks like a good option.
Thanks for the suggestion!
Gramps
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
'What is your life?"
"It is even a vapor that appears for a
little time and then vanishes away."
Saint James 61 A.D.
The shoulder rotation motor is a suddenly starting and too fast.
Can we slow it down by changing the pulse duration?
And what about ramp up and down? Is it adjustable?
Gramps
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
'What is your life?"
"It is even a vapor that appears for a
little time and then vanishes away."
Saint James 61 A.D.
Isn't this the big window motor controlled by the relay H-bridge that's driven by servo guts? If so, a software tweak to ramp the voltage will try to PWM (flicker) the relays, which is always a bad idea, especially with the current that motor is pulling.
When in doubt, Youtube your problem, like last time.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."
This is a new motor that controls the shoulder rotation(side to side).
The problem is that the arm is so big (and heavy) it's jerky.
Was hoping for some ideas to dampen it down perhaps by starting
and stopping the motor slower.
I may have to go to a motor controller on this one rather then the
relay-H-bridge configuration.
Gramps
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
'What is your life?"
"It is even a vapor that appears for a
little time and then vanishes away."
Saint James 61 A.D.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
'What is your life?"
"It is even a vapor that appears for a
little time and then vanishes away."
Saint James 61 A.D.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."
on the bot we built in Mongolia, it's just such a wasteful way to use
energy!
What about a choke coil-cap arrangement?
.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
'What is your life?"
"It is even a vapor that appears for a
little time and then vanishes away."
Saint James 61 A.D.
If I read you correctly, this joint has a vertical axis and (other than binding from a heavy load) doesn't fight gravity. Seems like this should be easy to control at low speed. At higher speeds, you have too much rotating momentum to fight. You may simply need a drive motor with lower gearing that moves more slowly with mucho el Torquo.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."