6
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

7
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

8
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

9
9chung ROBOLAB Environment Set up your screen in Inventor 4 so that it looks like the screen to the right.

10
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

11
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

12
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

13
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

19
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

20
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

24
24chung Ex 2: Go forward 1.5 seconds and come back by spinning left Spinning 180 degrees? Is it accurate?

25
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

29
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

30
30chung Ex 3. Go straight until the edge of the table is detected. Then stop the robot

31
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

32
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