Transcript Slide 1
Senior Project – Computer Engineering – Class of 2005
IR-to-RF Link for the Lego RCX
Eric P. Walklet
Advisor: Prof. John Spinelli
Abstract
The Lego RCX is a programmable digital device equipped with sensor inputs and motor outputs. As part of the
Lego Mindstorms package, it is intended for novice programmers and engineers as a teaching tool for illustrating
the fundamentals of programming. The RCX links to a user's computer using an infrared (IR) tower that connects to
a serial or USB port. IR technology requires that the user maintains a line of sight with the target - in this case, the
RCX brick - in order to keep communication active between the programming interface and the device that is being
programmed. The purpose of this project is to design a wireless link for the Lego RCX that does not require a line
of sight to operate properly. This is accomplished using a small wireless sensor network created with motes and
gateways manufactured by Crossbow, and a proprietary "programming language" usable through MATLAB.
resetMotors();
setMotorA(1);
while getSensorA() = 0
setMotorB(0);
end
setAllMotor(-1,1,0);
pause(0.5);
setMotorB(-1);
pause(0.5);
MATLAB
The user-interface for the IR-to-RF link takes the form of a class of MATLAB
functions that produce, in effect, a unique programming language for controlling the
motors and reading the sensors on the RCX. Each function changes an 8-bit
variable used to control the RCX’s three motor outputs. With each function call,
MATLAB sends an updated 8-bit message through a TCP/IP socket to a Crossbow
Ethernet Gateway, where it is passed on to the sensor network; and receives an 8-bit
message from the gateway concerning the status of the RCX’s sensors.
TinyOS & nesC
nesC is a highly-modular language used to program the motes in the sensor network, essentially turning
them into the “air traffic controllers” of the entire setup. One mote – connected to the Ethernet Gateway –
passes on messages that it receives from MATLAB and the RCX to their respective destinations. The
second – connected to the IR circuitry – encodes and decodes 8-bit messages to and from the RCX IR
protocol so that the two unlike devices may communicate.
From MATLAB to RCX
The IR Interface
For the IR detector on the
RCX to read any information,
the incoming IR signal must
be modulated at 38 kHz. A
pre-programmed
PIC
microcontroller
takes
the
output from the mote and
transforms it into a signal that
the RCX can detect.
Motor 1 Motor 2 Motor 3
Even
Parity
Odd
Parity
From RCX to MATLAB
Sensor 1 Sensor 2 Sensor 3
Odd
Parity
Even
Parity
One of the RCX’s greatest limitations is its
mere one-byte message buffer. Above, see
how one byte is used to store information
about three motors and three sensors with
four degrees of sensitivity.
LeJOS
LeJOS – Java for the RCX – replaces
the proprietary Lego firmware and
allows the programmer to use a familiar
and powerful programming language to
control their RCX-powered devices.
For this application, the LeJOS program
installed on the RCX has two purposes:
(a) accept a one-byte message from the
mote, and use the information
contained therein to operate the motors;
and (b) obtain the status of the RCX’s
three touch sensors, assemble the data
into a one-byte message, and send it
back to the mote.
During this
process, the program implements
an error-detection scheme using
leftover message bits.
Photo Credits: Microsoft Clip Art Collection, La robotique avec Lego (http://www.csdm.qc.ca/SJdelaLande/lesclasses/4web/wwwrobotique/robotique_lego.htm), http://www.tinyos.net, UCL (http://www.fsa.ucl.ac.be/candis_01-02/T3/math/cd-matlab), http://www.lejos.org