1 / 24

IR-to-RF Link for the Lego RCX

IR-to-RF Link for the Lego RCX. Eric P. Walklet Senior Project - Computer Engineering - 2005 Advisor: Prof. John Spinelli. Presentation Agenda. Introduction to the RCX Statement of the Problem Project Considerations Block Diagram Programming the RCX The IR Circuitry

daktari
Télécharger la présentation

IR-to-RF Link for the Lego RCX

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. IR-to-RF Linkfor the Lego RCX Eric P. Walklet Senior Project - Computer Engineering - 2005 Advisor: Prof. John Spinelli

  2. Presentation Agenda • Introduction to the RCX • Statement of the Problem • Project Considerations • Block Diagram • Programming the RCX • The IR Circuitry • Crossbow Motes and TinyOS • Communicating Between Unlike Devices • RFRCX – Controlling the RCX with MATLAB • Challenges and Conclusions IR-to-RF Link for the Lego RCX Slide 2

  3. Introducing the Lego RCX • Part of the Lego Mindstorms package for many years • Three motors and three sensors • Programmed using a proprietary language created by Lego • Interfaces with a host computer through a 935-nm IR link with a USB tower IR-to-RF Link for the Lego RCX Slide 3

  4. Purpose of the Project • To design an interface for the Lego RCX that does not require a line of sight to operate – such as an RF link • To design a new “programming language” in MATLAB that can allow novice programmers to control the RCX • Inspired by CSC-030 IR-to-RF Link for the Lego RCX Slide 4

  5. Project Requirements • Language must control all three motors and read all three sensors, at least • Language must be simple enough to understand for a student with little programming experience • Information must travel between MATLAB and the RCX via some type of RF link • RCX is limited by a one-byte message buffer and an archaic protocol IR-to-RF Link for the Lego RCX Slide 5

  6. Crossbow Motes • The building blocks of wireless sensor networks • Operate at RF frequency of 900 MHz • Capable of communication through RF or UART • Ethernet Gateway allows communication with other devices through TCP/IP • Programmed with nesC IR-to-RF Link for the Lego RCX Slide 6

  7. Block Diagram MIB600CA Ethernet Gateway MATLAB User’s PC TCP/IP Mote 900 MHz RF Mote 935 nm IR IR RX/TX Circuitry Lego RCX IR-to-RF Link for the Lego RCX Slide 7

  8. Making the Most of One Byte From MATLAB to the RCX – Motor Control Even Parity Odd Parity Motor 1 Motor 2 Motor 3 8 voltage settings, two directions; now limited to 3 settings in each direction + idle From RCX to MATLAB – Sensor Status Odd Parity Even Parity Sensor 1 Sensor 2 Sensor 3 100 scaled levels of sensitivity; now limited to 4 scaled levels of sensitivity IR-to-RF Link for the Lego RCX Slide 8

  9. Programming the RCX with LeJOS • LeJOS is a Java VM that replaces the standard RCX firmware • Small enough to fit in the 32 kB (!) of memory • Allows RCX programmers to use a language that they are already familiar with, though there are limitations • Support for the entire RCX feature set… and beyond IR-to-RF Link for the Lego RCX Slide 9

  10. What the RCX Accomplishes • Accepts a one-byte message from the IR receiver • Uses that message to control the three motors accordingly • Checks the status of the three sensors • Assembles the status of the three sensors into a one-byte message • Sends the message back through the IR transmitter IR-to-RF Link for the Lego RCX Slide 10

  11. while(true) // loop indefinitely { // reads in a message from the mote, and converts // it to binary inBin = integerToBinary(dis.readInt()); // if the parity checks properly, set the motors // accordingly if (evenParityCheck(inBin) && oddParityCheck(inBin)) { setMotors(inBin); } // assembles a message from the status of the // sensors, and adds parity outBin = convertBinary(setParity(getSensors())); // sends the sensor message dos.writeInt(outBin); dos.flush(); } if(motorNumber==1) { if((chArray[0] == 1) && (chArray[1] == 1)) { return 3; // motor is floating } else if((chArray[0] == 1) && (chArray[1] == 0)) { return 2; // motor is on, forward } else if((chArray[0] == 0) && (chArray[1] == 1)) { return 1; // motor is on, reverse } else return 0; // motor is off } else if(motorNumber==2) { if((chArray[2] == 1) && (chArray[3] == 1)) { return 3; // motor is floating } else if((chArray[2] == 1) && (chArray[3] == 0)) { return 2; // motor is on, forward } else if((chArray[2] == 0) && (chArray[3] == 1)) { return 1; // motor is on, reverse } else return 0; // motor is off } else if(motorNumber==3) { if((chArray[4] == 1) && (chArray[5] == 1)) { return 3; // motor is floating } I Can’t Believe It’s Not Java! IR-to-RF Link for the Lego RCX Slide 11

  12. Do You Speak Infrared? • Need an IR receiver and transmitter to communicate directly with the RCX • A Sharp GP1UW70QS remote control receiver collects sensor information from the RCX • A PIC12C508A microcontroller modulates the motor messages at 38 kHz so they can be detected by the RCX, and outputs them through an IR photodiode IR-to-RF Link for the Lego RCX Slide 12

  13. Circuit Diagram What the IR Detector Sees What the IR Diode Sends IR-to-RF Link for the Lego RCX Slide 13

  14. Mote #2 – The Great Interpreter • The RCX uses a unique protocol – eight bytes sent for a one-byte message • Crossbow motes use a variation of HDLC for both radio transmission and UART communication • The mote that connects to the IR circuit must change the message to a structure the RCX can understand • Sends translated message to RCX via UART, and sends decoded message to gateway via RF IR-to-RF Link for the Lego RCX Slide 14

  15. TinyOS and nesC • TinyOS is a native environment for small devices like the motes • nesC is a modular language based on C • Programs are formed by “wiring” interfaces and components to each other • VERY DIFFICULT AT FIRST • Each program requires a configuration and a module to operate IR-to-RF Link for the Lego RCX Slide 15

  16. configuration UARTRCXPacket { provides { interface StdControl as Control; interface BareSendMsg as Send; interface ReceiveMsg as Receive; } } implementation { components RCXPacket as Packet, UART; Control = Packet.Control; Send = Packet.Send; Receive = Packet.Receive; Packet.ByteControl -> UART; Packet.ByteComm -> UART; } /* Command to transfer an RCX-compatible packet */ command result_t sendRCXPacket(TOS_MsgPtr msg) { uint8_t* rcx_packet; result_t rval; // form RCX-compatible frame rcx_packet[0] = (uint8_t)(PACKET_HEADER); rcx_packet[1] = (uint8_t)(0xFF PACKET_HEADER); rcx_packet[2] = (uint8_t)(OPCODE_MESSAGE); rcx_packet[3] = (uint8_t)(0xFF - OPCODE_MESSAGE); rcx_packet[4] = (uint8_t)(msg); rcx_packet[5] = (uint8_t)(0xFF - rcx_packet[4]); rcx_packet[6] = (uint8_t)(OPCODE_RETTOSUB); rcx_packet[7] = (uint8_t)(0xFF - OPCODE_RETTOSUB); rval = call SendVarLenPacket.send(rcx_packet, PACKET_SIZE); return rval; } A Look at the Configuration To send one byte to the RCX… [0xFF] [~0xFF] [0xF7] [~0xF7] [message] [~message] [0x08] [~0x08] IR-to-RF Link for the Lego RCX Slide 16

  17. Mote #1: Not Quite as Glorious • Messages received from the RF network (i.e. Mote #2) are passed on to the Ethernet gateway, and further to the PC • Messages received from the Ethernet gateway are sent to the wireless network to be • Programming is the same as Mote #2, though lacks the RCX encoding IR-to-RF Link for the Lego RCX Slide 17

  18. MATLAB and the Motes • Crossbow includes Java tools for sending and receiving messages to and from the wireless network • Message Interface Generator (MIG) creates a message class unique to the programs installed on the motes • Connection is made to the Ethernet gateway through a TCP/IP socket IR-to-RF Link for the Lego RCX Slide 18

  19. RFRCX • Status of sensors and motors are stored to two global variables • A variety of functions are assembled into a program to describe the RCX’s behavior • Each function updates the global variables depending on user input or received messages • Always something to send! Always something to receive! IR-to-RF Link for the Lego RCX Slide 19

  20. function setMotorBackward(number) if number = 1 motorSettings(1) = 0; motorSettings(2) = 1; elseif number = 2 motorSettings(3) = 0; motorSettings(4) = 1; elseif number = 3 motorSettings(5) = 0; motorSettings(6) = 1; end setMotorParity; asInt = buildMessage; oMsg = net.tinyos.rfrcx.RCXMotorMsg(asInt); send(2,oMsg); % drive forward % when a wall is hit % back up, and move forward % again motorSettings = resetMotors; sensorSettings = resetSensors; setMotorForward(1); while getSensorValue(1) = 0 setMotorOff(2); end setAllMotors(-1,-1,0); continue(100); setMotorForward(2); continue(100); setMotorForward(1); RFRCX in Action IR-to-RF Link for the Lego RCX Slide 20

  21. Problems and Challenges • UART on the motes is prone to errors and failures • Poor battery life on the motes without power-saving features • nesC is not well documented • RCX hardware is proprietary • RFRCX is not as user friendly as it could be • Price IR-to-RF Link for the Lego RCX Slide 21

  22. The Future • Use multiple messages to have more control over the motors and other features • Control multiple motes through the same gateway to address price issue • Replace MATLAB with a true Java interface • Packaging • A direct-connect solution IR-to-RF Link for the Lego RCX Slide 22

  23. Acknowledgments • http://www.xbow.com • http://www.tinyos.net • Kekoa Proudfoot http://graphics.stanford.edu/~kekoa/rcx/ • http://www.csdm.qc.ca/SJdelaLande/lesclasses/4web/wwwrobotique/robotique_lego.htm • Prof. Spinelli • Crossbow (for their informative training seminar) • The rest of the CN/CS/EE department And a silent wave to all those in the room who were inspired to become engineers by the Legos they played with as a kid… including me. IR-to-RF Link for the Lego RCX Slide 23

  24. Questions?

More Related