Micromouse Design Specifications Prepared for: Dr. Dan Lewis Santa Clara University by: Jonathan Herbst Philip Livengood Kevin Wollenweber June 2, 1998 Abstract “Micromouse Design Specifications” by: Jonathan Herbst, Philip Livengood, and Kevin Wollenweber This project is designed with the intent of entering it in the 1998 IEEE Micromouse competition. This micromouse will need to be small, completely autonomous, and intelligent. For the competition, the micromouse is allowed two passes in the maze. The first pass is used to completely learn and map out the maze in an attempt to find the center, or goal of the maze. Then the second pass should find the shortest path to the center in the shortest time. With these goals in mind, we have designed a small, square shaped Micromouse. There will be eight infrared sensors, two on each corner of the mouse which are used for guidance. There are two wheels driven by stepper motors with the remainder of the weight balanced by two castor wheels. These wheels will be driven in a tank-like fashion using the infrared sensors to maintain its alignment. Our design also includes two power sources, one to drive the motors and one for the remainder of our components. The intelligence of the micromouse is based on its software. The goal of the first pass is to see as much of the maze as possible in order to create a map of the maze. In turn the second pass should take this map and determine the quickest path to the center. Abstract .......................................................................................................................... 2 Introduction .................................................................................................................... 4 Design Interaction........................................................................................................... 5 Design............................................................................................................................. 6 Motion.............................................................................................................................................. 6 Sensors............................................................................................................................................. 8 Power ............................................................................................................................................... 9 Control ............................................................................................................................................. 9 Software ......................................................................................................................................... 10 Conclusions................................................................................................................... 13 Appendix A: Micro Mouse Contest Rules...................................................................... 15 Appendix B: Software Flowchart.................................................................................. 18 Appendix C: Prototype Motor Driver Assembly Code................................................... 19 Appendix D: Micromouse Software .............................................................................. 20 Appendix E: Dijkstra’s Shortest Path Algorithm........................................................... 21 Introduction The Micromouse competition is a national competition that involves building an autonomous robot which can traverse a maze and intelligently calculate the fastest route to the goal of the maze then run to it. We have decided to build a Micromouse for our senior project so that it conforms to the official IEEE Micromouse contest rules (see Appendix A) with the intent of entering it in this competition after our design project is finished. Our goal is to have our mouse collect very accurate data about the maze so that even if it is not the fastest mouse, it has a good chance of finding the best route through the maze. To achieve this, we have decided to focus on the sensors and the software that controls them. This report will discuss the different design ideas we have come up with and what direction we are planning on going with our Micromouse. Design Interaction For our Micromouse, we decided to design our robot so that it meets the IEEE Micromouse Contest (see Appendix A) rules. To make the project easier to deal with we broke it down into five sections: motion, sensors, power, control, and software. The control section, consisting of the microprocessor and controlling hardware, receives information that is collected from the sensors section which acts as our data collection of the maze environment. Control is then responsible for sending information to the motion control section that drives motors and wheels. Power is simply responsible for powering the components and motors. The brains of our mouse will be the software that is run by the microcontroller. Software Motion Control Power FIGURE 1: DESIGN INTERACTION Sensors Design Motion During our design analysis, we were very concerned with the shape of our mouse and whether its shape would inhibit its movements through the maze. Our first concern was whether a square shaped mouse would catch itself on the corners of the maze, so our first designs focused on a circular or octagonal shaped mouse. Although these designs were never tested, we felt that they would not work for the types of sensors we wanted to use. If we had eight infrared (IR) sensors (one on each edge), there would be no corners to mount them on. In the case of the octagonal mouse, the IR sensors may cross each other and somehow get disrupted or trigger another sensor’s detector. This is the main reason we decided on a square Micromouse. We can place an IR detector/emitter pair on each corner (see Figure 2) of the mouse so that we have sensors at each edge. The main Castor Wheel Drive Wheels Sensor pair FIGURE 2: MICROMOUSE (TOP VIEW) drawback to the square mouse is that it will have a wider turning radius and may catch on corners, but we feel that if we focus on using the sensors to make sure we are turning 90° each time, we have eliminated much of this problem. In using the square design, we will have to make sure our mouse does not become too large or it may have problems turning tightly in corners. One major area of focus has been in the area of wheel structure. One way to make sure our mouse was turning 90° was to simply turn the wheelbase 90° and we would not have to troubleshoot our turns as much because we knew how much it was turning. A problem with this design was to turn the wheelbase without friction so that we could ensure the 90° turn. To solve this, we would have needed to attach a solenoid to the wheelbase and lift it into the mouse while the mouse was supported by its castor wheels. We would then turn the wheelbase and put it back down. This would have created a mouse that would almost guarantee a 90° turn. We were also concerned with the possibility that the mouse would somehow end up in a non-90 degree angle and we would not be able to correct it. With this design, small increments would be very difficult. So, we would have to try and use the wall to realign our robot. We were very worried that this type of trouble shooting was not very reliable. This is why we decided on a different type of locomotion. Our solution is a mouse driven by two stepper motors which will control the two main wheels. Stepper motors are the obvious choice for this project since they can be controlled to turn a certain distance with each clock pulse they are given. By counting the number of pulses, the mouse can be controlled to go a certain distance and its position in the maze can be calculated easily. With two wheels driven by stepper motors, and two castor wheels to help support it (see Figure 2), our mouse will move much like a tank. To go forward, we drive both wheels at the same rate. To turn, we simply step the wheels at the same rate, but in the opposite direction. We can also make adjustments to the mouse’s position by giving small pulses to the stepper motors. We felt that, although this technique is much more error prone than the first, it would be much simpler. In keeping our design simpler, we could use our extra resources to make sure our mouse is turning 90° and is centered in each hallway. Sensors The mouse will have eight IR emitter/detector pairs (see Figure 2) that will keep track of the presence of either walls or doors, and will be mounted on each corner of the square. To gather information about the structure of the maze, we will pulse the IR emitters. If this pulse is received in the detector, then the light has bounced off something and there is a wall in front of it. If there is no signal received, then there is a door in the direction of the sensor. In early tests, we have found that enough ambient light in the room can disrupt the reception of the IR signal, so we have decided to pulse the IR emitters at a certain frequency, then filter out that frequency on the receiver side to help solve this. This way, we can filter out the noise from the ambient light and send powerful pulses for a short duration to make receiving the signals easier. This data will then be sent to the microprocessor and software algorithms will decide which direction the mouse should move. Power For our power control, we will be using two different sources: one supply for the stepper motors and one supply for the remainder of the components. The reason we are using two different sources stems from the problem that the stepper motors draw a large amount of current when they start their motion. This current draw could cause our microprocessor to be reset, in turn halting and restarting the execution of our code. For both of our power supplies, we will use a simple array of batteries. Since all of our components require 5VDC, we are going to use an array of batteries producing more voltage than we need and then stepping this voltage down to 5VDC. This will allow our batteries to last longer. The stepper motor drivers require a maximum of 24V to run. We have tested them and have decided that using 16 rechargeable AA batteries will give us sufficient power to run the desired time. Control The Micromouse controller must take directions from software and control the mouse’s peripherals. It must control the motors and the sensors while executing the microcode that it fetches from program memory. We have designed our initial mouse controller using an 8051 microcontroller. The chip comes with some memory on board, both RAM and EMPROM, but it is not enough for this project. The code for the algorithms used and the data structures that store the maze data take up a lot of memory, so we are going to add 32K of external EPROM and 64K of external RAM so we are not limited in our program size. The 8051 has four input and output ports (two of which are used for memory), so we need to add a peripheral controller for a few extra output ports. We will use one port to strobe the IR LED’s, one to detect the IR signal, one to control the motors, and one to give ourselves some room to add features (debugging lights and switches) we need during additional testing (see Figure 3). A PORT A B PORT B C D PORT C DEBUG LED’s MOTOR DRIVERS DIP SWITCH PORT D ADC 8051 ADDRESS/DATA BUS STATIC RAM ROM FIGURE 3: HARDWARE BLOCK DIAGRAM Software The software (see Appendix D) is broken down into three sections to make it easier to build and test. The first section is the component control, which deals with control of the sensors and motors discussed earlier. This code is written in assembly language. Assembly language is much simpler and faster when interfacing with SENSORS hardware directly, and will save space in program memory for the more complex algorithms. The second section is the first pass algorithm which is implemented in C. Assembly language is much faster since it directly manipulates the hardware and can be optimized, but C is only slightly slower when it is compiled into assembly language and made programming the algorithms much easier to understand and debug. It may cost us time, but it is on the order of microseconds and will not effect the overall outcome of the race. The basic principle behind the first pass algorithm is to traverse the maze and create an undirected graph in memory that will be used later by the shortest pass algorithm. The third section will be the shortest path algorithm that will look for not only the shortest distance to the destination point of the maze, but also for the path that will take the shortest amount of time to reach the goal. Will have chosen to use Dijkstra's shortest path algorithm (Appendix E) These two are not necessarily the same path since it takes the mouse much longer to turn a corner and start again than to continue going straight. During the first pass, the mouse will follow these basic rules at each square: -Try to go right -If it can’t go right or already visited the square, go straight -If it can’t go straight or already visited the square, go left -If it can’t go left or already visited the square, turn around As the mouse moves through the maze, decisions must be made at each square. Following our basic rules listed above, if a turn must be made and we have not visited this door before, then this square is called a node and it must be added to our undirected graph. Also, if there are more doors at a particular square that we still need to visit, then we must store the coordinate of this square in a stack data structure in order to return to this location again. Each time the mouse finds a dead end and must turn around, then a coordinate is taken off the stack data structure and the shortest path algorithm is used to determine how the mouse is to move from its current location to the coordinate which was just popped off the stack. The graph that is created from the first pass algorithm, stores the coordinates of each node, the distance between connecting nodes in the maze, a count of the number of nodes in the graph, and the direction that the mouse is facing within the maze. The mouse continues to search the maze until it has visited every square in the maze and there are no more coordinates in the stack data structure mentioned above. Having done this, the first pass algorithm is complete. Figure 4 illustrates an example of the first pass algorithm and the data collected within the data structures listed above. In the figure, the dotted lines indicate the movement of the mouse, the circles indicate the locations of the nodes and the blackened circle indicates the current location of the mouse. Once the first pass algorithm has completed, the mouse will then be placed at the starting point of the maze and the shortest path algorithm will then determine the fastest route from the start to the destination square. This completes the micromouse simulation. Graph Data Structure Facing: North Node Count: 4 Nodes: (0,0) (0,1) (2,1) (2,2) Edges: (0,0) 0 1 0 0 (0,1) 1 0 2 0 (2,1) 0 2 0 1 (2,2) 0 0 1 0 FIGURE 4: SAMPLE MAZE AND GRAPH DATA STRUCTURES Conclusions This was a large design project and there were a lot of aspects of the project that we were not too familiar with, but we learned a lot. This project was perfect for a senior design project because it involved knowledge of electronics, computers, and mechanical design. So far the project is about 80% completed. We finished the structural design of the mouse and the software to control the mouse. Once the sensors are functional, we can begin assembling, testing, and debugging the system as a whole. We think that one of the main obstacles we had was obtaining donated parts. The microcontroller that we had donated by Philips Semiconductor was about 3 months late, which forced us to do our development with the 87752. This type of development was difficult since we could only test small portions of the mouse and not integrate parts together. Another obstacle we ran into was a blown stepper motor driver. Our motors and drivers were donated by Oriental Motors from discontinued stock. When one of the motors blew, there was no way to replace it. We are still in the process of resolving this problem. Although the project is not totally complete, we consider it a complete success for the time we had to finish it. We would, however, do a few things differently if we were to start over. One of the main things we would change about the way we went about this project would be the development board. We did not buy a development board because we decided to make one ourselves. We lost days of development time erasing and reprogramming the EPROM. Development boards can be purchased specifically to download test code into RAM, which is instantaneous and can be erased simply by resetting the system. Erasing the type of EPROM we used involved placing the chip under UV light for 20 minutes every time a different version of software is to be tested. Another recommendation would be to spend more time on the sensors. The idea of how the sensors are to work is fairly simple to grasp, but they can be difficult for anyone who has little experience with them. Experiment with different ways of pulsing the emitter so that you can send a powerful enough signal, at a certain frequency, that can be detected by the emitter. These were the major obstacles we faced that have to be resolved before this project can be completed. Appendix A: Micro Mouse Contest Rules (Adapted from IEEE/APEC Rules) I. Specifications for the maze 1. The maze shall comprise 16 x 16 multiples of an 18 cm x 18 cm unit square. The walls constituting the maze shall be 5 cm high and 1.2 cm thick. Passageways between the walls shall be 16.8 cm wide. The outside wall shall enclose the entire maze. 2. The sides of the maze shall be white, and the top of the walls shall be red. The floor of the maze shall be made of wood and finished with a non-gloss black paint. The coating on the top and sides of the walls shall be selected to reflect infrared light and the coating on the floor shall absorb it. 3. The start of the maze shall be located at one of the four corners. The starting square shall have walls on three sides. The starting square orientation shall be such that when the open wall is to the "north", outside maze walls are on the "west" and "south". At the center of the maze shall be a large opening which is composed of 4 unit squares. This central square shall be the destination. A red post, 20 cm high, and 2.5 cm on each side, may be placed at the center of the large destination square if requested by the handler. 4. Small square posts, each 1.2 cm x 1.2 cm x 5 cm high, at the four corners of each unit are called lattice points. The maze shall be constituted such that there is at least one wall touching each lattice point, except for the destination square. 5. The dimensions of the maze shall be accurate to within 5% or 2 cm, whichever is less. Assembly joints on the maze floor shall not involve steps greater than 0.5 mm. The change of slope at an assembly joint shall not be greater than 4. Gaps between the walls of adjacent squares shall not be greater than 1 mm. II. Specifications for the Micro Mouse 1. A Micro Mouse shall be self-contained. It shall not use an energy source employing a combustion process. 2. The length and width of a Micro Mouse shall be restricted to a square region of 25 cm x 25 cm. The dimensions of a Micro Mouse which changes its geometry during a run shall never be greater than 25 cm x 25 cm. The height of a Micro Mouse is unrestricted. 3. A Micro Mouse shall not leave anything behind while negotiating the maze. 4. A Micro Mouse shall not jump over, climb, scratch, damage, or destroy the walls of the maze. III. Rules for the Contest The basic function of a Micro Mouse is to travel from the start square to the destination square. This is called a run. The time it takes is called the run time. Traveling from the destination square back to the start square is not considered a run. The total time from the first activation of the Micro Mouse until the start of each run is also measured. This is called the maze time. If a mouse requires manual assistance at any time during the contest it is considered touched. By using these three parameters the scoring of the contest is designed to reward speed, efficiency of maze solving, and self-reliance of the Micro Mouse. 1. The scoring of a Micro Mouse shall be done by computing a handicapped time for each run. This shall be calculated by adding the time for each run to 30 of the maze time associated with that run and subtracting a 10 second bonus if the Micro Mouse has not been touched yet. For example assume a Micro Mouse, after being on the maze for 4 minutes without being touched, starts a run which takes 20 seconds; the run will have a handicapped time of: 20+4300-10=18seconds The run with the fastest handicapped time for each Micro Mouse shall be the official time of that Micro Mouse. 2. Each contesting Micro Mouse shall be subject to a time limit of 15 minutes on the maze. Within this time limit, the Micro Mouse may make as many runs as possible. 3. When the Micro Mouse reaches the maze center it may be manually lifted out and restarted or it may make its own way back to the start square. Manually lifting it out shall be considered touching the Micro Mouse and will cause it to loose the 10second bonus on all further runs. 4. The time for each run shall be measured from the moment the Micro Mouse leaves the start square until it enters the finish square. The total time on the maze shall be measured from the time the Micro Mouse is first activated. The mouse does not have to move when it is first activated but it must be positioned in the start square ready to run. 5. The time taken to negotiate the maze shall be measured either manually by the contest officials or by infrared sensors set at the start and destination. If infrared sensors are used, the start sensor shall be positioned at the boundary between the start square and the next unit square. The destination sensor shall be placed at the entrance to the destination square. The infrared beam of each sensor shall be horizontal and positioned approximately 1 cm above the floor. 6. The starting procedure of the Micro Mouse shall not offer a choice of strategies to the handler. 7. Once the maze configuration for the contest is disclosed, the operator shall not feed the Micro Mouse with any maze information. 8. The illumination, temperature, and humidity of the room in which the maze is located shall be those of an ambient environment. Requests to adjust the illumination may be accepted at the discretion of the contest officials. 9. If a Micro Mouse appears to be malfunctioning, the handlers may ask the judges for permission to abandon the run and restart the Micro Mouse at the beginning. A Micro Mouse shall not be re-started merely because it has taken a wrong turn. 10. If a Micro Mouse team elects to stop because of technical problems, the judges may, at their discretion, permit the team to run again later in the contest with a 3-minute maze time penalty. For example, assume a Micro Mouse is stopped after 4 minutes; it must be restarted as if it had already run for 7 minutes, and will have only 8 more minutes to run. 11. If any part of a Micro Mouse is replaced during its performance, such as batteries or EPROMS, or if any significant adjustment is made, the memory of the maze within the Micro Mouse shall be erased before restarting. Slight adjustments, such as to the sensors may be allowed at the discretion of the judges, but operation of speed or strategy controls is expressly forbidden without a memory erasure. 12. No part of the Micro Mouse (with the possible excretion of batteries) shall be transferred to another Micro Mouse. For example if one chassis is used with two alternative controllers, then they are the same Micro Mouse and must perform within a single 15-minute allocation. The memory must be cleared with the change of a controller. 13. The contest officials shall reserve the right to stop a run, or disqualify a Micro Mouse, if they believe its continued operation is endangering the condition of the maze. Appendix B: Software Flowchart First Pass Has square been visited Done no Is this the end Add to graph yes Right door? yes Visited no yes no Go right yes Forward door? Visited no yes Left door? no Go straight yes Visited no yes Return to last vertex and delete graph no Go left Appendix C: Prototype Motor Driver Assembly Code ORG 00H JMP START ORG 33H JMP START START: RIGHT_WHEEL: RIGHT_FWD: LEFT_WHEEL: LEFT_FWD: TURN_WHEELS: LOOP: END SETB MOV MOV MOV ANL JZ ORL JMP ORL MOV ANL JZ ORL JMP ORL MOV MOV MOV MOV JMP IE.7 ;ENABLE INTERRUPTS R0, #00H ;CLEAR R0 B, P3; ;CHECK DIP SWITCHES A,B A, #00000001B ;CHECK S0,RIGHT FORWARD RIGHT_FWD R0, #00010000B ;RIGHT WHEEL REVERSE (CW) LEFT_WHEEL R0, #00100000B ;RIGHT WHEEL FWD (CCW) A, B A, #00000010B ;CHECK S1, LEFT FORWARD LEFT_FWD R0, #10000000B ;LEFT WHEEL REVERSE (CCW) TURN_WHEELS R0, #01000000B ;LEFT WHEEL FORWARD (CW) PWCM, #01111111B ;SET PWM COMPARE TO 127 PWMP, #01111111B ;SET PWM PRESCALAR TO 127 P1, R0 ;OUTPUT WHEEL DIRECTIONS PWENA, #00000001B;BEGIN PULSING MOTORS LOOP ;LOOP UNTIL PWN DONE ;THEN CHECK MOTORS Appendix D: Micromouse Software See program code Appendix E: Dijkstra’s Shortest Path Algorithm See program code Bibliography 1) Flynn, Anita M, and Joseph L. Jones. Mobile Robots: Inspiration to Implementation. Wellesley, Mass: A K Peters, 1993. 2) McComb, Gordon. Robot Builders Bonanza: 99 Inexpensive Robotics Projects. San Francisco, CA: TAB Books, 1987. 3) Tanenbaum, Andrew. Computer Networks. Upper Saddle River, NJ: Prentice Hall PTR, 1996