robotics: integrated systems design handy board robot kit tutorial slides modified from botball 2004...

58
Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics and CMU General Robotics Class Written by Jason Geist

Upload: margery-lee

Post on 25-Dec-2015

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

Robotics: Integrated Systems Design

Handy Board Robot Kit Tutorial

Slides modified from Botball 2004 Workshop©1993-2004 KISS Institute for Practical Robotics

and

CMU General Robotics ClassWritten by Jason Geist

Page 2: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

Handy Board Setup

Serial Cable

Interface Cable(4 wire phone cord)

Charger:12V - 500 mA

Interface Board(with charger) Handy Board (w/ expansion)

Power Supply: 9.6V NiCad Battery Pack

Page 3: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

Charging HB Batteries• Charging is best accomplished through the interface board

– There is also an on-HB charge port (a trickle charge)

• The interface board has 2 modes: Normal Mode, ZAP Mode• In Normal Mode, the yellow light on the interface board is lit

– A full charge takes about 12 hours, though you can use the board earlier.

• ZAP mode fully charges a turned off HB in 2 hours (the yellow light is NOT lit)– Warning: if ZAP mode is used for more than 2 hours (or fraction thereof for a charged

battery), it• may damage the batteries • will eventually destroy the HB (via heat from battery overcharging)

– NEVER use ZAP unattended. • ZAP is ONLY recommended while working with the HB while it is on, or if your battery is very

low.

You fry it, you buy it!

Page 4: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

Interactive C • IC4 is a C compiler/interpreter• Implements most of the ANSI C language• Runs on Handy Board and LEGO RCX• Loads firmware onto board• Provides an editor and documentation• Provides an interactive environment for testing and

debugging• Built-in IC Manual• Check www.kipr.org/ic for the most current version

Page 5: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

Download the Firmware

• Make sure your Handy Board is connected to your personal computer via 4-pin modular cable, serial interface box and serial port cable (and a USB to serial converter if needed)

• Select Change controller type from the Settings menu and select the Handy Board

• Select Download Firmware from the Settings menu• Select the appropriate serial port• Click on Download Firmware button• Follow the onscreen directions

Page 6: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

Handy Board (with expansion)

charge port(under exp board)

knob (under exp board)

floating analog ports (16-19)

IR receiveranalogports

(20-23)

analogports(2-6)

digitalports(7-15)power LED

(off in download mode)

lo-battLEDSTART & STOP

buttons

servo ports(wire order B|R|Y)

motor ports(3 pins each)

downloadconnector

offpower switch

on

0

1

2

3

012345

sonar (uses 2 ports)

red (# 0)gray (digital 7)

Page 7: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

• The knob, Start button, and Stop button are built-in sensors• Detachable sensors use a keyed connector (2 wire or 3 wire)

– Analog sensors: • Light (ports 2-6, 20-23)• IR reflectance (ports 2-6, 20-23)

– Floating analog sensors:• Optical rangefinder (ports 16-19)

– Digital sensors:• Touch (ports 7-15)• Slotted encoder (ports 7,8,12 & 13)

– Special sensors:• Ultrasonic rangefinder (sonar)

– gray-7, red-0 on expansion board

• Camera (CMU)– 3 pin connector in any open sensor port– Phone cable in HB serial port

Handy Board Sensors

Page 8: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

• Black gear motor with gray cable plugs directly into HB motor port - high torque and medium speed

• Motors with Lego connectors are connected to the HB using Lego-HB motor wires

• High speed, medium torque gear motors (gray Lego)

• Low speed, low torque gear motor (red Lego)

Handy Board DC Motors

Page 9: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

Handy Board Servos• Plug-in order is black, red,

yellow with black toward the expansion board edge (left)

• Servo plugs are pins sticking out of expansion board

• Servos in packages are standard position servos

• Servo with trim knob is a speed servo

Page 10: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

Handy Board Plugs

Keyed plug (digital and analog ports)

DC motor plug (motor ports) Servo motor plug (servo ports)

Page 11: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

Testing Your HB, Sensors & Motors

• Turn the Handy Board off and then back on to start the program (follow the onscreen instructions using the knob and start and stop buttons)

• Connect and test motors • Connect and test digital sensors• Connect and test analog sensors (be sure you have the right

type of sensors in the right ports)• Connect and test the sonar sensor• Connect and test servos (one at a time)• Connect and test the dongle and CMUcam (see next slide)

Page 12: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

CMUcam SetupThe dongle switch has three

positions:– Switch at red end: HB talks

to CMUcam– Switch at gray end: HB

talks through charge/interface board to PC

– Switch in middle: CMUcam talks through charge interface board to PC

– The HB continues to charge no matter what the switch position

To Dongle’s red end

To HB

To PC

CMUcam keyed connector (powers the camera) goes to any keyed port on the HB

Page 13: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

Charging the HB With the CMUcam Connected

• The CMUcam uses as much power as the HB• Together they use more power than is supplied by normal

charge• When the camera is connected and the HB is turned on, it

is useful to have the charger in ZAP mode. The charger may be left in ZAP for a few minutes, even if the HB is turned off.

• ALWAYS reset the charger to normal mode and turn off the HB when you leave the HB unattended!

Page 14: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

Interacting with IC

• Click on the Interaction tab• Just type into area at bottom of IC window• Simple expressions

9/5;

• Making noisebeep();

• Printing to the LCD screenprintf("I’m printing!!\n");

Page 15: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

#use Preprocessor Statement• #use is a preprocessor directive

– Preprocessor directives start in column 1 with the “#” symbol

• Purpose of #use – Program blocks may be saved in multiple files– Before IC can compile a user’s program, the IC preprocessor has to gather

together all of the program files – The #use directive is needed to tell the preprocessor where to find files when

multiple files are being used• Example

#use "globals.ic" #use "motorfns.ic" void main () { . . .

• WARNING!! Preprocessor directives are terminated by the end of the line, not a semi-colon. When putting in a comment on a preprocessor directive's line, be sure to either put it on its own line or use /* comment */ (not // comment )

Page 16: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

IC: Processes• IC functions can be run as processes operating in parallel (along with

main)– The computer processor is actually shared among the active

processes– main is always an active process– Each process, in turn, gets a slice of processing time (5ms)

• A process, once started, continues until it has received enough processing time to finish (or until it is “killed” by another process)

• Global variables are used for interprocess communications

Page 17: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

IC: Functions vs. Processes

• Functions are called sequentially• Processes can be run simultaneously

– start_process(function-call);• returns the process-id• processes halt when function exits or parent process exits

– processes can be halted by usingkill_process(process_id);

• hog_processor(); allows a process to take over the CPU for several seconds until it finishes or defers

• defer(); causes process to give up the rest of its time slice until next time

Page 18: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

IC: Process Example#use pause.icint done; /* global variable for interprocess communication */void main(){ pause(); done=0; start_process (ao_when_stop());

. . . more code (involving motor operation) . . .} void ao_when_stop(){ while (stop_button() == 0); /* wait for stop button */ done=1; /* signal other processes */ ao(); /* stop all motors */}

Page 19: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

Structure

• LEGO bricks are finicky:– They HATE duct tape.

– They HATE hot glue.

– They HATE super glue.

– They HATE epoxy.

• You should never need adhesives to build reliable LEGO structures

Page 20: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

Basic Mounting Frame

• Servos may have a piece of LEGO glued to each side

• However, in many cases you can use a LEGO frame like this to securely mount a servo or black gear motor without using any glue

Picture courtesy of Terry Grant

Page 21: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

The Servo fits snugly in frame

Picture courtesy of Terry Grant

Page 22: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

Mounting a 24T Gear

• You can use the accessories that come with the servos to securely mount a 24 tooth gear the servo or black gear motor

Picture courtesy of Terry Grant

Page 23: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

Mounting a 40T gear

• The 40 tooth gear can be screwed onto one of the servo horns for a reliable mount.

Picture courtesy of Terry Grant

Page 24: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

Gear motor with 24T gear in the Frame

Picture courtesy of Terry Grant

Page 25: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

Philosophy

• Have fun

• Be creative, unique

• Strive for cool solutions, that work!

• Aesthetics: it’s fun to make beautiful robots!

Page 26: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

Sensor Types

• Digital:– Return a 0 or a 1

– Switches or bumpers are an example

(open: 0, or closed: 1)

• Analog:– Sensor returns a continuum of values

– Processor digitizes results (8 bits give values of 0-255)

– e.g. light sensors

Page 27: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

• Analog sensor• Connect to ports 2-6 or 20-23• Access with function analog(port#)• Low values indicate bright light• High values indicate low light• Sensor is somewhat directional and can be made

more so using black paper or tape or an opaque straw or lego to shade extraneous light. Sensor can be attenuated by placing paper in front.

Light Sensors

Page 28: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

• Analog sensor• Connect to ports 2-6 or 20-23• Access with function analog(port#)• Low values indicate bright light, light

color, or close proximity• High values indicate low light, dark

color, or distance of several inches• Sensor has a reflectance range of about 3

inches

IR Reflectance Sensor “Top Hat”

Page 29: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

• Floating analog sensor• Connect to ports 16-19• Access with function analog(port#)• Low values indicate large distance• High values indicate distance approaching

~4 inches• Range is 4-30 inches. Result is

approximately 1/d2. Objects closer than 4 inches will appear to be far away.

Optical Rangefinder “ET”

Page 30: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

• Timed analog sensor• Another Position Sensing Device• Connect red to Expansion board

– (upper deck) port #0

• Connect gray to Digital #7• Access with function sonar()• Returned value is distance in mm to closest object in field of view• Range is approximately 30-2000mm• No return (because objects are too close or too far) gives value of

32767• Wait at least .03 seconds between sonar()calls

Ultrasonic Rangefinder (Sonar)

Page 31: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

Touch Sensors • Digital sensor• Connect to ports 7-15• Access with function digital(port#)

• Three types• 1 indicates switch is closed• 0 indicates switch is open• These make good bumpers and

can be used for limit switches on an actuator

Page 32: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

Slot Sensors • Digital (breakbeam) sensor• Connect to ports 7, 8, 12 or 13• Access with function

digital(port#)• 1 indicates slot is empty• 0 indicates slot is blocked• These can be used much like touch

sensors (if the object being touched fits in the slot)

• Special abilities when used as encoders

Page 33: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

• Two types of wheel encoders

• Note that there are two transitions per rotation (dark to light and light to dark)

Wheel Encoders

reflectance sensor

slot sensor

Page 34: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

Using Encoders • For a striped encoder wheel

– with the RCX use the Lego light sensor– with the Handy Board use the top hat reflectance sensor

• For a perforated encoder wheel, use the slot sensor (HB only) • Connect to ports 7, 8, 12, 13 (encoder# is 0, 1, 2, 3)• On the RCX ports 1, 2 or 3 (encoder# is 1, 2, 3)

enable_encoder(encoder#);– enable an encoder only once...unless you disable it between enablesdisable_encoder(encoder#);read_encoder(encoder#);– returns the number of transitionsreset_encoder(encoder#);– sets that encoder’s count back to 0

• On the RCX with a light sensorencoderblack(encoder#);encoderwhite(encoder#);– used to calibrate light and dark values of a striped encoder wheel

The HB slot sensor will fit across a Lego wedge belt wheel

Page 35: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

Simple Encoder Program

void main(){ int enc1, enc2; enable_encoder(1); // turn on the encoders; sensors // plugged into ports 8 & 12 on HB or // 1 & 2 on RCX enable_encoder(2); while(!stop_button()) { enc1=read_encoder(1); /* read each encoder */ enc2=read_encoder(2); /* and show values */ printf("Enc1=%d Enc2=%d\n",enc1, enc2); sleep(0.1); /* wait a bit and do it again */ }}

Page 36: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

Mounting a slot sensor encoder

Carefully align sensor with encoder wheel

Page 37: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

Built-in Sensors: Knob

• Knob: the knob is a potentiometer which is treated like an analog sensor– The access function knob() returns 0-255– Can be used for adjusting values during runtime

Page 38: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

Built-in Sensors: Start

• Start Button: – Access function start_button()returns 1 while

pressed, 0 otherwise– Holding down Start while powering the board will

bypass executing main. – When downloading a new program, it is always good

practice to hold down the start button and power up the Handy Board before pressing the download button on IC

Page 39: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

Built-in Sensors: Stop

• Stop Button: – Access function stop_button()returns 1

while pressed, 0 otherwise– Holding down Stop while powering the board

will put the board in download-firmware mode. This is necessary for loading the firmware.

Page 40: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

• High speed, medium torque gear motors (gray Lego)– Use Lego-Lego cables from motor hotspot to

RCX– Connected to the HB using Lego-HB motor

wires

• Low speed, low torque gear motor (red Lego)– Connected the same way as the gray Lego

motors

• Use Motor channels 0, 1, 2 & 3 on the HB and 1, 2 & 3 on the RCX

• Full Forward: fd(1);• Full Reverse: bk(1);• 2/3 Reverse: motor(1,-66);

– Note: the RCX only has only 7 distinct PWM power settings spread over the values from 0 to 100 (and for 0 to -100)

DC Motors

Page 41: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

• Medium speed, High torque motors resemble servos -- but they are not

• Motors with gray cables plug into the Handy Board

• Motors with a black cable are for the RCX or by using a Lego-HB motor wire can be connected to the Handy Board

More DC Motors

Page 42: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

Handy Board Position Servos• Plug-in order in the servo ports is black, red, yellow

with black toward the expansion board edge (left)– You can remember this by associating it with

alphabetic order (black, red, yellow)

• Enable Servos:init_expbd_servos(1);

(activates all 6 servo ports)• Disable Servos:

init_expbd_servos(0);(de-activates all 6 servo ports)

• Servos’ positions are set by the globals servo0,servo1,…,servo5(these are predefined global variables and correspond to the servo ports)

– Save power by limiting values to

the range [1000, 3900]• Note: Servos acting weird or not

working indicates the battery is low

Page 43: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

cmucamlib Routines

• To use any camera routines, be sure to put #use "cmucamlib.ic" at the top of your file

• Call init_camera(); to initialize camera before any other camera calls -- will beep and complain if HB cannot talk to camera (check the dongle switch)

• Use clamp_camera_yuv(); to automatically set camera for the current lighting conditions. Camera should be pointed at a white surface when this call is being made (it waits for start button to be pressed). It takes 15 seconds for this function to complete!

Page 44: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

cmucamlib Routines (cont.)

• Call track_blue(); & track_orange(); to check for color blobs that CMUcam can see. These functions return 0 if they find no color blob, or the confidence of the blob detected. A good confidence is 80 and up. A confidence of 4 or 5 is poor.

Page 45: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

cmucamlib Routines (cont.)

• The track_color information is stored in globals:track_size stores the approximate number of pixels matching

in the blobtrack_x stores the pixel x coordinate of the centroid of the

color blobtrack_y stores the pixel y coordinate of the color blob (note:

0,0 is the center; 40,80 is upper right and -40,-80 is lower left)track_area stores the size of the bounding rectangle of the

color blobtrack_confidence stores the confidence for seeing the blob

Page 46: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

cmucamlib Routines (cont.)

• For experts: use trackRaw(…); to specify a particular color for tracking. Returns 0 if no such blob is found, -1 is there is a communication error, or the confidence. Also check out setWin(…);

• More details and low level functions are given in the comments at the beginning of cmucamlib.ic and cmucam3.ic in your Handy Board lib folder

Page 47: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

Example: cmucamlib-demo.ic

/* demonstrate color blob sensing for poof balls and blue paper */#use "cmucamlib.ic"void main(){ init_camera(); // initialize the camera in YUV mode clamp_camera_yuv(); //clamp camera white balance in YUV mode while(!stop_button()) { // hold down Stop for a long time if (track_blue() > 4) { // you could make this 0 bigger // number, like 80 for example printf("blue found:%d\n", track_confidence); } else if (track_orange() > 4) { printf("orange found:%d\n", track_confidence); } else { beep(); printf("nothing...\n"); } } // end while() } // end main()

Page 48: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

cmucamlib Notes

• Don't forget the #use "cmucamlib.ic" • More details and low level functions are given in

the comments at the beginning of cmucamlib.ic and cmucam3.ic in your Handy Board lib folder

Page 49: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

Lego RCX

• Simple controller– Similar memory and processor to Handy Board

• Three sensor inputs• Three motor ports

– Communicates to your computer via the IR tower– RCX powered by 6 alkaline AA batteries– IR tower powered by 9v alkaline battery– Gray DB9 to DB9 cable connects tower to serial port– Mac Serial port users, use HB cable, the 25-9 pin

connector and then the gray DB9-DB9 cable

Page 50: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

RCX

Ports 1, 2, & 3 are the sensor ports

Ports A, B & C are the motor ports (referred to in code as A, B & C (1, 2, & 3 also work) e.g., fd(A); or fd(1); turns on the motor on port A)

View button: view_button()

or start_button() (displays sensors port values if program is NOT running)

Prgm button: prgm_button() or stop_button()

Power button

turns RCX On and Off

Run Button

runs the main function

Page 51: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

Lego RCX Setup

RCX Power Supply: 6 AA batteries

IR Transmitter Power Supply: 9V battery

Serial Cable

Page 52: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

Download the Firmware

• Make sure your RCX is on and facing the IR tower which is connected to your personal computer via serial port cable (and USB to serial adapter if needed). Note: RCX USB IR tower does not work with IC4

• Start IC4• Select the RCX controller• Select the appropriate serial port• Click on connect now • Click on Download Firmware button if needed• It is a good idea to put a box over the RCX and IR tower while

downloading to shield the transmission from stray infrared signals that may be present in the room

• It may even be advisable to put a piece of black tape over the IR end of the RCX after the download is done!

Page 53: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

RCX Sensors

• Touch sensor

• Light and reflectance sensor

• Connect to RCX with Lego to Lego wire

• Sensors plug into ports 1,2 or 3

Page 54: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

RCX Motors

• Black gear motors have built-in connector and are medium speed and high torque

• Red & Gray motors use detachable wire

• Gray motors are high speed and medium torque

• Red motor is light, low speed and low torque

• Motors plug into ports A,B or C

Page 55: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

Testing your RCX• Using Lego to Lego wires, attach your Lego touch sensors to ports

1 and 2• Attach your light sensor to port 3• Using Lego to Lego wires, attach motors to ports A, B and C • Click on IC’s OPEN button• Load the file RCX/rcxtest.ic located in the IC program folder• Turn on the RCX and orient it towards the IR tower• Click on IC’s DOWNLOAD button -- the program will now be

downloaded to the RCX• After download is complete press the RUN button on the RCX• Follow the scrolling instructions on the RCX and press the touch

sensors and block, unblock the light sensor -- these actions cause changes in the motor speeds

Page 56: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

Structure• Common pitfall when trying to increase

mechanical robustness

• The wrong way

Page 57: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

Structure

• The right way:

Page 58: Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics

Connector pegs

• Black pegs are tight-fitting for locking bricks together.

• Grey pegs turn smoothly in bricks for making a pivot