Lego® RCX presentation - Clark Wood - BrickCon 2013

This presentation available at http://clark.cementhorizon.com

PRESENTATION GOAL:

Prepare Lego builders to use RCX bricks to display their otherwise non-robotic MOCs, probably unattended.
Yes, this is antique tech, but it is purist and robust (and simple and cheap).
The presentation and handout should tell you everything you need to know to replace your PF battery box or train control with an RCX brick.

MY INITIAL PROGRAM GOAL:

A well-documented program that displays several MOCs of engines at BrickCon, and highlights each one stationary, moving slowly, moving fast.
The motors should NOT be running non-stop for the 12 hours of the public exhibition, and the display should run unattended.

FURTHER:

Most of what I know I learned from (highly recommended): Definitive Guide to LEGO MINDSTORMS, Second Edition by Dave Baum (2002) available used through Amazon around $5.


http://bricxcc.sourceforge.net/nqc is the source for NQC and the FAQ and documentation. It covers a lot of these details more clearly.
http://www.mralligator.com/rcx covers disassembly and hardcore details of the RCX.
This is fun stuff and I'm happy to help. Contact me at clark.wood@gmail.com

NOT COVERED:

We won't be talking about NXT because I know nothing about it and there are thousands of First Lego League participants who would love to explain it to you.
We will also not talk about the Scout, a reduced-function RCX.

BRINGING AN OLD RCX BACK TO LIFE:

Unfortunately, this is probably your first task. You may have dug an old RCX out of a closet, or picked it up at a garage sale or flea market, or bought it from eBay or craigslist, etc.

Probably no one intended their expensive Mindstorms set to gather dust for 15 years when they put it away, and given the headache of "downloading firmware", and how hard they worked to get that first program to run, the thought of removing the batteries and letting their work evaporate encouraged them putting it away "for now" with the batteries still aboard.

So you open up your "new" Lego computer and the battery box is a mess. If you're lucky, the battery goopus didn't seep into the computer itself. But even if the corrosion is limited to the green box, you still have work to do.
If you're buying this from someone, you'd like to know in advance that your cleaning efforts will be worth it.


Attaching a 9-volt transistor battery to two alligator clips using a 9 volt snap connector power plug is a quick way to provide power to an RCX.



Turning the RCX over like turning a page in a book, the contacts that matter are the + (positive) at the lower right and the - (negative) at the upper left.
Providing power like this should allow you to turn the RCX on, hear the musical tone, and see the little man in the display.

If this DOESN'T work, you have a big disassembly job ahead of you, it may never work, and if you didn't buy it yet, you should pay accordingly.


If this quick test DOES work, cleaning out the battery compartment is your next job. Use an old (dry) toothbrush, toothpicks, and Q-tips. Polish the points on each connector that contact the AA batteries with a pencil eraser or strips of business card. You will know you're done when you can install 6@ AA batteries and read 9 volts between the lower right contact and the upper left contact with your meter. These are the same contacts you put your alligator clips on.
9 volts? You're good to go!


Now you need to download firmware...

Lego® RCX STEP BY STEP


* HOST OS & SOFTWARE ON PC *

There are two software environments we need to talk about: 32-bit Windows 95, 98, 2K, XP all support Lego graphics program RCX Code.
Version 1, at least, downgrades your display to 8-bit color, but you can reset this after you exit the program.

Dave Baum's NQC (Not Quite C) runs at the command line on any 32-bit version of Windows. I'm having great success with Windows XP.

NQC is command line software, but can (maybe) be frontended with bricxcc. (I was not able to get bricxcc to recognize my actual serial port on two XP computers.)


* THE RCX BRICK *


Three versions, all have the same internals, but only the original 1.0 has an external power input.
For the newer ones, should you create 9V DC adapter shaped like AA batteries? Solder wires to the tabs in the battery box? Or buy AAs in bulk?

Let's deal with the power confusion:

* PC to RCX INTERFACE; THE TOWER *


1.0 and 1.5 Mindstorms sets use a special cable and a db-9 serial connector on the tower. Great if your PC has a serial COM port!

If no serial port on your PC, a USB-serial adapter MAY work with Lego RCX Code program and with NQC.
(note that different USB-serial adapters use different chipsets, and driver availability and compatibility are not guaranteed.)

Verify that your USB interface is mapped to a low (COM1 - COM4) serial port number: On an XP computer:
Start - Control Panel - System - Hardware - Device Manager - Ports (COM & LPT) - Properties - Port Settings - Advanced - COM Port Number

Don't get confused. If you use a USB port on your PC and a USB-serial adapter, your computer and NQC think you're using a serial COM port.

RCX 2.0 includes the USB-attached tower (which requires at least Win98se). This actually looks like a *USB* port to your computer. Drivers for this USB tower can be downloaded from http://www.philohome.com/sdk25/sdk25.htm

With a serial terminal program like Hyper Terminal, 2400, odd, 8bit, 1stop, local echo off; should loop back through the IR in The Tower. Use the correct COM port! The green light on the tower helps tell if you're communicating.
NOTE: you can't communicate with the RCX this way.


* FIRMWARE ON THE RCX *

A new or un-batteried RCX needs firmware to be loaded.
Firmware 'goes away' if the RCX is left for too long with no batteries installed.
The RCX can be lobotomized instantly by removing even one battery and turning the RCX on.

RCX display showing ONLY the little man and number 1 - 5 needs firmware.


If the display ALSO shows a 4-digit number, it has some version of firmware already loaded.


Lego has released two firmware versions. (Newer firmware provides more functions, and NQC is written to make use of them.)

The simplest way to download firmware is at the command line using NQC.
RCX firmware 1.0
This came on the CD with the Mindstorms set versions 1.0 & 1.5
\FIRM\Firm0309.lgo  (45,112 bytes)  1998-06-30  03:37 AM
Downloading RCX firmware 1.0 to the RCX: (note: if -firmfast doesn't work for you, try -firmware instead)
E:\nqc-win-3-1-r6> nqc -SCOM1 -firmfast Firm0309.lgo
Downloading firmware:................................................................................
Current Version: 00030001/00030009
[note: this download of firmware 1.0 counted 1590 blocks and displayed 80 dots]
RCX firmware 2.0
This came on the CD of RCX version 2.0
AND
is also part of SDK 2.5 (the latest, from 2002!) which can be downloaded from: http://www.philohome.com/sdk25/sdk25.htm
If you don't want to INSTALL the entire SDK, open LEGOMindstormsSDK25.exe with 7zip or WinZip. The location of RCX 2.0 firmware in the file is
\\program files\LEGO\LEGO Mindstorms SDK\Bin\VPBrick1\RCX2\firm0328.lgo (68,644 bytes)  2002-09-27  08:37 AM
Downloading RCX firmware 2.0 to the RCX: (note: if -firmfast doesn't work for you, try -firmware instead)
E:\nqc-win-3-1-r6> nqc -SCOM1 -firmfast firm0328.lgo
Downloading firmware:.............................................................................................................................
Current Version: 00030001/00030208
[note: this download of firmware 2.0 counted 2494 blocks and displayed 126 dots]

* CABLES TO MOTORS *

There are two connector profiles. Older (black 2x2) is used by RCX, 9V trains, and Mindstorms motors.
Newer Power Functions uses the stone grey smiley face.

This adapter allows you to connect your LEGO 9V electric systems to Power Functions. From Lego Shop-at-Home, $2.99 http://shop.lego.com/en-US/LEGO-Power-Functions-Extension-Wire-8886

* MOTORS *


All 9V Mindstorms, train, and Power Functions motors and lights work fine (once you get past the connector issue).

* SENSORS *


Sensors are the key to Mindstorms' strength, but may not be relevant to this presentation. See Dave Baum's book.

* OPTIONAL REMOTE CONTROL *


The remote control REQUIRES that the RCX have firmware loaded in! Also requires that the RCX be turned on and not timed out (see TIPS).
May be useful to troubleshoot a completed installation; Is your problem in the programming or the cables?
Also lets you use your RCX like a PF battery box, with no programming at all. (As long as you loaded firmware!)

* TIPS *


* OVERVIEW OF THE PROGRAMMING PROCESS *

(this applies to Arduino and Stamp microcontrollers, too)
  1. create source code on PC or Mac: Graphical in Lego 'RCX Code' software, Windows only (source code created by 'RCX Code' is illegible without this software).
    or a graphic front end to NCQ using bricxcc, Windows only (source code will be readable ascii).
    or text-based ascii C-like source code file with the editor of your choice, to be used with NQC (Windows) or MacNQC.
  2. compile and download (object code) to RCX
  3. run your program (maybe use View function or use lights and motors to see what's happening)
  4. iterate

* First Demo Program: brickcon.nqc *

* Demo Program: dancer.nqc *

* Demo Program: motorspin.nqc *


* COMMANDS TO COPY AND PASTE INTO DOS WINDOW *

(assumes COM1 serial port, 2.0 firmware)
CD \nqc-win-3-1-r6

nqc -SCOM1 -firmfast firm0328.lgo
	if this fails, try: 
	nqc -SCOM1 -firmware firm0328.lgo

nqc -Trcx2 -SCOM1 -d -pgm 3 dancer.nqc

nqc -Trcx2 -SCOM1 -d -pgm 4 motorspin.nqc

nqc -Trcx2 -SCOM1 -d -pgm 5 brickcon.nqc


cewood 2013-09-29