massive dynamic final report

Upload: wolverinep

Post on 13-Apr-2018

218 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/27/2019 Massive Dynamic Final Report

    1/32

    ROBOT POOL

    SENIOR DESIGN REPORT

    Prepared for: Team Members:

    Dr. R. Lal Tummala Leo AloDepartment Chair Alex Lovisolo

    SDSU College of Electrical Engineering David MartinChristian ReyesJohn Kennedy Matt SelbySenior Project Instructor

    Massive DynamicSan Diego State University, 5500 Campanile Drive

    San Diego, Ca 92182

    M A S S I V E D Y N A M I C

  • 7/27/2019 Massive Dynamic Final Report

    2/32

    2

    TA B LE O F C O N TEN TS

    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

  • 7/27/2019 Massive Dynamic Final Report

    3/32

    3

    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.

  • 7/27/2019 Massive Dynamic Final Report

    4/32

    4

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

  • 7/27/2019 Massive Dynamic Final Report

    5/32

    5

    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.

  • 7/27/2019 Massive Dynamic Final Report

    6/32

    6

    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 sub-

    systems. A block diagram of the overall system is provided below.

    Central

    Processor

    PIC16F

    Distance

    Sensors

    Ultrasonic

    Sensor

    Color &

    Magnetometer

    Sensors

    IR

    Communication

    PIC16F882

    PIC16F882

    PIC16F882

    PIC16F882

    Acquisition

    System

    PIC16F882

    Delivery

    System

    PIC16F882

  • 7/27/2019 Massive Dynamic Final Report

    7/32

    7

    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

  • 7/27/2019 Massive Dynamic Final Report

    8/32

    8

    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.

  • 7/27/2019 Massive Dynamic Final Report

    9/32

    9

    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

  • 7/27/2019 Massive Dynamic Final Report

    10/32

    10

    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.

  • 7/27/2019 Massive Dynamic Final Report

    11/32

    11

    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 sensorsoutput

    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

  • 7/27/2019 Massive Dynamic Final Report

    12/32

    12

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

  • 7/27/2019 Massive Dynamic Final Report

    13/32

    13

    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 providedinput 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

  • 7/27/2019 Massive Dynamic Final Report

    14/32

    14

    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,

  • 7/27/2019 Massive Dynamic Final Report

    15/32

    15

    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

  • 7/27/2019 Massive Dynamic Final Report

    16/32

    16

    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.

  • 7/27/2019 Massive Dynamic Final Report

    17/32

    17

    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.

  • 7/27/2019 Massive Dynamic Final Report

    18/32

    18

    The flowchart summarizes the

    detection mechanism. Once the

    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.

  • 7/27/2019 Massive Dynamic Final Report

    19/32

    19

    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

  • 7/27/2019 Massive Dynamic Final Report

    20/32

    20

    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

  • 7/27/2019 Massive Dynamic Final Report

    21/32

    21

    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

  • 7/27/2019 Massive Dynamic Final Report

    22/32

    22

    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.

  • 7/27/2019 Massive Dynamic Final Report

    23/32

    23

    5. REFERENCE

    Works Cited

    CCS, Inc. - Home. 21 May 2009 .

    Sedra, Adel S. Microelectronic circuits. New York: Oxford UP, 2004.

  • 7/27/2019 Massive Dynamic Final Report

    24/32

    24

    6. APPENDICES

    Appendix A: Code Segments

    Detection Algorithm Code:

    #include

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

  • 7/27/2019 Massive Dynamic Final Report

    25/32

    25

    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 = 20){

    OUTPUT_HIGH(PIN_B1);

    }

    else if(PwmDelta > 14 && PwmDelta < 20){

    OUTPUT_HIGH(PIN_B2);

    }

    delay_ms(50);

    }

    }

  • 7/27/2019 Massive Dynamic Final Report

    26/32

    26

    Color Sensing and Magnetometer Code:#include#fuses HS,NOLVP,NOWDT,PUT, NOBROWNOUT#use delay(clock=4000000)

    intResultRed;

    intResultBlue;intResultHall;intRangeDelta;intBallnfoOut;inttest;intbluecount;intredcount;

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

  • 7/27/2019 Massive Dynamic Final Report

    27/32

    27

    // if (-24) {output_high(PIN_B2);output_low(PIN_B3);

    }else{output_low(PIN_B2);output_low(PIN_B3);}

    }

    if(ResultBlue4){output_high(PIN_B3);output_low(PIN_B2);}

    else{output_low(PIN_B2);output_low(PIN_B3);

    }}

    }}

    Servo Tracking Code:#include#fuses HS,NOLVP,NOWDT,PUT, NOBROWNOUT#use delay(clock=500000)

    intPwmDelta;intA;intB;intC;

    inttest;

    main(){

    SETUP_OSCILLATOR(OSC_500kHz);

    SET_TRIS_A(0x00);SET_TRIS_B(0x00);

    SET_TRIS_C(0xff);

  • 7/27/2019 Massive Dynamic Final Report

    28/32

    28

    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(PwmDelta16) {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

  • 7/27/2019 Massive Dynamic Final Report

    29/32

    29

    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

  • 7/27/2019 Massive Dynamic Final Report

    30/32

    30

    Appendix B: Budget & Project Management

    Detailed Budget Breakdown:

    ITEM # Part # DESCRIPTION DISTRIBUTOR QTY UNIT PRICE TOTAL

    1 iRobot Create Engineering Dept. 0 $129.99 $0.00

    2 AVAGO ADJDS371 Q999 Color Sensor SparkFun 3 $9.95 $29.85

    3 Ultrasonic Transducer Engineering Dept. 4 $1.00 $4.00

    4 IR Receiver Engineering Dept. 2 $1.00 $2.00

    5 GP2D12 Distance Sensor Mouser 4 $9.74 $38.96

    6 Servos Engineering Dept. 3 $10.00 $30.00

    7 PIC16F882 PIC Controller Digikey 6 $1.73 $10.38

    8 Distance Sensor Harness Engineering Dept. 4 $1.00 $4.00

    9 Tubular Solenoid (push) Engineering Dept. 1 $0.99 $0.99

    10 Hall Effect Sensor Sample 2 $0 $0.00

    11 PRT-08430 Jumpers Engineering Dept. 1 $4.27 $4.27

    12 568-3555-ND IC Mag Field Sensor Digikey 1 $4.93 $4.93

    13 PRT-08801 Mini-Breadboard SparkFun 1 $3.95 $3.95

    14 8650K311 Acrylic Sheet 12''x12'' Mcmaster 1 $16.30 $16.3015 LMV339 Tiny Pack Comparator Engineering Dept. 2 $1.20 $2.40

    16 C24-26C24DC-AY Tubular Solenoid (Push) Mouser 1 $31 $31

    17 PIC16F887 PIC Controller Engineering Dept. 1 1.73 1.73

    18 IRF530 N-channel Mosfet Engineering Dept. 5 0 0

    19 6800uF Capacitor Engineering Dept. 1 0 0

    20 100uH Inductor Engineering Dept. 1 3 3

    21 Fuse Holder Engineering Dept. 1 1 1

    22 863-1N5368BG Diodes-Zener 47V 5W Mouser 2 0.32 0.64

    23 1 Amp Fuse Engineering Dept. 1 0 0

    24 6-pin MTA connector Engineering Dept. 4 0.24 0.96

    25 3-pin MTA connector Engineering Dept. 6 0.12 0.72

    26 COM-00098 Omron Snap Action Switch SparkFun 2 1.95 3.9

    27 MDUSPCB MD US PCB Engineering Dept. 3 0 0

    28 MDPICPCB MD PIC PCB Engineering Dept. 1 0 0

    29 LM339 Quad Comparator Digikey 2 1.25 2.5

    30 COM-00527 12V Voltage Reg Engineering Dept. 1 0.5 0.5

    31 COM-00107 5V Voltage Regulator Engineering Dept. 2 0.5 1

    32 COM-00526 3.3V Voltage Regulator Engineering Dept. 1 0.5 0.5

    33 1-IDC2x5-F 2x5 IDC Female computercablestore 1 0.95 0.95

    34 Blue LED Engineering Dept. 2 0.25 0.5

    35 Photocell Digikey 1 1.75 1.75

    36 0

    37 0

    38 40-pin SIP Connector Engineering Dept. 8 1.25 10

    39 5k Bourns 3386 Trimmer Potentiometer Engineering Dept. 1 1 1

    Subtotal $213.68

    Tax Rate 7.75%

    Tax $16.56

    S & H 0

    Total $230.24

  • 7/27/2019 Massive Dynamic Final Report

    31/32

    31

    Gantt Chart:

    ID Task Name Start Finish Duration

    Mar 2009Feb 2009 Apr 2009

    22/2 29/38/3 5/41/3 19/4 26/422/315/315/2 12/4

    2 6w3/27/20092/16/2009Characterized sensors

    12 2w4/9/20093/27/2009Merge sensors and iRobot Create

    platform

    13 3w4/17/20093/30/2009Acquisition & Hardware Fabrication

    16 2.4w5/4/20094/17/2009Testing

    May 2009

    3/5 10/5 17/5

    3 4w3/13/20092/16/2009Distance Sensor

    4w3/13/20092/16/2009Ultrasonic Transducer

    1 0w2/16/20092/16/2009Project Start

    4

    24/5 31/5

    5 4w3/27/20093/2/2009IR Receiver

    0w3/5/20093/5/2009Proposal

    10

    8

    2w2/27/20092/16/2009Communication9

    6.8w4/2/20092/16/2009Software Development

    7

    3w3/19/20092/27/2009Movement

    11 2w4/2/20093/20/2009Sensor Algorithms

    6 4w3/27/20093/2/2009Color Sensor

    17 0w5/4/20095/4/2009Projects Ends

    0w4/6/20094/6/2009Final Oral Presentat ion14

    15 0w4/8/20094/8/2009Design Day

  • 7/27/2019 Massive Dynamic Final Report

    32/32

    Appendix C: Schematics

    Boost Converter Schematic:

    Ultrasonic Schematic: