Software Design Considerations COST ROBOT Abstract Design and
Software Design Considerations COST ROBOT
Abstract � Design and build a compact robot to traverse a maze � Use the robot to generate an ASCII representation of the entire maze � Mark light locations on map as they are discovered � Revisit lights intelligently throughout the maze in a user-defined order
Software Design Considerations � PIC 18 F 4550 Microcontroller Interfaces �General Purpose I/O �A/D sensors �PWM motor control �Communication with compass via I 2 C �Data transfer via USB � “Flag”-driven � Embedded C Design
General Purpose I/O � 5 registers for general purpose I/O � PORTx registers refer to pin � TRISx registers: � 0 – output � 1 – input � 3 X Single-colored LEDs � 1 X RGB LED (3 pins) � 2 X Pushbuttons � 4 X Motor direction control
A/D Sensors � 13 A/D Channels � Conversion process �Set channel to corresponding ANx pin �Set GO_DONE bit to 1 �Conversion complete when GO_DONE bit = 0 � 1 X RGB Color Sensor (3 pins) � 3 X Short-range sensor � 1 X Long-range sensor
PWM � PWM enable by setting bits 2 and 3 of the CCPx. CON register �CCP 1 �CCP 2 � Motor speed control � Alter duty cycle to change speed
I 2 C / USB � Communication between compass and microcontroller via I 2 C � Data transfer to computer with USB �Byte-by-byte transfer of data �Data structure decoded by PC
Flowchart for Main Loop
Power On / User Input
Power On / User Input
Maze Mapping
Maze Mapping
Maze Mapping typedef struct _maze. Node { /* bits 7 -5: 000 = normal node 001 = red 010 = green 011 = blue bits 4 -0: location from -10 to 10 */ char loc. X; // holds X location char loc. Y; // holds Y location // holds the path description /* bits 7 & 6: 00 = nothing 01 = entrance 10 = return 11 = unused bits 5 -0: index of the next node in maze. Node array */ char Npath; char Spath; char Epath; char Wpath; } maze. Node;
Tremaux’s Algorithm
Tremaux’s Algorithm [1] Tremaux’s Algorithm
Revisit Lights / USB Transfer
Revisit Lights / USB Transfer
Hierarchical Block Diagram of Code Organization
References � [1] David B Suits, “Playing With Mazes, ” Rochester, NY, 1994
- Slides: 19