0% found this document useful (0 votes)
82 views

Massive Dynamic Final Report

The document is a senior design report for an autonomous robot pool playing robot. It describes the overall system and subsystems of the robot, including an ultrasonic guidance system, distance sensing system using Sharp IR sensors, color sensing system, and an IR communication system. It also discusses the rules of the robot pool game and provides code segments and schematics in the appendices.

Uploaded by

wolverinep
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
82 views

Massive Dynamic Final Report

The document is a senior design report for an autonomous robot pool playing robot. It describes the overall system and subsystems of the robot, including an ultrasonic guidance system, distance sensing system using Sharp IR sensors, color sensing system, and an IR communication system. It also discusses the rules of the robot pool game and provides code segments and schematics in the appendices.

Uploaded by

wolverinep
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 32

MASSIVE DYNAMIC

RO BOT PO OL
SENIOR DESIGN REPORT

Prepared for:

Team Members:

Dr. R. Lal Tummala


Department Chair SDSU College of Electrical Engineering

John Kennedy
Senior Project Instructor
Massive Dynamic San Diego State University, 5500 Campanile Drive San Diego, Ca 92182

Leo Alo Alex Lovisolo David Martin Christian Reyes Matt Selby

TA B L E O F C O N T E N T S
1. ABSTRACT ...3 2. INTRODUCTION ..4 3. BODY .6 I. Overall System ..6 II. Sub-Systems..7 Ultrasonic System..7 Distance Sensing System...9 IR Communication System..12 Launching Mechanism System....13 Color Detection System...16

III. Budget & Cost Analysis.....19 4. CONCLUSIONS AND RECOMMEDATIONS...20 5. REFERENCE.23 6. APPENDICES...24 Appendix A: Code Segments.24 Appendix B: Budget & Project Management....30 Appendix C: Schematics32

1. ABSTRACT The functionality of robots has grown tremendously throughout the years. Present day robots are designed to take on tasks that were unheard of in previous years. Massive Dynamic saw a unique opportunity in this new era of robotics to propose a project that is not only innovative but is based on a concept of having fun. We proposed to design a fully autonomous robot that takes on the challenge of playing a game of pool according to a distinct set of rules and accomplished that goal. Our robot is based on an iRobot create platform and is equipped with an assortment of hardware components such as a ball retrieval device and a various amount of sensors. These components assist the robot in the process of acquiring balls and its movement on the table. The ultimate goal was to have a fully functioning robot that plays a game of pool against another robot in a competitive fashion and we proved that possible.

2. INTRODUCTION The goal of our project is to design an autonomous robot that plays a game of pool following a set of rules. The pool game will be set up with 15 balls on the table, seven being blue, seven being red, and the final ball being black. The black ball has a small magnet within it to differentiate it from the other balls. The game will be played on a table that is 5' x 10 and has six ball pockets that are emitting ultrasonic waves at a frequency of 25 KHz. After discussion with our competitors on the project, we decided on a set of rules that are fair and reasonable. The rules go as follows: One match shall consist of up to 3 games with each game lasting a maximum time of 5 minutes. A coin flip will determine the team colors for the first game. Colors will alternate in the second and third game (if necessary). Teams are able to lift balls from the pool table. Robots can be a maximum of 20x20 and must fit inside a specified box. Time penalty has been increased from 10 seconds to 15 seconds. If a robot gets stuck anywhere on the table, you are able to move your robot with a penalty charged. Penalties will be a choice between sinking an opponents ball, or pulling one of your own from the sockets. Malicious attempts to intentionally damage an opponents robot will be penalized by the official. If a robot captures and holds on to an opposing teams ball for more than 15 seconds a violation will be issued.

The game will be won by the first robot so sink all of its balls and the eight ball. If neither team succeeds, the team with the most balls pocketed will be declared the winner.

If a robot sinks the eight ball before pocketing all of their colored balls the game will end with the opposing team being declared the winner.

After reviewing how the game is played and the set rules, our team conceptually thought of various ways of completing the task at hand. Our ideas ranged from all sides of the spectrum on the complexity scale. After fair discussion, we decided on a design that is low in complexity but will be seamlessly efficient. This was decided because of the time frame that was given and our teams budget. Our robot design is centered on the iRobot create platform to simplify the project so we could fit the desired time requirements. We decided on using 4 different sensors on our platform that all serve unique purposes. We used hall sensors, color sensors, distance sensors, and ultrasonic transducers. The hall sensors primary purpose is to detect the eight ball on the table being that it has a magnet in its core. The color sensors were used for color detection of the balls while the distance sensors were used for any desired distance measurements the robot needed. Ultrasonic transducers were used to identify where the ball pockets are and provided the robot with directions on how to get to the holes. The main debate in our design was regarding on how our robot would retrieve balls. We decided to go for a retrieval mechanism that would only retrieve one ball at a time. This was chosen again due to time constraints and complexity issues. Our team chose this project because it seemed like a lot of fun and it most certainly was. We all came from different backgrounds but all had an interest in becoming more familiar with robotics. This project provided us with a unique challenge that we all embraced.

3. BODY I. Overall System In order to accomplish the task of robot pool, an array of sensors was used by the team to accomplish the tasks of game status sensing, ball detection, pocket location, and ball delivery. There were six sub-systems that went into the overall system of the robot: Distance Sensor System, Acquisition System, Color Sensing System, Ultrasonic System, Delivery System, and the IR Communication System. Each sensor unit is independent and operates under the command of an individual microcontroller. The entire project uses Microchip PIC 16 series 8 bit microcontrollers. UART serial communication was used with the robot in order to send commands/receive sensor data from the separate subsystems. A block diagram of the overall system is provided below.

Distance Sensors

Acquisition System

Color & Magnetometer Sensors

PIC16F882

PIC16F882

PIC16F882

Central Processor PIC16F

PIC16F882

PIC16F882

PIC16F882 Ultrasonic Sensor IR Communication

Delivery System

II. Sub-Systems Ultrasonic System The ultrasonic systems main purpose is to act as a guidance mechanism for the robot once it gets a ball of its choice. This system has the ability to sense the 25 KHz pulses being outputted by the holes on the pool table and through time measurements will provide the robot with commands telling it whether to turn right, left, or straight to go in the direction of the hole. This system was well thought out and meticulously engineered. The system is fundamentally built around an ultrasonic transducer. We are only using this transducer as a receiver, so therefore in a sense it is only acting as a sensor. This sensor has the ability to receive the pulses that are being emitted from the holes on the table but only outputs a very small voltage. We saw a need to amplify this signal using an instrumentation amplifier (INA126) in order to gain a better visual of when these pulses were occurring. Also through this amplifier we were interested in providing this signal with a tremendous amount of gain. We sought after this because we wanted the initial edge from the pulse as fast as possible in order to get an accurate time measurement. This rail to rail output will give us a very good idea of when the pulse is first hitting our sensor. Moving of from the amplification process, we then came up with the idea of adding a comparator (LM339) to our system so we could adjust the sensitivity of our sensors by simply adjusting a potentiometer located in the Vref (Voltage Reference) of the comparator. This worked by running the input of our amplifier into the input of the comparator. Then by properly setting up a voltage divider

with a resistor and a potentiometer in the Vref of the comparator, we now would be able to adjust the reference voltage very easily. The comparator also outputted a square wave which gave us a clean edge for time measurements. The output of the comparator was simply run into a microcontroller (PIC16f882) which now had the proper inputs for coding. The schematic for this circuit looks as such:

The ultrasonic system was set up on the robot by placing two of these transducer circuits on the same plane and measuring the time difference between the pulses hitting one transducer versus the other. The code for this operation was done in assembly language because it was dealing with timing measurements. This system was also mounted on a servo that would help in scanning the table for the holes of interest. This helps the efficiency of the robot because the robot did not have to do this scan manually. The code for both the servo and the Ultrasonic circuits can be found in the appendix of this report.

Distance Sensing System Due to its simplicity and immunity to interference from ambient light as well as a remarkable indifference to the color of an object being detected, we decided to use the Sharp IR GP2D12 distance sensor (Fig. x).

Figure x. Sharp IR GP2D12 distance sensor. This detector comes in a small package, very little current consumption (25mA), and an analog output that is proportional to the distance detected. Figure x shows the GP2D12 Output Voltage to Distance Curve. Figure y demonstrates that the output voltage response of the sensor is not linear, but rather somewhat logarithmic.

Figure y. GP2D12 Output Voltage to Distance Curve. The Sharp GP2D12 has a detection range of 10 to 80 centimeters; it uses triangulation and a small linear CCD array to compute the distance of objects in

the field of view. Charge-coupled device (CCD) is an analog shift register that enables the transportation of analog signals (electric charges) through successive stages (capacitors), controlled by a clock signal. Charge-coupled devices can be used as a form of memory or for delaying samples of analog signals. The sensor emits a pulse of IR light by the emitter. This light travels out in the field of view and either hits an object or just keeps on going. In the case of no object, the light is never reflected and the reading shows no object. If the light reflects off an object, it returns to the detector and creates a triangle between the point of reflection, the emitter, and the detector. Figure z demonstrates the distance detection principle utilized by the Sharp GP2D12.

Figure z. Distance detection principle. The angles in this triangle vary based on the distance to the object. The receiver portion of these new detectors is actually a precision lens that transmits the reflected light onto various portions of the enclosed linear CCD array based on the angle of the triangle described above. The CCD array can then determine what angle the reflected light came back at and therefore, it can calculate the distance to the object.

10

From Fig. y, we can also see the erratic output when the object is closer than 6 centimeters. This was accounted for by placing the sensors inside the diameter of the iRobot Create platform, about 6 cm away from the edge of the platform. By utilizing this hardware arrangement, the sensors irregular output was avoided. The robot uses a system of two distance sensors mounted on a servo. The sensors are placed one on top of the other, so that the higher one will only sense the wall and not the ball. Therefore, if both sensors output the same voltage, a large/tall object, probably the wall or an opponent is being detected by the sensors. On the other hand, a large difference in the sensors output voltage represents two different objects; most likely a ball its being detected by the lower sensor. Furthermore, utilizing the array of distance sensors an algorithm was implemented to detect any object on the table. The algorithm is based on edge detection. The distance sensors will inform the microcontroller controlling the servo to stay within the edges of the ball; thus locking the servo at the center of the object. The objects edges can be determine by monitoring the sensors output for an abrupt change on the output voltage. The code for the detection algorithm can be found in Appendix X. Once a ball has been identified, its position, relative to the robots, can be determined using the position of the servo. The servo motors have a built in motor, gearbox, position feedback mechanism and controlling electronics. The servo motor can be controlled to move any position by using simple pulse controlling. Sending 1 ms pulses sets the servo to one end position and sending 2

11

ms pulses sets it to the other end position. Sending 1.5 ms pulse sets the servo motor to the center position. This way, the object will always be centered independently of the iRobot's movement. The distance sensors array, the detection algorithm along with the range of movement and speed of the servo, allows the robot to detect objects faster and more accurate than using the robots movement mechanism. Infrared Communication System An infra-red (IR) communication channel will deliver information about the state of the game to the robot. There were four main states in which we were interested in: Start, Stop, Pause, and Penalty. The infrared game status sensor receives coded data via Sony pulse technology. In this technology, binary 1s and 0s are not represented by highs and lows, but instead represented by the length of the high time of the pulse. The initial pulse or AGC (automatic gain control pulse) is sent out to signify the beginning of a byte. This pulse is 2400 microseconds long. A 1 is specified with a high time of 1200 microseconds, whereas a 0 is specified with a high time of 600 microseconds. The chart below shows a typical byte sent over the infrared data channel (image courtesy of SDSU).

12

All of the coding for this sensor was done on a Microchip PIC 16 series microcontroller in assembly language. Launching Mechanism System The ball delivery system we decided to use was a solenoid shooting mechanism. The solenoid we purchased from Mouser had a 12VDC rating. However, the voltage supplied from the IRobot creates battery was limited to 5 Volts. This report is intended to provide the method of boosting DC voltage from 5 Volts to 50 Volts, by using a DC-DC switching boost converter designed specifically for this task. Boost converter schematic:

A boost converter works by taking the provided input DC voltage to the switch control, and to the magnetic field storage element. The switch control directs the action of the switching element, while the output rectifier and filter deliver an acceptable DC voltage to the output. In order to achieve the results

13

specified for this project, the output voltage of the converter needs to be higher than the input voltage. This type of converter operates in the flyback-mode. When the mosfet is conducting, current is being drawn through the inductor. At this time energy is being stored in the inductor. When the mosfet stops conducting the inductor voltage flies back or reverses because the current through the inductor cannot change instantaneously. The voltage across the inductor increases to a value that is higher than the combined voltage across the diode and the output capacitor. As soon as this value is reached, the diode starts conducting and the voltage that appears across the output capacitor is higher than the input voltage. The higher voltage is stored in the 6800uF 50 volt capacitor until it is ready to be discharged into the load with the help of a second mosfet. The inductor acts as the magnetic field storage element. It stores energy in its core material. The PWM functions as the switch control and the n-channel mosfets

acts as the switch element. This device also consists of a 5 V reference regulator, a comparator, and a controlled duty cycle oscillator. The oscillator charges and discharges an external timing capacitor. The upper threshold of the timing capacitor is equal to the reference regulator voltage of 5 V. The value of the timing capacitor sets the frequency of the entire circuit and controls the rate of operation of the oscillator. When the capacitor is charging the voltage at the lower input of the AND gate is high. The comparator inverting input is connected to two external resistors, which control the duty cycle of the circuit. When the output voltage of the converter falls below the required value,

14

the inverted input of the comparator will fall below 5 V. Then the comparator will output a Logic 1 and the SR latch will set, enabling the mosfet to conduct until 5 V is again present at both inputs of the comparator. The timing capacitor will then discharge. A Logic 0 will be present at the lower input of the AND gate and the mosfet will stop conducting. The boost converter was built on a standard breadboard. During testing, a pulse was used to mimic the operation of the control chip PWM. An on time and an off time were entered into the attributes of the pulse. The circuit was simulated with two resister connected across the output capacitor for sampling purposes. All of the specifications stated previously have been met by this boost converter design. The output voltage across the output capacitor is 50V. The voltage ripple was higher than we would have liked but it didnt affect the end result too dramatically. The process of building this design did have its problems. We burned out multiple mosfets due to having the load connected incorrectly. Although the design worked in SPICE, it had to be modified when transferred to the bread board. After the bread board test circuit was completed, we sent in the PCB layout we made from mentor graphics. The PCB had one of the parts connected in reverse so it took another day to figure out what was wrong with the circuit. After making sure all the traces were working, we were able to salvage the board using jumper wires. Unfortunately, we were not able to implement this design in time for the robot pool competition. Integrating all of our other systems onto our robot

15

caused us to have many unforeseen problems that took priority over our delivery system. Color Detection System
Once the mechanical arm is lowered, it is crucial that the ball is correctly identified. There are three possible different types of balls that can be collected - Red, Blue and Black. An important thing to note is that the black ball has 6 magnets uniformly distributed inside of it, with the same polarity pointing outwards. This can be used to distinguish the black ball from the colored balls using appropriate sensors. Initially, MASSIVE DYNAMIC experimented with the Avago ADJD-S371-Q999 color sensor. This is a very powerful sensor: 4 channels (red, blue, green and clear) each with a 10 bit resolution, and integrated bright LED. This was difficult to work with. Due to its small size, prototyping was difficult. 10 wire wrap wires had to be soldered by hand on the small 3.9x4.5mm sensor. These thin wires often broke off the solder joints, and frequent resoldering led to two of them being burned out. After the final circuit was laid out on the pcb, the i2c communication functioned perfectly, but in circuit debugging would not work. This made it impossible to calibrate the sensor hence rendering the circuit unusable.

The Color Sensor


The solution we adopted was to create a simple color sensor ourselves. This essentially consisted of 2 ultra bright LEDs, one red and one blue, and one voltage divider composed of a fixed resistor in series with a light dependent resistor (fixed resistor connected to +5V, photo resistor connected to ground). The LED's are controlled by a PIC16F882 microcontroller and the output of the voltage divider is fed to an Analog to Digital converter channel of the PIC. The photo resistor has a film around the sides blocking direct light from the LEDs so only reflected light has an effect on the voltage divider's output.

16

The analog voltage output of the voltage divider is a decreasing function of the light reflected from the ball. This is because the resistance of the photo resistor decreases as a function of light intensity. For each ball we shine one LED at a time, and read the output of the voltage divider. Clearly the red ball reflects more red light than the blue ball, and vice versa. Thresholds can be set to distinguish the colors: if the value read when the red LED is shining is below the threshold for red the ball is red, and if the value read when the blue LED is shining is below the threshold for blue the ball is blue. This approach is not ideal. These thresholds depend on the background light, and on the distance the sensor is from the ball. In our application, background light is isolated by the cup, but as the cup is wider than the ball, the distance from the photo resistor to the ball may vary. For this reason we used dynamic thresholds. A reading is made with the red LED, and the result is the threshold for the reading with the blue LED. This is explained in the flow chart.

The Magnetometer Circuit


To distinguish the black ball we used a KMZ 10B M609 magnetometer. This senses magnetic flux and outputs an analog voltage in the mV range. The output is amplified with an INA126 instrumentation amplifier and fed to the second of the PIC's Analog to Digital channel. When checking if the ball is black, the result from the A/D channel is compared to a threshold. Only if it is higher than the ball is black.

17

The detection

flowchart

summarizes Once

the the

mechanism.

magnetometer has sensed a field, the output is held at 1,1 until the arm is raised. The PIC is given 1 bit input from the central processor to be able to tell whether the arm is raised or lowered. This is the same bit that controls the servo that raises and lowers the arm. Using dynamic thresholds proved to be a brilliant solution. The sensing mechanism worked just as well in the dark covered by the cup as it did out of the cup with the lights on in the room. If we had used fixed thresholds we would have needed to reprogram the device to work with different light conditions. It is always good practice to create systems which automatically calibrate themselves.

18

III. Budget & Cost Analysis Our team was given a budget of $250.00 to complete our robot. The $129.99 irobot create platform was provided for us and was not included in the budget. The way were able to access our funds was by completing purchase orders. These purchase orders had us fill out the part names, descriptions, costs, and vendors. Our instructor John Kennedy would then send the orders in and have the items shipped to San Diego State University. The vendors we used were Mouser, Digikey, SparkFun, as well as purchasing items from the SDSU engineering department. One of our main goals was to keep costs as low as possible so that others interested in doing a similar project would have an affordable way of doing so. However, there were complications during the testing an integration phase that caused us to spend almost all our available budget. The percentage breakdown is as follows:

The majority of our funds were spent on electronic parts. Our robot utilized multiple servos for our ultrasonic sensor, infrared distance sensor, and arm acquisition system. There were also many other electronic parts purchased which added up to the final 38% count. The

19

second largest expense was our sensors, followed by fabrication costs. Fabrication costs included acrylic plastic, hinges, and other materials. We are happy with our final cost because we were able to stay under the $250.00 limit. Something that was surprising was how fast smaller parts costs added up. With the exception of our $31.00 solenoid, most of the other parts were less than $10.00 with other parts running just $1.00 or less. We were able to utilize many of the free parts available to us found in the lab. Making sure we planned ahead with our budget was vital because not having enough money to finish would be detrimental to the project. 4. CONCLUSIONS AND RECOMMEDATIONS The goal of the project is of little use other than a didactic one. A robot that can play pool is not going to be mass produced and will not be able to become commercially successful. However, it can be easily adapted to a project aimed to solve a real life problem. Furthermore there are countless applications each subsystem could be used in. Robot competitions are becoming more and more common, with most competing teams being groups of university students like ourselves, but the aim of these competitions is not to learn to design robots better at playing pool. These competitions are set up in the hope that new solutions are found to problems. This notion is best explained with examples: The ROOMBA robotic vacuum cleaner requires the user to press a button to start vacuuming. The user might want it to automatically vacuum once a week, every week, completely independently. A docking station could be placed on the floor for charging and coordination which emits ultra sonic pulses similarly to the pockets on the pool table. Equipping the iRobot ROOMBA with 2 ultra sonic sensors would mean it could automatically find the charging dock after the task is completed, and completely independently. Ultra sonic walls are

20

already commonly used in applications like the roomba. They can be used to close off an area, for instance delimit a room, so the robot does not clean a room undesirably. Color sensing has many applications also. Color sensors are used in industries for sorting, just as our robot sorts red balls and blue balls. Designing a more efficient color sensor means colors can be more accurately, quickly and reliably detected. We have designed a highly inexpensive color sensor that suits our task of distinguishing red and blue much better than other more sophisticated ones available commercially. Infra red communication is an efficient way to wirelessly send data. The Infra-red game status module we developed could find many applications. It could be used for the communication between two robots. For instance, if there were two roombas cleaning the floor they could communicate amongst each other to ensure that the same part of the room was not covered twice, or the base station could send commands wirelessly. Many more examples could be listed for each subsystem, and creating them efficiently not only improves the robots ability to play pool, but also makes them more suitable to solve the problems listed above, hence improving the way we approach real life problems. Ultimately, we will be able to create autonomous systems able to do work in dangerous job enviromnments. The project was very instructional, and gave each team member strong expertise. Each subsystem was intended to work independently and they all did. There are some main recommendations for those who wish to attempt something similar in the future. It was brilliant to break up the project into subsystems which work completely independently. This enabled us to think of everything modularly and gave the project a clear structure. It also reduced the work load any single processor had to carry. One important aspect which should not to be underestimated is the integration process. In our case, each subsystem worked flawlessly on its

21

own, both when it was powered from a power supply and from the voltage regulators on board of the iRobot. Putting the project together however, each subsystem added noise to the power line, and although we had two separate 5V regulators for noisy and not noisy supply, the systems interfered with each other. This was caused by the servos. So long as only one was powered at a time there was no problem. When all three were powered, peaks of high current draw would cause the voltage to drop on the other non noisy supply although the servos were powered by the noisy supply. This problem was discovered too late to redesign the main board with the voltage regulators. We managed to solve the problem by redesigning the system using only one servo. This made our robot less efficient. Instead of having the ultra sonic system track using a servo, the entire robot turned. This movement is slow. We also eliminated the mechanical arm as the servo caused too much noise. The robot pushed the ball and sometimes the ball would get lost while turning as it was not held by the cup. The only servo we used was the one used in the infra red ball tracking, without which the entire project would not work. This shows how important power management is in a project. And that the integration process may take a long time even after each system works perfectly. The team should have put just as much effort on the integration as on completing each individual task. This was only a slight slip, and MASSIVE DYNAMIC successfully created a robot able to sort balls on a pool table and compete.

22

5. REFERENCE Works Cited CCS, Inc. - Home. 21 May 2009 <http://www.ccsinfo.com>. Sedra, Adel S. Microelectronic circuits. New York: Oxford UP, 2004.

23

6. APPENDICES Appendix A: Code Segments Detection Algorithm Code:


#include <16F882.h> #fuses HS,NOLVP,NOWDT,PUT,NOBROWNOUT #use delay(clock=1000000) int PwmDelta; int BottomRange; int TopRange; int RangeDelta; int BallnfoOut; main(){ SETUP_OSCILLATOR(OSC_1MHz); SET_TRIS_A(0xFF); SET_TRIS_B(0x00); OUTPUT_B(0x00); SETUP_ADC_PORTS( sAN0 | sAN1); SETUP_ADC( ADC_CLOCK_INTERNAL ); SETUP_CCP1(CCP_PWM); SETUP_TIMER_2(T2_DIV_BY_16,150,1); PwmDelta = 15; while(TRUE){ if(PwmDelta == 28){ PwmDelta = 15; SET_PWM1_DUTY(PwmDelta); OUTPUT_B(0x00); delay_ms(900); } SET_ADC_CHANNEL(1); BottomRange = READ_ADC(); SET_ADC_CHANNEL(0); TopRange = READ_ADC(); if(BottomRange > TopRange) RangeDelta = (BottomRange - TopRange);

24

if(TopRange > BottomRange) RangeDelta = (TopRange - BottomRange);

if(RangeDelta < 15){ OUTPUT_LOW(PIN_B0); OUTPUT_LOW(PIN_B1); OUTPUT_LOW(PIN_B2); PwmDelta++; delay_ms(5); } else{

} SET_PWM1_DUTY(PwmDelta); if(PwmDelta > 22 && PwmDelta < 29){ OUTPUT_HIGH(PIN_B0); } else if(PwmDelta <= 22 && PwmDelta >= 20){ OUTPUT_HIGH(PIN_B1); } else if(PwmDelta > 14 && PwmDelta < 20){ OUTPUT_HIGH(PIN_B2); }

delay_ms(50); } }

25

Color Sensing and Magnetometer Code:


#include <16F882.h> #fuses HS,NOLVP,NOWDT,PUT, NOBROWNOUT #use delay(clock=4000000) int int int int int int int int ResultRed; ResultBlue; ResultHall; RangeDelta; BallnfoOut; test; bluecount; redcount;

main(){ SETUP_OSCILLATOR(OSC_4MHz); delay_ms(15); SET_TRIS_A(0xFF); SET_TRIS_B(0x00); test=input(PIN_B4); SETUP_ADC_PORTS( sAN0 | sAN1 ); SETUP_ADC( ADC_CLOCK_INTERNAL ); SETUP_TIMER_2(T2_DIV_BY_16,150,1); bluecount=0; redcount=0; while (1) { output_low(PIN_B4); output_low(PIN_B1); output_low(PIN_B0); SET_ADC_CHANNEL(1); ResultHall = READ_ADC(); if(ResultHall>0x1f) { output_high(PIN_B2); output_high(PIN_B3); output_high(PIN_B4); } //read red (led on pin B0) output_low(PIN_B1); output_high(PIN_B0); delay_ms(300); SET_ADC_CHANNEL(0); ResultRed = READ_ADC(); //read blue (led on pin B1) output_low(PIN_B0); output_high(PIN_B1); delay_ms(300); SET_ADC_CHANNEL(0); ResultBlue = READ_ADC();

26

// if (-2<(resultred-resultblue)<2) {redcount=0; bluecount=0;} if(ResultBlue>ResultRed) { //ball is red redcount=redcount+1; bluecount=0; if (redcount>4) { output_high(PIN_B2); output_low(PIN_B3); } else { output_low(PIN_B2); output_low(PIN_B3); } } if(ResultBlue<ResultRed) { //ball is blue bluecount=bluecount+1; redcount=0; if (bluecount>4){ output_high(PIN_B3); output_low(PIN_B2); } else { output_low(PIN_B2); output_low(PIN_B3); } } } }

Servo Tracking Code:


#include <16F882.h> #fuses HS,NOLVP,NOWDT,PUT, NOBROWNOUT #use delay(clock=500000) int int int int int PwmDelta; A; B; C; test;

main(){ SETUP_OSCILLATOR(OSC_500kHz); SET_TRIS_A(0x00); SET_TRIS_B(0x00); SET_TRIS_C(0xff);

27

OUTPUT_B(0x00); SETUP_CCP1(CCP_PWM); SETUP_TIMER_2(T2_DIV_BY_16,150,1); PwmDelta = 10; SET_PWM1_DUTY(PwmDelta); test=1; while (1) { while (test==1) { SET_PWM1_DUTY(10); test=input(PIN_C3); } A=input(PIN_C0); B=input(PIN_C1); C=0; while ((A==0)&(B==0)&(test==0)) { output_low(PIN_B0); output_low(PIN_B1); if (C) { PwmDelta=PwmDelta+1; SET_PWM1_DUTY(PwmDelta); if(PwmDelta>16) {C=0; PwmDelta=15;} } if (!C) { PwmDelta=PwmDelta-1; SET_PWM1_DUTY(PwmDelta); if(PwmDelta<5) {C=1; PwmDelta=6;} } A=input(PIN_C0); B=input(PIN_C1); test=input(PIN_C3); delay_ms(250); } if (A&(test==0)) { PwmDelta=PwmDelta+1; if (PwmDelta>16) {PwmDelta=16;} SET_PWM1_DUTY(PwmDelta); A=input(PIN_C0); B=input(PIN_C1); test=input(PIN_C3); } if (B&(test==0)){ PwmDelta=PwmDelta-1; if (PwmDelta<5) {PwmDelta=5;} SET_PWM1_DUTY(PwmDelta);

28

A=input(PIN_C0); B=input(PIN_C1); test=input(PIN_C3); } if (PwmDelta>11) { output_high(PIN_B0); output_low(PIN_B1); } else{ if (PwmDelta<9) { output_low(PIN_B0); output_high(PIN_B1); } else { output_high(PIN_B0); output_high(PIN_B1); } } delay_ms(250); } }

29

Appendix B: Budget & Project Management Detailed Budget Breakdown:


ITEM # 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 5k Bourns 3386 Trimmer 40-pin SIP Connector Potentiometer Engineering Dept. Engineering Dept. 8 1 Subtotal Tax Rate Tax S&H Total 1.25 1 COM-00098 MDUSPCB MDPICPCB LM339 COM-00527 COM-00107 COM-00526 1-IDC2x5-F 863-1N5368BG PRT-08430 568-3555-ND PRT-08801 8650K311 LMV339 C24-26C24DC-AY PIC16F887 IRF530 PIC16F882 GP2D12 AVAGO ADJDS371 Q999 Part # DESCRIPTION iRobot Create Color Sensor Ultrasonic Transducer IR Receiver Distance Sensor Servos PIC Controller Distance Sensor Harness Tubular Solenoid (push) Hall Effect Sensor Jumpers IC Mag Field Sensor Mini-Breadboard Acrylic Sheet 12''x12'' Tiny Pack Comparator Tubular Solenoid (Push) PIC Controller N-channel Mosfet 6800uF Capacitor 100uH Inductor Fuse Holder Diodes-Zener 47V 5W 1 Amp Fuse 6-pin MTA connector 3-pin MTA connector Omron Snap Action Switch MD US PCB MD PIC PCB Quad Comparator 12V Voltage Reg 5V Voltage Regulator 3.3V Voltage Regulator 2x5 IDC Female Blue LED Photocell DISTRIBUTOR Engineering Dept. SparkFun Engineering Dept. Engineering Dept. Mouser Engineering Dept. Digikey Engineering Dept. Engineering Dept. Sample Engineering Dept. Digikey SparkFun Mcmaster Engineering Dept. Mouser Engineering Dept. Engineering Dept. Engineering Dept. Engineering Dept. Engineering Dept. Mouser Engineering Dept. Engineering Dept. Engineering Dept. SparkFun Engineering Dept. Engineering Dept. Digikey Engineering Dept. Engineering Dept. Engineering Dept. computercablestore Engineering Dept. Digikey QTY 0 3 4 2 4 3 6 4 1 2 1 1 1 1 2 1 1 5 1 1 1 2 1 4 6 2 3 1 2 1 2 1 1 2 1 UNIT PRICE $129.99 $9.95 $1.00 $1.00 $9.74 $10.00 $1.73 $1.00 $0.99 $0 $4.27 $4.93 $3.95 $16.30 $1.20 $31 1.73 0 0 3 1 0.32 0 0.24 0.12 1.95 0 0 1.25 0.5 0.5 0.5 0.95 0.25 1.75 TOTAL $0.00 $29.85 $4.00 $2.00 $38.96 $30.00 $10.38 $4.00 $0.99 $0.00 $4.27 $4.93 $3.95 $16.30 $2.40 $31 1.73 0 0 3 1 0.64 0 0.96 0.72 3.9 0 0 2.5 0.5 1 0.5 0.95 0.5 1.75 0 0 10 1 $213.68 7.75% $16.56 0 $230.24

30

Gantt Chart:
Feb 2009 Mar 2009 1/3 8/3 15/3 22/3 29/3 5/4 Apr 2009 12/4 19/4 26/4 3/5 May 2009 10/5 17/5 24/5 31/5

ID

Task Name

Start

Finish

Duration
15/2 22/2

1 2 3 4 5 6 7 8 9 10 11

Project Start

2/16/2009 2/16/2009 2/16/2009 2/16/2009 3/2/2009 3/2/2009 3/5/2009 2/16/2009 2/16/2009 2/27/2009 3/20/2009

2/16/2009 3/27/2009 3/13/2009 3/13/2009 3/27/2009 3/27/2009 3/5/2009 4/2/2009 2/27/2009 3/19/2009 4/2/2009

0w 6w 4w 4w 4w 4w 0w 6.8w 2w 3w 2w

Characterized sensors
Distance Sensor Ultrasonic Transducer IR Receiver Color Sensor

Proposal

Software Development
Communication Movement Sensor Algorithms

12

Merge sensors and iRobot Create platform Acquisition & Hardware Fabrication
Final Oral Presentation Design Day

3/27/2009

4/9/2009

2w

13

3/30/2009

4/17/2009

3w

14 15 16 17

4/6/2009 4/8/2009 4/17/2009 5/4/2009

4/6/2009 4/8/2009 5/4/2009 5/4/2009

0w 0w 2.4w 0w

Testing
Projects Ends

31

Appendix C: Schematics

Boost Converter Schematic:

Ultrasonic Schematic:

32

You might also like