Aug 12, 2012

A new life for RCX 2.0

My LEGO Mindstorm had been unused for years now especially since I started using micro-controllers like BasicStamp and now Arduino. It had a short revival last winter when I used it to build a Star Wars R2-Unit crane for my twins. It was a real success and they played with it for two weeks straight.

Initially I was happy that my RCX was being used again but very puzzled that, after that playing stint, they had not included this new motorized brick into their regular LEGO play. Why? Maybe the cabling or specially the gears were a bit much for their age (7).

Lately my son made yet another awesome LEGO thingy and I told him he could make one part spin if he used the motors. He suddenly looked defeated and told me that “the pump thing is hard”. I finally knew why he was not using the RCX. He thought that the pneumatic system we used when making the crane, was the only way to make a working machine. Happy to enlighten him, I explained that he could use the motors alone and, at that very moment, I saw that his little brain was about to explode with ideas while he ran back to the LEGO boxes. His first creation was this 4 wheeled vehicle with one motor per wheel.

Then he dug up my old LEGO RCX 2.0 Mindstorm book that came with the kit, went through it one evening, found a line-following robot and built it the next day. I heard the perplexity in his voice when he called me saying “It's not working!”. The robot, going in circle, was missing the right code. I told him that building the physical robot was half the job and that it needed a program to tell him what to do. Of course now he wanted us to put the program in the robot.
I didn't want to disappoint him but the last time I pushed code on an RCX brick was in 2001 with a Windows XP computer. The software CD was probably lost in some storage box and, adding to the problem, loading a program must be done using a LEGO Infrared USB device (LEGO USB Tower) which are probably not supported anymore. Or so I thought.

I recovered my LEGO USB Tower and, ready for some major Internet archeology, Googled about LEGO RCX. I quickly found that Not Quite C (NQC) was still going strong. It was the programming language I used 10 years before. Not only that but I found that the LEGO USB Tower was now directly supported into Linux. So I plugged it in and BAM! /dev/usb/legousbtower0. Minutes later I uploaded a test program on the RCX brick and ran it. Victory is ours!

I coded a very simple program to show my son some basic logic in programing and now he's completely shocked by the fact that he can make a full robot, including the code.

I've created a monster and I like it.

More Geek info after the break

Given that the lego Tower is in /dev/usb/legousbtower0, start by making sure the device is accessible with a lazy hack:
$ sudo chmod 777 /dev/usb/legousbtower0
Here are two useful nqc commands to communicate with the RCX brick through the Lego Tower.
1) Uploading the firmware(if needed): nqc -Susb:/dev/usb/legousbtower0 -firmware firm0309.lgo
2) Uploading a nqc program: nqc -Susb:/dev/usb/legousbtower0 -d yourProgram.nqc