Techincal Manual
Transcription
Techincal Manual
DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING Engineering Team Design Project Technical Manual Presented by Team Beemo (Team #3) COEN/ELEC 390/2 (Fall 2011) 12/7/2011 Table of Contents 1 2 3 4 5 Introduction ...................................................................................................... 3 1.1 Document Identification .............................................................................. 3 1.2 System Overview ....................................................................................... 3 1.3 Document Overview ................................................................................... 3 System Description .......................................................................................... 4 2.1 Introduction ................................................................................................ 4 2.2 Operational Scenario .................................................................................. 4 2.3 Hardware Requirements ............................................................................. 4 2.3.1 Functional Requirements ......................................................................... 4 2.3.2 Non-Functional Requirements ................................................................. 5 2.4 Software Requirements .............................................................................. 5 2.4.1 Functional Requirements ......................................................................... 6 2.4.2 Non-Functional Requirements ................................................................. 6 Hardware ......................................................................................................... 8 3.1 Block Diagram ............................................................................................ 9 3.2 Circuit Schematic of BeemoBot ................................................................. 11 3.3 Scope of the BeemoBot System Hardware ................................................ 12 3.3.1 Power Supply ......................................................................................... 12 3.3.2 Microcontroller ....................................................................................... 12 3.3.3 Motor Controller ..................................................................................... 14 3.3.4 GM8 Motor ............................................................................................. 15 3.3.5 Johnny Robot Track Kit .......................................................................... 15 3.3.6 Sharp GP2D12 Analog Proximity Sensors .............................................. 16 3.3.7 Sharp GP2D15 Digital Proximity Sensors ............................................... 16 3.3.8 QRD1114 Line Sensors .......................................................................... 16 3.3.9 Micro-Switches ....................................................................................... 18 3.3.10 Printed Circuit Board (PCB) ................................................................. 18 BeemoBot Assembly ....................................................................................... 20 4.1 Assembly Steps ........................................................................................ 20 4.2 Final Product of BeemoBot ........................................................................ 24 Software .......................................................................................................... 26 5.1 Pseudo-Code ............................................................................................ 26 5.2 BeemoBot’s Expected Behavior ................................................................ 28 5.2.1 Robot Detection ..................................................................................... 28 5.2.2 Robot Touch .......................................................................................... 29 5.2.3 Line Detection ........................................................................................ 30 5.3 Source Code ............................................................................................. 30 1|Technical Manual 6 7 8 Programming the Atmega8 .............................................................................. 31 Troubleshooting .............................................................................................. 33 References ...................................................................................................... 35 Table of Figures FIGURE 3.1 - BLOCK DIAGRAM OF THE BEEMOBOT ............................................................. 10 FIGURE 3.2 - SCHEMATIC OF THE BEEMOBOT ELECTRICAL HARDWARE ................................ 11 FIGURE 3.3 - REGULATED POWER SUPPLY CIRCUIT ........................................................... 12 FIGURE 3.4 - ATMEGA8 PINOUT ........................................................................................ 12 FIGURE 3.5 - ATMEGA8 RESET AND ISP PROGRAMMER CIRCUITRY ..................................... 13 FIGURE 3.6 - SN754410A PINOUT ................................................................................... 14 FIGURE 3.7 - MOTOR CONTROL CIRCUITRY ....................................................................... 14 FIGURE 3.8 - SOLARBOTICS GM8 MOTOR WITH BRACKET ................................................... 15 FIGURE 3.9 - JOHNNY ROBOT TAMIYA TRACK KIT ............................................................... 15 FIGURE 3.10 - GP2D12 AND GP2D15 SENSOR CASING .................................................... 16 FIGURE 3.11 - QRD1114 PACKAGE.................................................................................. 16 FIGURE 3.12 - QRD1114 PINOUT..................................................................................... 17 FIGURE 3.13 - QRD1114 PERF-BOARD CIRCUITRY ........................................................... 17 FIGURE 3.14 - MICRO-SWITCH PACKAGE........................................................................... 18 FIGURE 3.15 - BEEMOBOT PCB TOP-DOWN VIEW ............................................................. 19 FIGURE 4.1 - IMAGE SHOWING THE MOTOR MOUNTED ON THE CHASSIS ................................. 20 FIGURE 4.2 - IMAGE SHOWING HOW THE LINE SENSOR IS MOUNTED TO THE CHASSIS .............. 21 FIGURE 4.3 - IMAGE SHOWING HOW THE PCB IS MOUNTED TO THE CHASSIS ......................... 21 FIGURE 4.4 - FIGURE SHOWING HOW THE TRACKS ARE MOUNTED ......................................... 23 FIGURE 4.5 - FIGURE SHOWING ON/OFF BUTTON IS MOUNTED, TO THE RIGHT ....................... 24 FIGURE 4.6 - FINAL ROBOT ASSEMBLY .............................................................................. 24 FIGURE 4.7 - ARTIST'S RENDERING OF ROBOT ASSEMBLY .................................................... 25 FIGURE 5.1 - BEEMOBOT ANALOG (FRONT/REAR) ROBOT DETECTION ................................. 29 FIGURE 5.2 - BEEMOBOT DIGITAL (LEFT/RIGHT) ROBOT DETECTION ................................... 29 Table of Tables TABLE 2.1 - BEHAVIORAL EXPECTATIONS OF THE BEEMOBOT ................................................ 7 TABLE 3.1 - ELECTRICAL HARDWARE OF THE BEEMOBOT ..................................................... 9 TABLE 5.1 - TROUBLESHOOTING SCENARIOS ..................................................................... 33 2|Technical Manual 1 Introduction 1.1 Document Identification This document describes the design of the BeemoBot. This document has been prepared by Team Beemo for assessment in Concordia University’s COEN/ELEC 390 “Mini Capstone” project. 1.2 System Overview The Team Beemo BeemoBot is meant to locate opposing robots and push them outside of a circular area marked by a black ring on a white board. At the same time, the robot must remain inside the circular area at all times. The behavior of the robot is controlled by the use of 4 line sensors, 4 analog IR sensors, 2 digital IR sensors and 5 micro switches. 1.3 Document Overview The following document includes a system overview of the BeemoBot. It will describe the functional and nonfunctional requirements of the BeemoBot. It then describes in detail the design of the BeemoBot, starting with hardware and all its components, as well as how to assemble BeemoBot. This is followed by the overview of the BeemoBot software and algorithms, the source code of the BeemoBot and finally finished with instructions on how to program an Atmega8 microcontroller to use on BeemoBot. 3|Technical Manual 2 System Description This section of the document will provide a general overview of the basis for the BeemoBot system design. The modules will be divided into hardware (electrical and non-electrical) and software, as well as its development and implementation. 2.1 Introduction This BeemoBot system can be divided into several main components, called “modules” from here on. The first main division of its modules is hardware and software. The hardware module covers the electrical components of the system, such as the microcontroller, motors, motor controller, and so on. It also covers the non-electrical hardware module covers the parts of the system, such as the chassis, wheels, mounting brackets, and so on. The software module covers exclusively the code used in the system’s microcontroller, which determines the behavior of the robot. 2.2 Operational Scenario The BeemoBot’s intended use is to operate in a ring, marked with a black border on a white MDF board. The ring should be approximately 4” in diameter. The BeemoBot is intended to compete with an opposing robot in this ring, which is also designed to have the same general behavior as the BeemoBot. This behavior is to locate and target the opponent, and then attempt to push the opponent outside of the marked ring. Upon start of the match both robots must face towards the outside of the ring – back to back – approximately 6” away from the border. They must be activated simultaneously, stand still for at least 5 seconds, and then begin the match, The BeemoBot may also oppose more than one robot, in a “free-for-all” match. 2.3 Hardware Requirements This section describes in detail the requirements that must be met for the hardware module of the BeemoBot that are both electrical and non-electrical 2.3.1 Functional Requirements 2.3.1.1 Inputs The BeemoBot has several inputs required to operate well. It must respond well to both user inputs and opponent robot inputs as well. It must also take into account environmental inputs, such as the border of the ring and any obstacles that may appear inside the ring that is not the opponent. Firstly the BeemoBot must have a human input – the On/Off switch. This switch will be used by the operator to activate the BeemoBot once the match is ready to start. Next the BeemoBot must react to the opposing robot in the ring. The BeemoBot must be able to locate and track the opponent in the ring. The robot must also have a way to detect if the opponent is making contact, so it can make appropriate evasive or offensive maneuvers. 4|Technical Manual Lastly the BeemoBot must be able to stay within the operating environment, in this case the ring. It must also handle the placement of an undefined obstacle in the ring (e.g. sand, sticky tape, a low block, etc.). 2.3.1.2 Process The BeemoBot must have a system in place to process the information it receives while operating in the ring, such as seeing the opponent, detecting a line and so on. To do this the BeemoBot has need of an onboard “computer”. This computer must process the information coming in through the possible inputs that have been listed above. It must then determine the appropriate behavior required to deal with these inputs, and will react accordingly using various maneuvers. These maneuvers will be executed by the electrical outputs of the hardware. 2.3.1.3 Outputs The BeemoBot requires a method of performing the appropriate maneuvers and behaviors required to track the opponent robot and to push it out of the ring as required. 2.3.2 Non-Functional Requirements The BeemoBot needs to conform to a set of non-functional requirements. The robot must also follow a list of design constraints listen by the course instructor (from here on called the customer). 2.3.2.1 Performance The BeemoBot must run the full duration of the match without losing power. It may not lose any hardware pieces on the track during the match. 2.3.2.2 Design Constraints The customer has provided a list of available parts which may be used in the robot design. The permitted electrical hardware components are outlined in Appendix B. If any components not included on this list wish to be used, it must be proposed to and accepted by the customer. The robot must also conform to a list of design constraints, also provided by the customer. These general constraints are listed as follows: 1) No robot is allowed to INTENTIONALLY damage its opponent. 2) The use of materials and/or components other than the ones that are listed in the parts list is possible, but must be authorized PRIOR to use. *Note that this parts list is not yet available. 3) The materials used as “plow”, “shield”, “bumper”, “mounting bracket”, etc. must be as light as possible. No heavy gage steel, led, concrete, tungsten alloy etc. is allowed. 4) The chassis provided must not be altered in ANY way (i.e. no holes drilling or enlarging, no cutting, no bending, etc.). 5) All components must be mounted using either machine screws or tie-wraps. 6) No kind of glue is allowed. 7) The maximum robot size is limited by the chassis listed in the parts list. No part (excluding the wheels when the motors) may stick out for more than 10 mm before start and after finish (before any interaction with robot). If any of these constraints are not met, the robot may be disqualified from the competition. 2.4 Software Requirements This section covers the software requirements needed to be met by the BeemoBot. 5|Technical Manual 2.4.1 Functional Requirements 2.4.1.1 Inputs The BeemoBot receives inputs from the hardware, as listen above. These inputs are digitized using various methods (software ADC, hardware ADC, etc.) and then sent to the microcontroller to be processed. The software in the microcontroller must understand these inputs. Using the software ADC, we must “translate” these values to something that will make more sense – from voltage level to distance, for example. 2.4.1.2 Process The microcontroller of the BeemoBot must have software that processes the information received from the input, and uses it to determine the output. For example, if an input shows that an opponent has been seen to our side, the software must make the decision to turn into the appropriate direction. The turning maneuver is executed by sending the proper output. 2.4.1.3 Outputs The outputs sent from the microcontroller on the BeemoBot tell it which maneuvers it must make. The microcontroller sends this output to the motors, and the motors will turn in the appropriate direction. 2.4.2 Non-Functional Requirements 2.4.2.1 Performance The BeemoBot must poll its hardware at an appropriate frequency. It should be frequent enough such that the robot will not “lag” in response to changes in the environment. It must also be slow enough that the processor has enough time to “decode” the inputs, make the appropriate decision for maneuver and then send appropriate output. 2.4.2.2 Design Constraints The BeemoBot is under a list of software-based design constraints. The BeemoBot must conform to certain behavioral patterns. In Table 2.1, we may observe some of the behavioral expectations provided by the customer. 6|Technical Manual # Situation Time allowed, sec Robot scores #1 #2 Clear win and clear-like wins 1. 2. 3. #1 pushes #2 out of the ring. #1 stays in the ring for at least 10 seconds. #1 pushes #2 out of the ring. #1 stays in the ring for less than 10 seconds. #1 pushes #2 out of the ring. #1 leaves the ring during the push while being pulled by #2. Default wins #1 and #2 are in the ring. Both of them have moved from their initial positions 4. AND have detected the edge of the ring at least once. #1 is closer to the center. #2 leaves the ring without being forced to do so. #1 stays within the ring for at 5. least 10 seconds. #1 has detected the edge of the ring at least once. #1 and #2 are in the ring. #1 is moving; #2 has stopped. #1 has touched #2 and 6. has detected the edge at least once. #2 leaves the ring without being forced to do so. #1 stays within the ring for at 7. least 10 seconds. #1 has never detected the edge of the ring. 8. #1 and #2 are in the ring. #1 has moved from the initial position; #2 has not. #2 leaves the ring without being forced to do so. #1 leaves the ring in less 10 9. seconds after #2. 10. #1 and #2 have not moved from their initial (starting) positions. 180 180 5 4 0 0 180 4 2 180 3 2 180 2 0 20 2 0 180 1 0 20 1 0 180 0 0 20 0 0 Table 2.1 - Behavioral expectations of the BeemoBot 7|Technical Manual 3 Hardware The general behavior of this robot is that of a sumo bot. The primary function of this robot is to locate opposing robots and push them outside of a circular area marked by a black boundary line along the ground. At the same time, the robot must remain inside the circular area at all times. These goals are met by the implementation of different hardware components. These hardware components can be listed by category; Chassis Tracks Motors Printed circuit board (PCB) with IC’s and connectors Sensors Micro-switches 2 Battery packs Mounting brackets with nuts and bolts Connecting wires The chassis being used for the BeemoBot is a transparent square piece of 5mm thick Plexiglas measuring 106mm by 112mm. This Plexiglas has been cut to size to fit in the design constraints, and custom drilled to mount all necessary components. The robot operates on two Johnny Robot Standard GM tracks. These tracks are mounted on two Standard GM sprockets and two Idler sprockets. The GM sprockets are each connected to two GM8 Motor shafts. These are powered and controlled by the Quad-Half H-Bridge located on the PCB. The GM8 motors are mounted underneath the chassis using L-brackets with nuts and bolts, All the electrical hardware components of the robot are either mounted on, or connected to, a printed circuit board (PCB) which has been designed specifically for this project. The microcontroller and motor controller are both mounted on this board using dual-in-line-pin (DIP) connectors. Some of the capacitors and resistors needed for the system, as well as the voltage regulator, are also soldered onto the PCB. All other components are connected to the board using wires and tap-screw connectors. At each of the four corners of the robot a light sensor is placed underneath the robot chassis facing straight down, at a height of approximately 3mm off the floor. These light sensors are used to detect the black electrical tape used to delineate the end of the ring. On both the front and the rear we will find two analog IR sensors, placed equidistant from the center of the front of the robot facing straight forwards. They will be placed slightly inside the edge of the chassis. These four sensors will be used to find and track the opposing robot. On the center of the sides of the chassis, mounted underneath we will find a digital IR sensor. These sensors are used to detect if an opposing robot is approaching our robot from the side. We use these sensors to appropriately maneuver out of the “danger zone”. 8|Technical Manual There are 2 micro switches on both the front and rear of the robot located behind aluminum bumpers. These micro switches help determine whether the force applied by the opposing robot is on the left, right or center of the bumper. In the following table you will find all of the electrical hardware components required to build the BeemoBot. Component Label Part Number Part Description Qty C1 0.33uF Ceramic Capacitor 1 C2 0.1uF Ceramic Capacitor 1 D1 LED Green LED 1 IC1 Atmega8 8-Bit Microcontroller 1 IC2 SN754410 Quad Half H-Bridge 1 J1 LM7805 5V Voltage Regulator 1 J2 N/A Power Switch 1 J3 N/A 12xAA NiMH Battery Pack 1 IR Proximity Sensor (10-80cm) 4 Microswitch 4 J4, J5, J6, J7 GP2D12 J8-J11 N/A J13, J14, J15, J17 QRD1114 Reflective Object Sensor 4 J16, J18 GP2D15 IR Proximity Sensor (24cm) 2 J19, J20 GM8 Servo DC Motor 2 R1-R4 20kΩ Metal-Film Resistor 4 R5 220Ω Metal-Film Resistor 1 R6-R9 10kΩ Metal-Film Resistor 4 R10, R11 12kΩ Metal-Film Resistor 2 R12-R15 160Ω Metal-Film Resistor 4 Table 3.1 - Electrical Hardware of the BeemoBot 3.1 Block Diagram The following Figure shows the general implementation of the hardware components with each other in the form of a block diagram. 9|Technical Manual Figure 3.1 - Block Diagram of the BeemoBot 10 | T e c h n i c a l M a n u a l 3.2 Circuit Schematic of BeemoBot The following figure shows the full schematic of the BeemoBot electrical hardware. The labeled parts correspond to those in Table 2.1. Figure 3.2 - Schematic of the BeemoBot Electrical Hardware 11 | T e c h n i c a l M a n u a l 3.3 Scope of the BeemoBot System Hardware In the following section you will find detailed information of each hardware component, both electrical and non-electrical, which together create the BeemoBot. 3.3.1 Power Supply The BeemoBot is supplied by twelve AA NiMH rechargeable batteries. At 1.2V per battery, this totals 14.4V of supply voltage to the robot. Most components of the BeemoBot need a 5V source voltage, thus a voltage regulator is required. The BeemoBot uses the LM7805, a voltage regulator which allows an input voltage of 7 to 35V, with a constant output of approximately 5V. A small power supply circuit is needed for the BeemoBot, consisting of the battery, two coupling capacitors, a power switch and a common ground. The power supply circuit may be seen in Figure 4.3 Figure 3.3 - Regulated Power Supply Circuit 3.3.2 Microcontroller The BeemoBot’s “computer” is actually an Atmel Atmega8 8-bit microcontroller. This microcontroller provides 3 input/output (I/O) ports, PA, PB and PC. Each port has 8 pins (labeled 0-7). This totals to 24 available I/O pins. Of these pins we have 6 analog to digital converters (ADC) available and two hardware interrupt pins. The BeemoBot only uses software interrupts, as such the hardware interrupt pins are used only as regular I/O pins. The BeemoBot does, however, use 4 ADC pins for the IR proximity sensors. Figure 3.4 - Atmega8 Pinout 12 | T e c h n i c a l M a n u a l 1 The Atmega8 is powered using the 5V regulated voltage VC from the power supply circuit, shown in Figure 3.3. This voltage is applied to pins 7 and 20 (VCC and Vref). The common ground is connected to pins 8 and 22 (both labeled GND). On pin 21, Aref, we connect a coupling capacitor of 0.1μF to ground. This is for the functionality of the ADC. Pin 1 is reserved for a reset circuit, as shown in Figure 3.5. This circuit, however, is optional, and is not included in the final BeemoBot, as its main purpose is for testing. If the reset circuitry is connected, pressing the reset pin will result in the robot’s software algorithm resetting to the beginning. To program the Atmega8 microcontroller the user must connect a small programming circuit on a separate breadboard. It is required that pins 1, 16, 17 and 18 are connected to an ISP connector. This ISP connector is then plugged into the parallel port your computer to allow for programming. More instructions on programming the microcontroller can be found in Section 6 of this document. The microcontroller is placed on the PCB in its proper connecter. This can be seen in Section 3.3.10 of this document. Figure 3.5 - Atmega8 Reset and ISP Programmer Circuitry 13 | T e c h n i c a l M a n u a l 3.3.3 Motor Controller Figure 3.6 - SN754410A Pinout 2 The quad half H-bridge motor controller is the “messenger” between the microcontroller and the motors. Its function is to take the motor control signals outputted from the microcontroller and use them to make the motors go forwards, reverse, or stop. The motor controller logic is powered by 5V, and is applied to VCC1. VCC2 is powered by the battery voltage (14.4V). This 14.4V source is used to power the motors through pins 1Y, 2Y 3Y and 4Y. 1,2EN and 3,4EN are always connected to the 5V source. Pins 1A, 2A, 3A and 4A are connected to the appropriate motor control pins on the microcontroller. The input to these pins determines the direction of the motors. For the BeemoBot, pins 1A and 2A control the left motor, 3A and 4A control the right motor. The motor controller is placed on the PCB in its proper connecter. This can be seen in Section 3.3.10 of this document. Below is an image showing how the motor controller is connected to the motors, the microcontroller and to the power sources. Figure 3.7 - Motor Control Circuitry 14 | T e c h n i c a l M a n u a l 3.3.4 GM8 Motor Figure 3.8 - Solarbotics GM8 Motor with Bracket 3 The motors are used to move the BeemoBot forwards and backwards, as well as make it turn. The ones used on BeemoBot are two Solarbotics GM8 motors. By applying a voltage to one lead and a grounding the other, the motor will turn. If this voltage is reversed, the motor will turn in the opposite direction. These directions are determined by the motor controller described in the previous section. The motors are held in place using GM8 mounting brackets, also provided by Solarbotics. Additional hardware, such as nuts and bolts, is required to mount the motor to the chassis. 3.3.5 Johnny Robot Track Kit The actual “wheels” being used on the BeemoBot are not actually wheels, but a set of tracks, specifically the Johnny Robot Tamiya Track Kit. This kit includes 40 plastic tracks with pins, where 20 track bits are used for each track. Also included are two GM standard sprockets, and two GM idler sprockets. The GM sprockets are mounted to the GM8 motors, and the idler sprockets are mounted to the chassis using an Lbracket and shoulder bolts. Figure 3.9 - Johnny Robot Tamiya Track Kit 4 15 | T e c h n i c a l M a n u a l 3.3.6 Sharp GP2D12 Analog Proximity Sensors Figure 3.10 - GP2D12 and GP2D15 Sensor Casing 5 For BeemoBot to see and track its opponent, it needs long-range proximity sensors. These sensors are used to know where, and how far, the opponent is. The BeemoBot uses four GP2D12 analog proximity sensors (two on the front, two on the rear) to spot and follow its opponent. The GP2D12 is connected to VCC, GND and also has an output VO. This output has a varying voltage, from X to X, depending on the distance of the object being seen. This output is connected to one of the 4 allotted ADC pins on the microcontroller. 3.3.7 Sharp GP2D15 Digital Proximity Sensors For BeemoBot to know when it is being approached from the side we use digital proximity sensors. The GP2D15 is a digital proximity sensor which outputs logic LO when no object is seen within a 24cm range, and logic HI when an object is seen within a 24cm range. The GP2D15 has the same casing as the GP2D12, as well as the same pin-out. However the GP2D15 requires an additional resistor in the circuitry, from the VCC pin to the 5V source. This additional resistor is soldered on to the PCB, as is shown in Section 3.3.10 of this document. 3.3.8 QRD1114 Line Sensors Figure 3.11 - QRD1114 Package 16 | T e c h n i c a l M a n u a l 6 Figure 3.12 - QRD1114 Pinout 7 The BeemoBot may not exit the ring at any time. The ring is delineated using black electrical tape on a white MDF board. For BeemoBot to see when it has approached a line, it needs line sensors. For BeemoBot we chose the QRD1114 analog line sensors. These sensors will output a different voltage level depending on the reflectivity of the surface it is pointing at. For the BeemoBot, we use these analog line sensors as digital sensors. To accomplish this, we must add some additional circuitry to the QRD1114. This additional circuitry can be seen in Figure 3.13 We add two resistors, R1 and R2. R2 is connected to pin 3 (cathode) of the QRD1114 is used to control the brightness of the infrared diode in the QRD1114. R2 is used to digitize the signal. It is connected to pin 1 (the emitter) of the sensor, and to VCC. Pin 1 is also connected to the microcontroller. Using this set-up we will get a logic HI whenever the sensors sees the black line. When the sensor sees the white surface, it will output logic LO. The circuitry shown in Figure 3.13 is soldered to perf-board. This perf-board will have three wires connected to it – VCC (to the resistors), GND (connected to pins 2 and 4) and VO, connected to pin 1. A small hole should also be drilled in the perf-board for mounting, which is discussed later in Section 4 of this document. Figure 3.13 - QRD1114 Perf-Board Circuitry 17 | T e c h n i c a l M a n u a l 3.3.9 Micro-Switches 8 Figure 3.14 - Micro-Switch Package The BeemoBot requires knowing when an opponent is making contact. On the sides we have the digital proximity sensors, which allow us to know when we are being approached from the side and need to turn. For the front and rear, however, we need a different method of knowing when contact is being made. As the GP2D12 analog sensors have a small dead zone when objects are very close, we use micro-switches paired with bumpers. These allow us to know when, and at what angle, we have made contact. The micro-switches have 3 pins, which allow use to use it as either normally-open (NO) or normally closed (NC). BeemoBot uses NO micro-switches, with an active LO signal. This means that when we are not making contact, the switches will output logic HI to the microcontroller. When contact is made we will output logic LO. A pull-up resistor is required for use with the micros-witches. These resistors are soldered onto the PCB, as shown in Section 3.3.10 of this document. 3.3.10 Printed Circuit Board (PCB) BeemoBot assembly requires a “hub” of sorts, with which all the components may be connected to each other, as well as to the power supply. BeemoBot has a custom designed printed circuit board (PCB) with which to do this. On the PCB you will find the following components: LM7805 Voltage Regulator Coupling capacitors Resistors DIP connectors for Atmega8 and H-Bridge Top-screw connectors By properly soldering on the necessary components, inserting the Atmega8 and H-Bridge, and connecting the leads from each component to its respective connecter, we will have assembled all the electrical hardware components needed to build BeemoBot. The PCB design may be seen in Figure 3.15. The PCB is not the only way to connect the components. A breadboard of appropriate size may also be used. This is, however, not as stable as the PCB. On the PCB all components are fastened firmly, and will not loosen during operation. This is not true for a breadboard, where wires may pop out of their slots. 18 | T e c h n i c a l M a n u a l Figure 3.15 - BeemoBot PCB Top-Down View To create the PCB you may either send the design to a PCB manufacturer and have it made for you, or obtain access to a PCB etching station. When etching, ensure that you have proper instruction and follow the safety rules. Note that the above figure shows the top-down view of the PCB. When printing this board, the image is reversed and printed to the BOTTOM of the board. All components soldered to the board are placed through the TOP of the board, and then the pins soldered onto the pads, located on the bottom of the board. 19 | T e c h n i c a l M a n u a l 4 BeemoBot Assembly 4.1 Assembly Steps NOTE: Unless otherwise specified, all bolts being used in the assembly process are 1/8’ machine screws that are threaded from the head to the very end. Washers and hex nuts are used to fasten components tightly together. Step 1: Attaching the GM8 Motors and Idler L-bracket a) b) c) d) Attach left motor to the front left of the bottom of the chassis. Attach right motor to the front right of the bottom of the chassis Attach left L-bracket to the rear left of the bottom of the chassis Attach right L-bracket to the front right of the bottom of the chassis Insert bolt from bottom to top in each bracket hole and through the appropriate holes in the chassis, with the washer already on the bolt. Place the nut on the bolt and screw clockwise until very tight. Figure 4.1 - Image showing the motor mounted on the chassis Step 2: Attaching QRD1114 line sensors a) b) c) d) Attach front-left line sensor Attach front-right line sensor Attach rear-left line sensor Attach read-right line sensors Insert bolt from the top down through the appropriate pre drilled hole for line-sensor mounting. Place nut on the bolt and screw tight. Place another hex nut on the bolt and twist until the desired height. Place the QRD1114 perf-board circuit on the bolt through the pre-drilled hole. Place a third hex nut on the bolt and screw until tight. Repeat for all line sensors. 20 | T e c h n i c a l M a n u a l Figure 4.2 - Image showing how the line sensor is mounted to the chassis Step 3: Attaching the PCB Insert a bolt from top-to-bottom in each of the 3 PCB mounting holes, located on the PCB. Attach a nut to each bolt and turn them all tightly. Attach another nut to each bolt, approximately 60mm from the first nut. Line up the bolts with the PCB mounting holes located on the chassis. Insert all bolts through. Place a nut on each of the bolts and turn until tight. Figure 4.3 - Image showing how the PCB is mounted to the chassis Step 4: Attaching proximity sensor brackets and sensors a) b) c) d) e) Attach main left bracket Attach main right bracket Attach 4 mini L-brackets Attach front cross bracket Attach rear cross bracket 21 | T e c h n i c a l M a n u a l f) Attach left GP2D15 L-bracket g) Attach right GP2D16 L-bracket Place the main brackets on the chassis such that the mounting holes line up with the bolts used to mount the motors and L-brackets. Place nuts on each bolt and fasten tightly. Mount the 4 mini L-brackets underneath the top part of each main bracket, as shown, using bolts and nuts. Next attach the front and rear cross brackets. Lastly attach the two GP2D15 L brackets as shown. Mount two GP2D12s on the front cross-bracket, ensuring they face squarely forward and no other components or wires are in their line of sight. Do the same for the other two GP2D12s on the rear crossbracket. Mount the GP2D15s on their appropriate L-brackets, located on the sides of the robot. Step 5: Attaching GM8 sprocket, idler and Tamiya tracks a) Attach left sprocket b) Attach left idler 22 | T e c h n i c a l M a n u a l c) d) e) f) Attach left track Attack right sprocket Attach right idler Attach right track To attach the sprocket, simply slide it onto the GM8 drive shaft. It should fit tight and snug. Next screw the wheel onto the driveshaft. To attach the idler, use a shoulder bolt and hex nuts to fasten it firmly to the L-brackets mounted under the chassis. With the tracks unfastened (one pin missing), place them around the two wheels. Pull the two ends together firmly but gently, and insert last pin. Figure 4.4 - Figure showing how the tracks are mounted Step 6: Attaching the battery pack Place the battery pack between the cross-brackets that were used to mount the GP2D12s. Fasten to the robot using tie-wraps. Step 7: Attaching On/Off button Insert the on/off switch through the appropriate whole located on the proximity sensor brackets. Fasten securely using a hex nut. 23 | T e c h n i c a l M a n u a l Figure 4.5 - Figure showing On/Off button is mounted, to the right Step 8: Connecting wires and ICs Using the schematic and PCD circuit design, place all the wires in their appropriate connectors. If the wires are too long, cut the slack, strip the end of the wire and connect it to the top-screw connectors on the board. Place the microcontroller and motor controller in their appropriate connectors, taking care to note the correct orientation. 4.2 Final Product of BeemoBot Assembly of the BeemoBot is now complete. The following figures are a photograph of the finished product, as well as an artist’s 3D rendering of the robot. Figure 4.6 - Final Robot Assembly 24 | T e c h n i c a l M a n u a l Figure 4.7 - Artist's rendering of robot assembly 25 | T e c h n i c a l M a n u a l 5 Software The following sections will show the pseudo-code for the BeemoBot, as well as a flowchart and images depicting the general behavior of the BeemoBot. It will also include the C program code used in the BeemoBot as well as how to program the microcontroller with this code. 5.1 Pseudo-Code The following depicts the algorithm of the robot in an easy to follow C-like pseudo-code. Note that when the BeemoBot changes its direction flag, it means that it reverses its front and rear. Reverse now becomes forward, forward becomes reverse, and so on. MAIN /////////INITIALISE///////////////// //initialise Digital input set line sensor states to 0 set contact sensor states to 0 set Left & Right IR sensor states to 0 //initilaise Analogue Sensor pins and Data values Enable 60Hz interrupt Enable ADC for Front & Back IRsensors //initialise digital output pins set Motor control Pins as outputs set winning LED pin as output //Delay initialise Enables 1000Hz interrupt on Timer2 for interuptable delay. //initialise global state variables Direction = 0 (forward) //////////////////////////////////////// //5 SECOND DELAY//// do nothing for 5 seconds ////While(1) Loop//// ///GET SENSOR DATA///// Check line sensor data Check contact sensors Check Front & Back IR sensors Check Left & Right IR sensors ////IF A LINE IS DETECTED///// if a line is detected if front left sensor detected the line Set direction flag to 1 go forward turn counter clockwise if front right sensor detected the line 26 | T e c h n i c a l M a n u a l set direction flag to 1 go forward turn clockwise if rear left sensor detected the line set direction flag to 0 go forward turn clockwise if rear right sensor set direction flag to 0 go forward turn counter clockwise if both Front sensors detected the line set direction flag to 1 go forward if both rear sensors detected the line set direction flag to 0 go forward /////ELSE IF ROBOT MAKES CONTACT///// if a robot makes contact if robot makes contact on front left set direction flag to 0 move forward and left into robot if robot makes contact on front right set direction flag to 0 move forward and right if robot makes contact behind to left set direction flag to 1 move forward and right into robot if robot makes contact behind to right set direction flag to 1 move forward and left into robot if robot makes contact on both front sensors set direction flag to 1 move forward into robot if robot makes contact on both rear sensors set direction flag to 0 move forward into robot if robot makes contact at front and back turn clockwise to evade being stuck ///ELSE IF ROBOT IS SEEN BY FRONT/BACK IR SENSORS//// if a robot is seen detected at front or back if robot is seen on front left set direction flag to 0 move forward and left toward robot 27 | T e c h n i c a l M a n u a l if robot is seen on front right set direction flag to 0 move forward and right toward robot if robot is seen behind to left set direction flag to 1 move forward and right toward robot if robot is seen behind to right set direction flag to 1 move forward and left toward robot if robot is seen by both front sensors set direction flag to 0 move forward toward robot if robot is seen behind set direction flag to 1 move forward toward robot ///ELSE IF ROBOT IS SEEN TO LEFT OR RIGHT/// if a robot is seen to left or right if robot is seen to left turn counter clockwise then move forward if robot is seen to right turn clockwise then move forward ///IF NOTHING IS DETECTED//// else Move forward 5.2 BeemoBot’s Expected Behavior 5.2.1 Robot Detection In the figure below we can see a visual representation of what happens when BeemoBot detects an opponent. In Figure 5.1 (a) we see that BeemoBot is looking for an opponent with its digital IR sensors. In Figure 5.1 (b) an opponent has entered BeemoBot’s field of vision. Next BeemoBot will turn to face its opponent, as can be seen in Figure 5.1 (c). BeemoBot knows that its opponent is straight in front if both digital IR sensors are asserted. If an opponent is seen in the rear, the BeemoBot will change its direction flag, reversing its front and back, and will track the opponent in the new front direction. 28 | T e c h n i c a l M a n u a l Figure 5.1 - BeemoBot Analog (Front/Rear) Robot Detection Figure 5.2 - BeemoBot Digital (Left/Right) Robot Detection In the figure above we can see a visual representation of what happens when one of BeemoBot’s digital IR sensors is asserted. These sensors are placed on the left and right of the robot. If Figure 5.2 (a) we see that BeemoBot is checking for a robot at its side. In Figure 5.2 (b) we see that the digital proximity sensor has been asserted. It will then turn to face the opponent, as can be seen in Figure 5.2 (c). 5.2.2 Robot Touch BeemoBot knows when it is making contact with another robot by means of micro-switches located on its front and rear. When both contact switches are asserted, BeemoBot knows its making head-on contact with its opponent and will move in that direction. If, for example, only the front left sensor is being asserted, BeemoBot will turn counter-clockwise to the left, until both contact switches are asserted. Once both are asserted, it will move straight forward. These contact switches are also located on the rear of BeemoBot. If one or both of the rear contact switches is asserted, BeemoBot will change its direction flag, reverse its front and rear, and then move in its new forward direction. 29 | T e c h n i c a l M a n u a l 5.2.3 Line Detection START Etc... Figure 6.3 - Line Detection The BeemoBot is bi-directional. Because of this, when the BeemoBot detects a line head-on, it does not turn around. Instead, a flag is set which reverses the front and the back in the code. The BeemoBot then moves in its new forward direction. If the line has been approached at an angle, the BeemoBot will set the flag, move into the new forward direct, turn approximately 30° away from the line and then continue forward again, waiting once again for an input from one of its sensors. 5.3 Source Code The actual code listing may be found in Appendix A. 30 | T e c h n i c a l M a n u a l 6 Programming the Atmega8 Step 1: Open AVR Studio 5 Step 2: Create new project by going to [File New Project…] Step 3: From the list of installed templates make sure AVRGCC is selected and select ‘C Executable Project’ from the list and give your project a recognizable name. Press ‘Ok’ when done. Step 4: You should now see the ‘Device Selection’ screen, select Atmega8 from the list of devices. You can use the search function in the top right of the screen to speed up this process. Press Ok Step 5: Write your code Step 6: Put AVR Studio in to release mode, do this by looking for a dropdown box in the toolbar, by default it will say ‘Debug’, select ‘Release’ instead. Step 7: Compile the code by either selecting [Build Build Solution], or hit F7. Depending on the length of the code this process may take a few seconds to process. Step 8: Once everything has compiled successfully, open ‘ponyprog.exe’ Step 9: Click Device. In the AVR submenu and select Atmega8 Step 10: Select [Setup Calibration], then proceed to hit [Yes], followed by [OK]. Step 11: Select [Setup Interface Setup], this will bring you to the I/O port setup window. Step 12: Ensure that the settings are as follows: Parallel, AVR ISP I/O, if multiple parallel ports are on the machine make sure the correct one is selected, and then press [OK]. Step 13: Click [File Open Device File <your file name> Default Binary <your .hex file>]. The code will then appear in ponyprog.exe’s main window in hex format. Step 14: Connect the programming circuit on a breadboard as shown in Figure 3.5 in this document. Step 15: Plug your interface cable into the parallel port of your computer. Step 16: Plug the other end of the interface cable into the ISP connectors located on your breadboard. Step 17: Turn ON the 5V supply to power the Atmega8. If you do not do this you may receive the error message ‘unidentified or missing device -21’ when writing to the chip. Step 18: In ponyprog.exe, click Write All, ponyprog.exe will write to the chip and then verify its write. Step 19: If all was successful, your program is now loaded on to your Atemga8 microcontroller. Step 20: Insert the microcontroller into its allotted socket on the BeemoBot PCB. 31 | T e c h n i c a l M a n u a l 32 | T e c h n i c a l M a n u a l 7 Troubleshooting The following table outlines some troubleshooting scenarios. Component QRD1114 GP2D12 GP2D15 Micro-switch Issue Asserting on white surface Not asserting on black surface Asserting when an object is not within 80cm range Not asserting when an object is within 80cm range Asserting when an object is not within 24cm Not asserting when an object is within 24cm Asserting when not depressed Not asserting when depressed Solution Ensure that voltage VO of line sensor is within 0-1V range when within 3mm of a white surface. If not, increase the value of R1 (refer to Figure 3.13 - QRD1114 Perf-Board Circuitry) Ensure that voltage VO of the line sensor is within 3-5V range. If not, decrease value of R2 (refer to Figure 3.13) Check voltage level on output VO of the sensor (refer to Figure 3.2). Voltage level should be almost 0V when no object is within range Check voltage level on output VO of the sensor. Ensure that the correct voltage level is being output for set distances (refer to Figure 3.2). Check the voltage level on output VO of the sensor, when no object is in range. Ensure the voltage level is near 0V. If not, increase the value of the resistor connected to the sensor (refer to Figure 3.2) Check the voltage level on output VO of the sensor, when no object is in range. Ensure the voltage level is between 3-5V (refer to Figure 3.2) Ensure that the micro-switch is connected normally-open. Ensure that the micro-switch is connected normally-open. Table 7.1 - Troubleshooting Scenarios 33 | T e c h n i c a l M a n u a l 34 | T e c h n i c a l M a n u a l 8 References 1 - Atmega8 Pinout” Atmel http://www.futurlec.com/Pictures/ATMega8.gif (accessed December 3rd 2011) 2 - SN754410A Pinout” Texas Instruments “http://lizarum.com/assignments/htink/images/motors/sn754410.jpg” (accessed December 3rd 2011) 3 - Solarbotics GM8 Motor with Bracket” Solarbotics http://www.solarbotics.com/assets/images/gm8/gm8-front-img_3148_pl.JPG (accessed December 3rd 2011) 4 - Johnny Robot Tamiya Track Kit” Tamiya http://www.robotshop.com/Images/xbig/fr/kit-chenillestamiya-johnny-robot-B.jpg (accessed December 3rd 2011) 5 - GP2D12 and GP2D15 Sensor Casing” Sharp http://www.solarbotics.com/assets/images/35080/35080front-dcn1503_pl.jpg (accessed December 3rd 2011) 6 - QRD1114 Package” Fairchild Semiconductor http://www.hvwtech.com/products/97/35120_PV.jpg (accessed December 3rd 2011) 7 - QRD1114 Pinout” Fairchild Semiconductor http://megads.com/files/datasheets/qrd1114-datasheet9b.png (accessed December 3rd 2011) 8 - Micro-Switch Package” Tamiya http://pics.towerhobbies.com/image/t/tamx7516.jpg (accessed December 3rd 2011) 35 | T e c h n i c a l M a n u a l