| Hempel Design Group | / Home / lego / servos / |
| Using R/C Servos with the RCX |
For a long time now, regular participants in the LUGNET Robotics newsgroup have wished for a way to control more outputs, control Technic pneumatics, and to have more options for output devices. This page describes a very simple circuit that lets you control a standard RC servo in one of two positions using the standard LEGO Mindstorms software.
If you only want to move the servo and not hold it in one position, then you can actually control two servos from one RCX output by simply removing components from the circuit below.
Finally, if you want really fine control of the servo position, then you'll want to get the new pbForth distribution.
The big trick here is finding servos that work within LEGO geometry. A "standard" sized servo is just too big to work into most models. Micro servos are generally weaker, more expensive, and very delicate. I stripped two gearsets myself before giving up on these miniature marvels.
The best all-round servo that I have found is the S200 from FMA Direct. It jsut happens to fit into the space of a 4x4x2 brick, not including the ears. LEGO Engineers take note: The guts of this servo would easily fit inside a molded part!. Combined with the circuit below, the servo is an easy way to control pneumatics effectively. It can also be used for precise steering, directional beacons, and any other application where the control signal specifies a position, not just direction. The servo's internal circuitry is used to set the postion, saving a rotation sensor on your model.
The entire assembly fits neatly inside the boundaries of LEGO dimensions as shown in the picture below:
The next three photos show the mechanism I developed to move pneumatic switches. Note that the bulk of the mechanism is there for support. In a real model, we could use other types of bracing. The trick is to get your throws just right.
I drilled holes in the standard "circle" servo arm. The servo also ships with a T shaped arm, and an L shaped arm. The holes accept Technic pins, although they are loose. The arms are made of nylon, which does not bond to ABS with solvents. I could use epoxy, but I wanted to play with things a bit more before I did anything permanent.
You can use pbForth for very fine control over the servos, which in turn gives you control over the pneumatics. All you need is the simple electronic circuit below which converts the motor waveforms to servo waveforms!
If you are very sure of your servo settings, you can get away with shorter throw ranges. The problem is that when the throw can't go any further, the servo will try to get there, and you end up straining the motor. In the very worst case, you'll strip the gears.
DISCLAIMER: The circuit below is not endorsed or authorised by LEGO in any way, shape or form. Furthermore, you assume all risks and liabilities arising from the construction or use of this circuit. This means that if you hurt yourself, your loved ones, or your RCX, don't come crying to me. That being said, I have not wrecked my RCX yet using this device... I have always wanted to control my pneumatic creations with my RCX. Small valves can be purchased, but they are very expensive. You need two of them to control both actions on a Technic cylinder, so the cost is going to get very high very fast. The servo idea was germinated a long time ago when I saw Linc Smith's micromotor controller. I realized then that a small, high-torque motor was needed to move the standard Technic pneumatic switch, and that some kind of feedback had to be employed. You can get small servos for about 20 bucks - a pretty good deal.
Unfortunately, the RCX only comes close to getting a servo waveform correct. A servo expects a positive pulse between 1.0 and 2.0 milliseconds long. The neutral position is a 1.5 msec pulse. The pulses are spaced about 30 msec apart.
If you have read the details found in Kekoa's Internals Page, you'll know that the fundamental frequency of the RCX is 1 khz - temptingly close to 1 msec. Those of you fortunate enough to have a scope might have observed the motor waveform at different settings. At power level 7, you'll see a stright DC level. When you set the power level to 6, you will see about 9 volts for 7 msec, and 0 volts for 1 msec. At power level 5, you get 9 volts for 6 msec, and 0 volts for 2 msec. Hmmm, these numbers are close to what the servo expects, except they are inverted!
The RCX output ports can deliver about 500 mA into a dead short and will enter a thermal shutdown mode before they wreck themselves. A typical servo takes about 200 to 300 ma when it is holding a load or moving to a target setting. Micro servos take even less current. All we need is a way to invert the signal and hold up the voltage during the low energy times and we're off to a good start for servo control!
Pretty simple, isn't it? The 4 diodes on the left give us a standard bridge rectifier so that it doesn't matter which "direction" the motor output is set to. Later on, I'll show how to expand your control options by removing components from this design. The RCXA-1 and RCXA-2 terminals are connected to the pair of wires from a standard LEGO electrical connector. I buy these in service packs and just cut them in half to interface with custom sensors or output devices.
The resistors and NPN transistor act as a simple inverter. This turns our 0 volt idle periods into the positive signal pulses we need to drive the servo signal input. The other two diodes across the top and the capacitor on the right form the "gas tank" for this circuit.
The cap holds enough charge to power the servo and the inverter for the brief period of time that the RCX output is low. The two diodes drop the voltage to the servo to a safe level if you're running off an adapter and prevent the capacitor from leaking back into the driver output. The exact value of the capacitor is not critical. Just make sure it's somewhere between 220 and 470 uF. The bigger the value, the more power your servo will have available during transitions.
In its current form, the interface works pretty well - even if you only have the standard Mindstorms firmware. As I hinted at in the description, the two power settings you'll find useful are 6 and 5 - they give the 1 and 2 msec pulse trains the servo wants.
The next release of pbForth will have support for precise control of the servo. This means you will be able to implement in-hold-out settings using the standard LEGO Technic pneumatic switches!
The pneumatic switches hold their last set position, so you really only need to use the servo to get the switch to whatever position it needs to be in. So here's the magic in getting more outputs by depopulating the driver board - make two drivers and only implement half of the rectifier circuit on each. The drivers will respond to one polarity or "directon" each. If you remove D2 and D3 from the driver, then you only respond to positive voltage on RCXA-1. Similarly, if you remove D2 and D3 from the driver, then you only respond to positive voltage on RCXA-2.
I'll be developing more code for pbForth that lets you control the precise position of the servo. I'll also be designing some control mechanisms using the servo principle. FInally, I'm considering doing a bulk purchase of servos and building these driver boards up using SMT components. With sub-micro servos, things shold fit into a 2x6 brick about 3 bricks high.
If you have any comments or suggeestions for me (or even corrections) please email me at the address at the bottom of the page.
| ©2000 Ralph Hempel | For more information contact info@hempeldesigngroup.com | Modified at 10/7/00; 5:32:50 PM |