|
Servo motor RCX interface |
| Home/ Sensors/ Lego RCX servo interface |
Disclaimer
This page is not connected with or endorsed by The LEGO Company. LEGO, LEGOLAND,
LEGO SYSTEM, LEGO TECHNIC, DUPLO, LEGO PRIMO and LEGO MINDSTORMS are trademarks
of The LEGO Company.
I put this project in my web site only because I didn't find a practical reference for this device anywhere and I decided to make a guide.
This device is by Ralph Hempel, so if you are interested on details about it, follow the link.
I bought a servo for about 20 € (quite equal to 20$), that's about the price of a Lego geared minimotor: but with a servo you can control position of the shaft without external sensors.
Here's the internals of the device I built, making only made some modifies:
I removed a
voltage drop diode before the servo because it was weak (too low alimentation) ,
and for packaging reasons.
I replaced
the giant 220uF capacitor, with a much smaller 47uF, that's enough.
As Hempel
suggests, I polarized the driver to respond to positive polarity,
removing two diodes from the feeding bridge.
It was a challenge to fit all inside a 2x3 brick!


I'm not very capable on programmation, so, after trying learning PBForth - that allows complete control on Servos - and after sadly failing,
I returned to good old NQC, that I use through BricxCC:
with it, due to limitations of original Lego RCX firmware, I could control only the extreme positions, all right, all left.
It is enough to set motor power levels at 5 or 6 to obtain this positions ( also try 4 for an intermediate position): it's a pity it's not possible to reach the center with power level control.
So I came up to this code:
| int dir; void right (int time) { dir=1; SetPower (OUT_A,4); On(OUT_A); Wait(time); Off(OUT_A); } void left (int time) { dir=2; SetPower(OUT_A,6); On(OUT_A); Wait(time); Off(OUT_A); } void center () { if(dir==1){ //if on the right,turn left until center dir=0;SetPower(OUT_A,6);On(OUT_A);Wait(18);Off(OUT_A);} if(dir==2){ //if on the left,turn right until center dir=0;SetPower(OUT_A,5);On(OUT_A);Wait(13);Off(OUT_A);} } void center2 () { dir=0;SetPower(OUT_A,4);On(OUT_A);Wait(40);Off(OUT_A); } task main () { SetSensor (SENSOR_1, SENSOR_TOUCH); SetSensor (SENSOR_2, SENSOR_TOUCH); SetSensor (SENSOR_3, SENSOR_TOUCH); while (true) { if(SENSOR_1==1){ //go right and remind it dir=1;right(60);} if(SENSOR_2==1){center();} if(SENSOR_3==1){ //go left and remind it dir=2;left(50);} } } |
It is only a driving test, using 3 touch sensors to control left right and center, obtained simply with a timing procedure. It could be done better.