Embedded Motion Control/Lego Mindstorms Installation

From Control Systems Technology Group
Jump to navigation Jump to search

This document describes the installation of the necessary and sufficient software (approximately 400 MB) on Windows XP to start programming your own RCX from LEGO Mindstorms to control your Marslander. After reading this small manual, you should be able to run your own program on the RCX.

Installing Cygwin and the IR Tower

The RCX will be running on Linux and hence you need to compile all your code under Linux. Therefore, you can use a Linux emulator under Windows, called Cygwin. To install this emulator, carefully follow the following steps:

  1. Insert the marslander installation CD and wait for the installation window.
  2. Choose Install Cygwin, and the installation program will start.
  3. In the following window, choose install from local directory.
  4. Then choose the directory where Cygwin should be installed, the other options should be left at the recommended ones.
  5. Now the setup prompts for the local package directory, which is cygwin_install_files on the cd-drive.
  6. It is time to select the packages. It is preferred to install them all, so activate them all by clicking on All-default (the default-part) until it says All-install, and start the installation by clicking next.

When this is finished, Cygwin is installed but you still need a special compiler and operating system for the RCX. Therefore do the following:

  1. Click the button Directories to copy in the installation window of the CD. An explorer window will be opened with four directories, build, brickos-0.9.0, etc, and usr. Copy these to the directory you just installed Cygwin in (e.g., c:\Cygwin\). Choose yes when asked to replace.
  2. You are finished, so choose Exit in the installation window of the CD.

Now you need to install the driver for the infrared communication tower. To do this, plug the IR USB Tower in a free USB slot in your computer. Windows will automatically detect it, and prompts for a driver. Don’t let Windows update but choose to install your own driver which can be found in the directory IR_Tower_USB on the CD. Now everything is ready to set-up the RCX.

Putting a kernel into the RCX

In order for the RCX to be able to run your programs, it needs to be provided with dedicated firmware. The RCX is equipped with a ROM chip on which the standard Mindstorms firmware is stored. Every time the RCX loses power (e.g. when changing batteries), the firmware which was running on the RCX is replaced by this standard firmware. Therefore, every time the RCX has lost power, the dedicated firmware has to be installed again.

N.B.: If there is already a kernel running on the RCX (not the original one), then this one has to be deleted before a new one can be transferred to it. This can be done by pushing the Prgm button immediately after you push the On-Off button to swith the RCX off (this may take some practice).

To install the firmware for BrickOS, power on your RCX, open a cygwin shell (it opens in /brickos/marslander) and type

firmdl3 ../boot/brickOS.srec

Now the kernel is being transferred to the RCX and when this is finished, your RCX is ready to be programmed with your own programs.

Downloading your program to the RCX

The programming language used to control the RCX is C. Suppose you wrote a program in C to display "hello world" on the LCD of the RCX. This simple file helloworld.c can be found in the marslander directory /brickos-0.9.0/marslander. In order to compile this code we use the command make. This command uses the Makefile already present in the same directory. Therefore, all your C-code should be put into that directory. To compile type

make helloworld.lx

This will start the compilation process and delivers (amongst others) the file helloworld.lx. This is the actual program that will run on the RCX. To download it to the RCX, type

dll helloworld.lx -p1

where the option -pX is used to specify the program number on the RCX, here number 1 (there is room for 7 different programs, hence X is in the range 1 to 7). The program is now loaded on the RCX and by hitting the run button, the text hello world will be displayed on the screen. A second program which plays sound (sound.c) can be compiled and downloaded to the RCX by typing

make sound.lx

dll sound.lx -p3

You can now switch between these two programs (1 & 3) using the Prgm button on the RCX.