The Lego RCX is an excellent development tool for almost any low performance applications. Combining a microprocessor with the quick mechanical design of Legos yields a system that can be constructed in a matter of minutes. Add to this an intuitive visual programming language, ROBOLAB, and you can design, build, program, and test a robotic system in a matter of hours without concern for compatibility. Unfortunately, this ease of use comes with a price. For instance, the Lego RCX has a usable clock speed (the rate at which it can perform tasks in the outside world) of only 100 Hz. Most commercial microprocessors are capable of at least 10 MHz. Additionally, the RCX limits its user to three outputs and three inputs. Standard microcontrollers are available with a myriad of input/output configurations. The Z-World BL-1500 that we used, for instance, has 24 digital input/output pins and 4 ADC input channels. Furthermore, the Lego motors and three PWM output ports of the RCX offer very little in terms of accurate and variable motor control.
The problem with moving from a Lego RCX and ROBOLAB system to a commercial microcontroller is that there is a huge difficulty gap between where a pure Lego system ends and a pure commercial microprocessor system begins. This is because the Lego users are protected from the headaches of industrial automation by both the simple visual programming of ROBOLAB and the convenient, all-in-one, package that is the RCX. In order to ease the transition between systems, we decided that the next step would be to maintain the use of ROBOLAB, but use it to drive a commercial microcontroller rather than the RCX.
We saw a few options for adapting ROBOLAB to program additional microprocessor. The first option was creating a new set of VIs (the ROBOLAB analog to functions in other languages) that would allow the user to program for a target other than the RCX. The main problem with this plan is that the user would have to make an entirely new program to use the new microcontroller. This removes the possibility of debugging the program with the RCX before migrating it to the high performance microprocessor.
Instead we decided to use the LASM (Lego Assembly) code that ROBOLAB generates to program the RCX. To do this, we created a C library that defines functions for each LASM command. We also created a new end VI for ROBOLAB. This VI takes the place of the 'stoplight' in a regular ROBOLAB code and converts the LASM commands that the user's program generated into C snytax. Once the LASM has been converted it is saved to a C-file with the same name as the ROBOLAB program and in the same directory as the ROBOLAB program.
In order to give the user as much control as possible, we also wanted to allow them to configure the outputs and inputs of the microcontroller through ROBOLAB. To do this, we developed a new project menu program for ROBOLAB. This program allows the user to assign a ROBOLAB port to each of Input/Output pins of the microcontroller and stores the data to a configuration file. Our 'stoplight' VI then adds this data to the beginning of the C-file.
With our system, a user can develop their program and test it with the RCX. Then move it to a higher performance microcontroller by changing only one VI in their program and configuring the microcontroller's output ports. All that remains is the compilation and running of a C-file. To get a better idea of the process we developed, please check out this simple example.
We are currently looking into a few improvements on this system. First of all, the we currently support only Inventor Levels 1-3 in ROBOLAB. Unfortunately, Inventor Level 4 applications, such as data logging and multitask execution, are where a user will most likely need the extra performance offered by a commercial microcontroller. Consequently, we are looking into expanding the C-library to include Inventor Level 4 functions. Additionally, or current system only supports one microcontroller, the Z-World BL-1500, and uses their proprietary programming language, Dynamic C, as the output language. It would be nice to add more microcontrollers to the list. Another feature we would like to add is the ability for ROBOLAB to compile and send code directly to the microcontroller rather than just outputting a code file to be compiled and uploaded by the user.
This ROBOLAB add-on only works with the Z-World BL-1500 and requires Dynamic C. We used Dynamic C version 5.26, but new versions should work as well. Broader support is in the works. In the meantime, follow these instructions to install Z-World version:
1) Download the .zip file below
2) Move the 'Robolab.lib' file to the "***\lib"folder where *** is the folder where Dynamic C is installed.
3) Use a text editor to open the "lib.dir" file that is in the folder where Dynamic C is installed.
4) Add "LIB\ROBOLAB.LIB" as a new line at the end of that file and save it.
5) Move the "MCend.vi" to the "***\engine\user.lib" folder where *** is the folder where ROBOLAB is installed.
6) Move the "MCend.llb" to the "***\engine\project" folder where *** is the folder where ROBOLAB is installed.
7) Develop your program in ROBOLAB using Inventor Level 4.
8) From the project menu select "Set MicroController Ports," configure the ROBOLAB ports to to the z-world pins you desire, and press 'done.'
9) Replace the regular 'stoplight' VI with the "MCend.vi" from the "My RCX Programs" folder on the Inventor 4 pallet.
10) Save your program and run it.
11) Open Dynamic C and open the C-file with the same name as your ROBOLAB program. It will be in the same folder as your ROBOLAB program.
12) Compile, upload, and run the C program.
If you have any questions or comments e-mail AJ at firstname.lastname@example.org