5chung LEGO MindStorms® Overview – Robot Command Explorer (RCX/Brick) Hitachi H8 16MHz 8-bit microcontroller with 32K ext. Ram 16K ROM contains power up driver 16K of firmware can be downloaded to extend the on- chip driver User programs are downloaded to the RCX as byte code in 6K region of memory Firmware executes and interprets the byte code of programs when instructed
6chung LEGO MindStorms® Overview – Robot Command Explorer (RCX/Brick) Infra-red (IR) ReceiverIs a sensor that accepts the program being transmitted from the IR tower. Also transmits data. Sensor Input PortsInput ports 1, 2, & 3 are used to attach sensors to the RCX (0V/0 – 5V/1024 A/D) View ButtonUsed to obtain feedback from the input and output ports On-Off ButtonManually turn the RCX on and off Motor (output) PortsUse output ports A-C to connect any combination of motors LCD DisplayDisplay different values and information regarding the RCX and programs AC/DC Power InputThe RCX can be powered by plugging into a 9 Volt adapter (not for recharging batteries) Program ButtonUsed to switch between programs 1-5 Run ButtonPress the Run button to activate and run your current program Speaker (not shown)Internal speaker indicates RCX status and acts as a programmable sound output
7chung What Is RoboLab? A Graphical programming language For the RCX based on LabVIEW In 1997, LabView was used for Sojourner project By designing a flow chart with given icons the programmer can program the RCX
8chung Writing a new program Click on the Programmer button. You should then see the Inventor login screen. Double click Inventor 4 to get full RoboLab environment. Introduction to RoboLab – Programming Environment
9chung ROBOLAB Environment Set up your screen in Inventor 4 so that it looks like the screen to the right.
10chung ROBOLAB Environment There are two major pallets that contain most of the icons and commands you need to build a program. If you cannot see these pallets, you can find them under the Window -> Show drop down list. Tools Functions
11chung RoboLab Workspace Functions Palette – Contains Icons for all possible RCX program commands. Icons vary with Level Tools Palette – Contains Icons for building a program diagram in the RoboLab workspace Context Help – When this window is open it displays Help information about the Function Icon under the mouse cursor Example Program – All programs begin with a Green light and end with a Red light Icon Search – Click the Search tab to find a Function Icon in the Functions palette Menus Sub Menu Icons – Icons with the right side black dot have sub menu Icons
12chung Tools Palette Operate Value tool: Change values in the Workspace window Wire Tool: connect icons in your program from start to finish Set/Clear Breakpoint: allows you to suspend the execution of your program Set Color Tool: allows you to set the colors of objects in the Panel and Diagram windows Scroll Window Tool: move around in the Title or Workspace windows Arrow Tool: move, delete, or place icons in workspace window Automatic Tool Selection: Automatically senses correct tool to use Get Color Tool: allows you to copy a color from an image and use it as part of the color palette Probe Data: allows you to check the program for values Object Popup Tool: modify settings for items in the Workspace window Edit Text Tool: edit or insert text boxes
13chung RoboLab Programming Elements Forks – equivalent to if/then selection structures Task – run multiple task simultaneously (8 max.) Wait states – program execution will be halted until the wait state condition is satisfied Loops – to create repetition structures in a program Subroutines – a segment of code that can be called repeatedly from another code segment (8 max./program slot) Events – jumps to the specific section of code when the specified event occurs
14chung RoboLab Capabilities I Read Analog input values Output PWM on the output ports Subroutines Multitasking Event monitoring Multimedia Image/sound processing and capture Access all RCX Brick input/output interfaces (buttons, LCD screen, etc.) Music and sound functions
15chung RoboLab Capabilities II Data logging (2000 pts. @ 100Hz) and processing functions using G-Code (can compute basic statistics to derivatives and integrals) Basic Logic and Math functions Variables (47 total, 22 user variables) IR Communication functions Direct program control functions Internet functions User defined libraries LASM functions (LEGO assembly language) Control lab interface functions
16chung Pros to Using RoboLab Easy to see control structure Visual interface is simple Exactly like LabVIEW Data gathering and visualization (investigator)
17chung Cons to Using RoboLab Spaghetti code Hard to wire icons… No edge triggering supported
18chung For More Information LEGOs Page www.lego.com/dacta/robolab National Instruments Page www.ni.com/robolab Tufts University www.ceeo.tufts.edu/graphics/robolab www.lego.com/education/mindstorms/i mages/eng/downloads/compare.doc
19chung What is a computer program? A list of instructions created by a computer programmer (you) that tell a computer what to do next Your job as a computer programmer is to: Decide how to get from point A to point B using a bag of tricks (instructions) For the LEGO Robot, instructions = Picture Icons connected together to form a program A (what I want the program to do) B (program doing what I want it to do) LEGO RoboLab Function Icon Palette
20chung An Introduction to Structured Programming (or How to get from point A to point B) Structured programming philosophy states that all programs can written using only three single entry/single exit control structures 1.Sequence structure: is built into RoboLab and means that statements are executed sequentially one after another as along the chain of connected icons 2.Selection structure: chooses between alternative courses of action (makes yes or no decisions) 3.Repetition structure: tells which actions are to be repeated while some condition is true Programs are built in structured programming by stacking and/or nesting as many control structure building blocks as needed to solve the problem
22chung Ex 1: Go forward 2 seconds and come back by reversing motors
23chung Making Turns Turn left: Spin left: (point turn) Face left: Left wheel Right wheel Left wheelRight wheel stop
24chung Ex 2: Go forward 1.5 seconds and come back by spinning left Spinning 180 degrees? Is it accurate?
25chung Tips How to insert icons? How delete icons? How to save programs? How to use the Icon search feature? Cover the tower and RCX when downloading, if more than one robot in a room! Use Meaningful file names Add Comments using A: edit text
29chung Attach a Light Sensor Facing down Gap: around 1 cm (What will be the problem if less than 1 cm to solve the Miner Rescue problem?) Port No. 1
30chung Ex 3. Go straight until the edge of the table is detected. Then stop the robot
31chung Stop when it sees the black line on the Miner Rescue field Measure and record the following values White shelf Black line Foil Outside Edge Start of the ramp from the miner field and the home base: why? The big gap! Suggested to lower the power level move down slowly
32chung The gap between the Light sensor and the floor!!! Both Reflected and Ambient light values are affected by the distance between the sensor and the floor! The light sensor value is in inverse proportion to the gap Light sensor Light sensor
33chung Stop when it sees the black line on the Miner Rescue field
34chung Ex 4. Stop when it sees the 2 nd black line on the Miner Rescue field What went wrong?
35chung How about stopping at the 4 th line? Loop (Repeat) Block
36chung Touch Sensor If released (not pressed): 0 If pressed: 1 Is it very sensitive?