Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics."— Presentation transcript:

1 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

2 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

3 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!

4 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 versionwww.kipr.org/ic

5 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

6 Handy Board (with expansion) charge port (under exp board) knob (under exp board) floating analog ports (16-19) IR receiver analog ports (20-23) analog ports (2-6) digital ports (7-15) power LED (off in download mode) lo-batt LED START & STOP buttons servo ports (wire order B|R|Y) motor ports (3 pins each) download connector off power switch on 0 1 2 3 0 1 2 3 4 5 sonar (uses 2 ports) red (# 0) gray (digital 7)

7 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

8 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

9 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

10 Handy Board Plugs Keyed plug (digital and analog ports) DC motor plug (motor ports) Servo motor plug (servo ports)

11 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)

12 CMUcam Setup The 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

13 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!

14 Interacting with IC Click on the Interaction tab Just type into area at bottom of IC window Simple expressions 9/5; Making noise beep(); Printing to the LCD screen printf("I’m printing!!\n");

15 #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 )

16 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

17 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 using kill_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

18 IC: Process Example #use pause.ic int 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 */ }

19 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

20 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

21 The Servo fits snugly in frame Picture courtesy of Terry Grant

22 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

23 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

24 Gear motor with 24T gear in the Frame Picture courtesy of Terry Grant

25 Philosophy Have fun Be creative, unique Strive for cool solutions, that work! Aesthetics: it’s fun to make beautiful robots!

26 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

27 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

28 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”

29 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/d 2. Objects closer than 4 inches will appear to be far away. Optical Rangefinder “ET”

30 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)

31 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

32 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

33 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

34 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 enables disable_encoder( encoder# ); read_encoder( encoder# ); –returns the number of transitions reset_encoder( encoder# ); –sets that encoder’s count back to 0 On the RCX with a light sensor encoderblack( 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

35 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 */ }

36 Mounting a slot sensor encoder Carefully align sensor with encoder wheel

37 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

38 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

39 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.

40 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

41 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

42 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

43 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!

44 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.

45 cmucamlib Routines (cont.) The track_color information is stored in globals: track_size stores the approximate number of pixels matching in the blob track_x stores the pixel x coordinate of the centroid of the color blob track_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 blob track_confidence stores the confidence for seeing the blob

46 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

47 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()

48 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

49 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

50 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

51 Lego RCX Setup RCX Power Supply: 6 AA batteries IR Transmitter Power Supply: 9V battery Serial Cable

52 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!

53 RCX Sensors Touch sensor Light and reflectance sensor Connect to RCX with Lego to Lego wire Sensors plug into ports 1,2 or 3

54 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

55 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

56 Structure Common pitfall when trying to increase mechanical robustness The wrong way

57 Structure The right way:

58 Connector pegs Black pegs are tight-fitting for locking bricks together. Grey pegs turn smoothly in bricks for making a pivot


Download ppt "Robotics: Integrated Systems Design Handy Board Robot Kit Tutorial Slides modified from Botball 2004 Workshop ©1993-2004 KISS Institute for Practical Robotics."

Similar presentations


Ads by Google