Coin Identification Using Eddy Currentsciuec.weebly.com/uploads/3/9/1/6/39169121/coin... · 2018....

43
Coin Identification Using Eddy Currents  Second Semester Report Full Report By Frank Lindauer Mohammad Alhusainan Momin Garrouch Prepared to partially fulfill the requirements for ECE 402 Department of Electrical and Computer Engineering Colorado State University Fort Collins, Colorado 80523 Project advisor(s): Dr. George Collins Mr. Garrett Durland  Approved by: Dr. George Collins  

Transcript of Coin Identification Using Eddy Currentsciuec.weebly.com/uploads/3/9/1/6/39169121/coin... · 2018....

  • Coin Identification Using Eddy Currents  

    Second Semester Report

    Full Report

    By

    Frank Lindauer

    Mohammad Alhusainan

    Momin Garrouch

    Prepared to partially fulfill the requirements for ECE 402

    Department of Electrical and Computer Engineering

    Colorado State University

    Fort Collins, Colorado 80523

    Project advisor(s): Dr. George Collins

    Mr. Garrett Durland  

    Approved by: Dr. George Collins

     

  • Abstract Coin fraud continues to be a problem for any industry that relies on automatic coin identification and processing such as vending machines, change machines, car washes, and public laundries. For example, acceptance of foreign currency, which may have a lower exchange rate, or worth-less tokens or slugs, which have no value, directly impacts the bottom line of these business owners. Replacing the coin slots with debit or credit card readers may help to eliminate the coin fraud but also introduces additional security problems and cost (need access to data line or Wi-Fi connection) while limiting machine access to customers who have these cards.

    This project will demonstrate one of the many practical uses of eddy currents by designing, building, and testing a system that can identify the denomination of United States (US) coins based upon measured changes in the magnetic field caused by induced eddy current. These cir-cular electric currents are induced within the metallic coins as they roll into the magnetic field produced by a magnet. The induced eddy currents in turn produce a magnetic field that is oppo-site in direction to the field produced by the initiating magnets. These opposing forces work to slow the momentum of the coin as they continue to roll through the magnetic field. By timing the coin as it passes through the magnetic field, and collecting parameter data using different sensors, we can measure the effect that the induced eddy current has on the coin and in turn iden-tify the denomination of the coin.    

  • Table of Contents Abstract ..................................................................................................................................................... 2 

    Table of Contents ...................................................................................................................................... 3 

    List of Figures ............................................................................................................................................ 4 

    List of Tables ............................................................................................................................................. 5 

    List of Equations ........................................................................................................................................ 5 

    Chapter 1  Introduction .......................................................................................................................... 5 

    Chapter 2  Summary of Previous Work .................................................................................................. 7 

    Chapter 3  Project Details ....................................................................................................................... 7 

    Objectives.............................................................................................................................................. 7 

    Constraints ............................................................................................................................................ 7 

    Design Considerations........................................................................................................................... 7 

    What Went Right .................................................................................................................................. 8 

    What Went Wrong ................................................................................................................................ 8 

    Coin Ramp Construction & Design ........................................................................................................ 8 

    Circuit Design ...................................................................................................................................... 11 

    First Semester ..................................................................................................................................... 11 

    Second Semester................................................................................................................................. 12 

    LCD Screen .......................................................................................................................................... 12 

    Hall Effect Sensor ................................................................................................................................ 12 

    Electromagnet with Potentiometer .................................................................................................... 13 

    Microcontroller Programming ............................................................................................................ 16 

    First Semester ..................................................................................................................................... 16 

    Second Semester................................................................................................................................. 17 

    Testing Decisions, Procedures, and Results ........................................................................................ 18 

    First Semester ..................................................................................................................................... 18 

    Second Semester................................................................................................................................. 22 

    Chapter 4  Conclusions & Future Work ............................................................................................ 28 

    Conclusion ........................................................................................................................................... 28 

    Recommendations for continuation ....................................................................................................... 29 

    References .............................................................................................................................................. 29 

    Appendix A   Abbreviations ................................................................................................................. 30 

    Appendix B   Budget ............................................................................................................................ 31 

  • What was planned .............................................................................................................................. 31 

    Donations ............................................................................................................................................ 32 

    Estimate for labor ............................................................................................................................... 32 

    Total cost ............................................................................................................................................. 33 

    Funding ............................................................................................................................................... 34 

    Appendix C   Project Plan Evolution .................................................................................................... 35 

    Appendix D:  Programming Flow Chart ................................................................................................ 38 

    Appendix E   Microcontroller Code ...................................................................................................... 39 

    Acknowledgments ................................................................................................................................... 43 

     

    List of Figures Figure 1: Coin Ramp with Circuit................................................................................................................... 9 Figure 2: Close Up of Acrylic Guide Rails ....................................................................................................... 9 Figure 3: Close up of photo interrupter and LCD placement ...................................................................... 10 Figure 4: Close up of Hall Effect sensor ...................................................................................................... 10 Figure 5: Final Coin Ramp System Design ................................................................................................... 11 Figure 6: Connection from single photo‐interrupter to Arduino board ..................................................... 11 Figure 7:  Connections from two photo‐interrupters to Arduino board .................................................... 12 Figure 8: Hall Effect sensor [4] .................................................................................................................... 12 Figure 9 : Hall Effect sensor pin configuration [5] ...................................................................................... 13 Figure 10: Commercial electromagnet we bought ..................................................................................... 14 Figure 11: First electromagnet we built – 500 turns! ................................................................................. 14 Figure 12: Illustration of Eddy Currents in Different Transformer Cores [7] .............................................. 15 Figure 13: Second electromagnet we built ................................................................................................. 15 Figure 14: Two electromagnets‐one for each side of the acrylic track....................................................... 15 Figure 15 Final Circuit Design ...................................................................................................................... 16 Figure 16: Photo‐interrupter Schematic [8] ................................................................................................ 16 Figure 17: Common Anode RGB LED [11] ................................................................................................... 18 Figure 18: First Semester Quarter Timing Data Scatter Plot ....................................................................... 19 Figure 19: First Semester Dime Timing Data Scatter Plot ........................................................................... 20 Figure 20: First Semester Nickel Timing Runs Scatter Plot ......................................................................... 20 Figure 21: First Semester Penny Timing Data Scatter Plot ......................................................................... 21 Figure 22: First Semester All Denomination Timing Data Scatter Plot ....................................................... 21 Figure 23: Standard Normal Curve for Quarter .......................................................................................... 22 Figure 24: Second Semester Quarter Timing Runs Scatter Plot.................................................................. 24 Figure 25: Second Semester Dime Timing Runs Scatter Plot ...................................................................... 24 Figure 26: Second Semester Penny Timing Runs Scatter Plot .................................................................... 25 Figure 27: Second Semester Nickel Timing Runs Scatter Plot .................................................................... 25 Figure 28: Second Semester All Denomination Timing Data Scatter Plot .................................................. 26 Figure 29: Standard Error of Mean for all four coin denominations .......................................................... 27 Figure 30: Standard deviations of timing data by denomination and mint year ........................................ 28 

  • Figure 31 : Total Project Hours ................................................................................................................... 33 Figure 32: Final Project Cost ....................................................................................................................... 33 Figure 33 : Programming Flowchart ............................................................................................................ 38 

    List of Tables Table 1 : First Semester Coin Timing Data by Denomination ..................................................................... 19 Table 2: Second Semester Coin Timing Data by Denomination ................................................................. 23 Table 3: Metal Composition of U.S. Coins [12] ........................................................................................... 27 Table 4 : Budgest Estimations ..................................................................................................................... 32 Table 5 : Project Timeline ‐ Sept. 17, 2014 ................................................................................................. 35 Table 6 : Project Timeline ‐ Oct. 8, 2014 ..................................................................................................... 36 Table 7 : Project Timeline ‐ Nov. 6, 2014 .................................................................................................... 37 

    List of Equations Equation 1 : Faraday's Law ............................................................................................................................ 5 Equation 2 :A1301 Hall Effect sensor voltage to field strength conversion ............................................... 13 Equation 3: Magnetomotive Force [6] ........................................................................................................ 13 Equation 4: Standard Error of theMean ..................................................................................................... 26 Equation 5: Sample Standard Deviation ..................................................................................................... 26 

    Chapter 1 Introduction Coin fraud continues to be a problem for any industry that relies on automatic coin identification and processing such as vending machines, change machines, car washes, and public laundries. For example, acceptance of foreign currency, which may have a lower exchange rate, or worth-less tokens or slugs, which have no value, directly impacts the bottom line of these business owners.

    Replacing the coin slots with debit or credit card readers may help to eliminate the coin fraud but also introduces additional security problems and cost (need access to data line or Wi-Fi connec-tion) while limiting machine access to customers who have these cards.

    The main theory behind our project is based on electromagnetics, specifically Faraday’s Law of Induction and Lenz’ Law. Faraday’s Law governs the interaction between a conductor and a magnetic field that produces an electromotive force otherwise known as electromagnetic induc-tion. The induction is equal to the negative rate of change in the magnetic flux relative to time [1].

    The equation for Faraday’s Law is

    Equation 1 : Faraday's Law

    Lenz’s Law states that an induced electromotive force always gives rise to a current whose mag-netic field opposes the original change in magnetic flux [2]. His law basically added the nega-tive sign in front of Faraday’s Law of Induction.

  • Eddy currents are used in a wide variety of applications throughout industry such as metal detec-tors, conductivity meters for non-magnetic metals, non-destructive testing, coating thickness measurements, proximity sensing and many others.

    This project will demonstrate one of the many practical uses of eddy currents by designing, building, and testing a system that can identify the denomination of United States (US) coins based upon measured changes in the magnetic field caused by induced eddy current. These cir-cular electric currents are induced within the metallic coins as they roll into the magnetic field produced by a permanent magnet. The induced eddy currents in turn produce a magnetic field that is opposite in direction to the field produced by the permanent magnets. These opposing forces work to slow the momentum of the coin as they continue to roll through the magnetic fields.

    By timing the coin as it passes through these magnetic fields, we can measure the effect that the induced eddy current has on the coin and in turn identify the denomination of the coin.

    Our system design will consist of a display ramp that will channel the coin into a narrow chute that will guide the coin past two optical sensors, also known as photo-interrupters, and a magnet-ic field.

    As the coin enters the ramp it will pass through a photo-interrupter. A photo-interrupter consists of a diode that emits a ray of light and a sensor that receives the ray of light. When the coin passes through the photo-interrupter it blocks the ray of light and records the time via the micro-controller. As the coin rolls down the ramp, it will pass through a magnetic field generated ei-ther by permanent magnets harvested from a hard disk drive or an electromagnet. As the coin rolls through the magnetic field, the rotational motion of the metallic coin induces eddy currents on the surface of the coin. The eddy currents in turn induce a magnetic field that opposes the field of the permanent magnets thus slowing the momentum of the rolling coin. After the coin leaves the magnetic field, it will then pass through a second photo-interrupter which will record the stop time again via the micro-controller.

    The micro-controller measures how long the coin takes to pass through both photo-interrupters. Different types and amount of metals disturb the magnetic field in different ways, for instance, a larger coin contains more metal and therefore will disturb the field more than a smaller one. A quarter will disturb the magnetic field differently than a dime and will therefore take longer to roll down the ramp. By using the timing and magnetic field data, we can define an algorithm that will determine the denomination of the coin and will send that information to a liquid crystal display (LCD) screen displaying the identity of the coin as well as the time the coin took to roll the length of the ramp. We are expecting to see a distinct time separation between the coin de-nominations

    Within this coin identification process, we chose to add a Hall Effect sensor to potentially help us further differentiate between the coin denominations by the different impact each coin makes on the electromagnetic field. The Hall Effect sensor specifically provides information regarding the type of magnetic pole and magnitude of the magnetic field.

    The use of different sensor types and different measurement parameters will make our detection and identification system more robust and less prone to error and reduce the risk of fraud. An-other benefit of this system is its robustness, as it can successfully operate in harsh environments.

    Chapter 2 contains the summary of our research and interest into the background of our project.

  • Chapter 3 contains the details of the work performed on the project broken down into major pro-ject components such as circuit design and data analysis. Chapter 3 also contains additional pro-ject information such as our overall project goals and constraints that we are working within.

    Chapter 4 contains our summary of the project for the first semester as well as our project plans for the second semester.  

    Chapter 2 Summary of Previous Work Vending machines have been around for a long time as the first coin-operated machines that dis-pensed tobacco were being operated as early as 1615 in the taverns of England [3]. Lots of re-search has been done to improve the quality, size, and the inner working mechanisms of these machines. We are not expecting our project design to revolutionize the industry but we were in-trigued by the operation of the coin identification mechanism and the engineering technology behind it. In particular, this video piqued our interest, How Stuff Works: Deconstructed Vending Machine. In short, we are using our senior design project as a learning experience versus an en-trepreneurial endeavor.  

    Chapter 3 Project Details Objectives

    Demonstrate the use of eddy current to identify the denomination of United States coins based upon measured changes in the magnetic field caused by induced eddy current.

    Design, build, and test a coin ramp to demonstrate system used to identify different coins.

    Add a Hall Effect sensor to measure changes in the magnetic field strength.

    Program microcontroller to linearize, offset, and scale data received from the photo inter-rupters and Hall Effect sensor.

    Integrate the sensors, LCD screen, RGB LED, and the microcontroller with the circuit.

    Build and use an electromagnet to provide a larger, variable magnetic field.  

    Constraints

    Our coin identification system will be designed to work only with U.S. currency.

    Minimizing the power consumption of the electronics.

    Minimize physical size of electronics and circuitry in anticipation of small available space in commercial application.

    Overall project budget limited to ≤ $450.00, minimize per unit cost of electronics and cir-cuitry.

    Design Considerations

    Proper coin ramp height/incline angle.

  • Sensor location within coin path.

    Choosing ideal location for HDD magnets/electromagnet.

    Ideal coin channel width.

    Delivering a minimum magnetic field strength of 1600 Gauss from electromagnet.

    Proper wire soldering to aid system mobility and minimize damage to circuitry.

    What Went Right

    Successfully induced eddy current in coins.

    Experimentally determined optimum angle for ramp that balanced eddy current force and gravitational force.

    Determined magnitude of magnetic field necessary to affect coins enough to differentiate them.

    Developed algorithm to successfully determine denomination of coin > 90% of time.

    What Went Wrong ● Failed to minimize friction applied to coins due to the acrylic channel. ● Magnetic field produced by electromagnet failed to affect coins as well as HDD magnets. ● Some overlap in coin timing data still exists due to the following factors:

    ○ Similarities of coin geometry & weight (dime & penny). ○ Inconsistencies in coin release mechanism. ○ Fixed magnetic field not strong enough to affect all coins. ○ Surface imperfection in coin channel.

    Coin Ramp Construction & Design The coin ramp is one of the primary parts of the design as it is used to demonstrate the operation of our coin identification system. We built it so we could perform consistently repeatable tests on the coin by rolling it down the ramp. The coin ramp is built from wooden materials with two long pieces of acrylic that work as a guide for the rolling coins. On the ramp we placed two rare earth permanent magnets on the outside middle section of the acrylic track to produce the mag-netic field and two photo-interrupters to calculate the time it took the coin to pass through the ramp.

    Through the process of building the ramp we faced a few difficulties related to the physical oper-ation of the ramp.

    One such difficulty was finding the correct rolling angle and ramp height, because the steeper the ramp gets the less effect the magnetic field will have because the gravity effect will make the

  • coin roll faster through the field. Through numerous field tests, we determined the best angle for the ramp that balanced the influence of the magnetic field while maintaining an angle that en-sured the coins rolled the entire way to the bottom of the ramp.

     Figure 1: Coin Ramp with Circuit

    Another difficulty that arose was with the acrylic guide rails on the ramp. The quarter, dime, nickel and penny are all different widths, with the nickel being the widest and the dime the nar-rowest. We were trying to provide as narrow of a guide as possible in order to limit the side to side movement of the coin as it rolled down the ramp. The less side to side movement the coin had, the more consistent the timing results would be. We encountered tests where the nickel would get stuck in the guide rails at various spots on its way down. We detached and reattached the guide rails many times to remove imperfections in the acrylic surfaces and to provide the proper spacing in between the guides to best accommodate all of the coins. As of now, the guide rails are wide enough to not inhibit the free rolling motion of the nickel but are not tight enough to keep the dime from moving from side to side.

     Figure 2: Close Up of Acrylic Guide Rails

    Hard Drive Magnets Photointerrupter 

    Photointerrupter misaligned with acrylic rails 

    Acrylic rails to guide coins. 

  •  

    Figure 3: Close up of photo interrupter and LCD placement

     

    A third difficulty was trying to physically attach the photo-interrupters to the ramp. The initial ramp was built with accommodations to mount the photo-interrupters on the extreme outer edges of the ramp. However, this would have required us to place or drop the coins into the guide track and we felt we needed a release mechanism that would provide us with consistently repeatable results and the overall design of the ramp was changed. The ramp was increased in length from about 2 feet to 2.5 feet to allow for placement of a release mechanism. The photo-interrupter that was to be placed on the upper end of the track was then placed a few inches from the end. A short section of guide track was added to the very top of the ramp, holes were drilled in the acryl-ic to allow a metal wire to be inserted which will act as a release gate.

    Another issue we faced was finding the best location for the Hall Effect sensor, so we could measure the strength of the magnetic field experienced by the rolling coins. The Hall Effect sen-sor was too sensitive, and we had to choose a fixed location to make sure it doesn't move a lot. The figure below shows the location we chose for the sensor, so it could measure the field be-tween the magnets. We were getting constant readings from the sensor because we were using static magnets.

     

    Figure 4: Close up of Hall Effect sensor

     

    Photointerrupter aligned with acrylic rails 

    LCD screen to dis‐play data

    Hall Effect sensor to detect magni‐tude of magnetic field 

  • The last issue we faced was the components wiring. We had to make sure that we have strong wire connections for the sensors, LCD screen and the LED, also make them visible on the ramp to be presented in the senior design showcase. We soldered the connections of the Hall Effect sensor, the LCD screen, the RGB LED, and many of the wires to extend their lengths so that we could make the assembly/disassembly of the circuit easy and robust.

     

    Figure 5: Final Coin Ramp System Design

     

    Circuit Design First Semester Circuit design in our project has progressed through two phases. First of all, we had our Arduino board connected to one photo interrupter with two pull down resistors to get better readings as shown in the figure below:

     

    Figure 6: Connection from single photo-interrupter to Arduino board

    Coin release area

    RGB LED for visual indication of coin identified 

    LCD screen for data display 

    Hall Effect sensor Lower photo interrupter 

  • In the second phase, we duplicated the components we had from the first circuit to get better readings and make it easier to hook it up to the Arduino board. An example of the circuit is shown in the figure below.

    Figure 7: Connections from two photo-interrupters to Arduino board

    Second Semester LCD Screen One of the first things we did was to integrate an LCD monitor with the Arduino board. We de-cided to use a serial type monitor to reduce the number of connections we needed to make be-tween the monitor and the LCD. The serial connection called for 3 connections, one to power, one to ground, and one to the transmit (Tx) pin on the Arduino. We soldered the wiring connec-tions made to the LCD monitor to ensure the integrity of the connections. We used wires ap-proximately 8 inches in length to allow us to remotely mount the screen on the coin ramp to easi-ly display the data during our E-days presentation.

    Hall Effect Sensor Theory: The Hall Effect provides information regarding the type of magnetic pole and magnitude of the magnetic field. The output voltage, called the Hall voltage, (VH) of the basic Hall Element is directly proportional to the strength of the magnetic field passing through the semiconductor material (output ∝ H).  

     

    Figure 8: Hall Effect sensor [4]

    We added a Hall Effect sensor to our circuit and used it to capture the magnetic field strength to add another variable to use to identify the coins. We chose to use the A1301 continuous-time, ratiometric, linear IC sensor from Allegro Microsystems. This sensor provides an output voltage that is proportional to the magnetic field strength that it detects. We connected the output pin of

  • the sensor to one of the analog input pins of the Arduino. The output sensitivity of the A1301 is 2.5 mV / Gauss. The 5 volt output of the Arduino can be broken down into 1024 analog steps leading to the following conversion formula we used to calibrate and program the sensor;

     

    Equation 2 :A1301 Hall Effect sensor voltage to field strength conversion

     Figure 9 : Hall Effect sensor pin configuration [5]

     

    Electromagnet with Potentiometer Theory: The amount of flux available in any given magnetic circuit is directly proportional to the current flowing through it and the number of turns of wire within the coil. This relationship is called the magnetomotive force (mmf) and is defined as:

    Equation 3: Magnetomotive Force [6]

    The goal we set out to accomplish with the electromagnet was to create a higher strength mag-netic field in comparison to the field generated by the hard drive magnets and then vary the strength of the magnetic field using a potentiometer. We intended to find a magnetic field strength that would be unique to each coin, in essence, an individual magnetic signature that could be used as another variable to help identify the coins.

    The first electromagnet that we tried was a commercially made one. It had a lifting strength of 10 kg (2.2lbs) and was designed to operate at 12V DC. We tried different power supplies with this electromagnet, a 1A benchtop supply, a 5A benchtop supply, and a 12V 5Ah battery. The largest magnetic field strength we measured was around 100 gauss, over 10 times smaller than the field generated by the hard drive magnets which was 1100 gauss. The strongest field was produced with the battery but it also caused the electromagnet to heat up the most. We were worried about the long term performance of the electromagnet at high heat because in general, the magnetic flux decreases at higher heat levels and increases at lower heat levels.

  •  

    Figure 10: Commercial electromagnet we bought

    We met with Professor Marconi to get some construction ideas for an electromagnet that we could build on our own. We wrapped 16 gauge magnet wire around a 12 inch length of PVC pipe that contained an 8 inch long, ¾” diameter iron bolt. We were able to get approximately 500 turns using multiple layers. Again, we powered the electromagnet with the various power supplies mentioned above and unfortunately, received even worse results. The maximum meas-ured magnetic field strength from this electromagnet was only around 50 gauss. As expected, the greatest field strength was measured at the center point of each end of the electromagnet core.  

     

    Figure 11: First electromagnet we built – 500 turns!

    We showed our magnet to Professor Marconi and he suggested a few things, one - making the turns much tighter and closer together and holding the different layers in place using packing tape, two - changing from a solid iron core to welding rods, and three - making the electromag-nets smaller to help concentrate the field.

    The change in core material from a solid metal to individual welding rods would help to elimi-nate any eddy current losses that may be occurring in the solid core.

    The welding rods would mimic a laminated transformer core, which use very thin strips of insu-lated (usually with varnish) metal joined together to produce a solid core. The laminations in-

  • crease the resistance of the iron-core thereby increasing the overall resistance to the flow of the eddy currents, so the induced eddy current power-loss in the core is reduced, and it is for this reason why the magnetic iron circuit of transformers and electrical machines are all laminated. [7]. This concept is illustrated in the figure below.

    Figure 12: Illustration of Eddy Currents in Different Transformer Cores [7]

     

    Figure 13: Second electromagnet we built

    After our second meeting with Professor Marconi, we also met with the graduate students in the Electromagnetic lab to get some additional ideas about how we could increase the magnetic field strength. The main take away from that meeting was to try using two electromagnets, one placed on each side of the acrylic track, similar to the arrangement we used with the hard drive magnets.

    We built two smaller electromagnets, using lengths of PVC pipe cut to approximately 2.5 inches in length. For the core, we used ⅛”steel welding rods and we were able to get 75 turns of 16 gauge magnet wire on each magnet. With this configuration, we were able to produce a field of 1600 gauss, our highest generated field yet. We soldered one of the leads from each magnet to-gether to allow us to place one on each side of the acrylic track and power them both from the same power supply.

     

    Figure 14: Two electromagnets-one for each side of the acrylic track

    Welding rod core 

  • However, when we placed the magnets on either side of the acrylic track, there was no discerna-ble effect on the coins. We think this was because of the separation distance created by the thickness of the acrylic track as the magnetic field strength is proportional to 1/r2 with r repre-senting the distance from the magnet.

    We were able to successfully connect a potentiometer to the double electromagnet and vary the strength of the field but because of the sharp decrease of the magnetic field as the distance from the electromagnet increases, varying the field had no effect on the coins.

    Figure 15 Final Circuit Design

     

    Microcontroller Programming First Semester The microcontroller programming started with initializing the photo-interrupters and making them interact with the microcontroller. We used the 5v pin on the Arduino as the power pin for the photodiode and connected the other side to one of the digital pins, and the same for the tran-sistor on the other side as shown in figure 5. Then we wrote some code that allowed the sensor to capture the time in milliseconds that when an object passed through the sensor. We were able to observe the photo-interrupter communicating with the controller through the serial monitor. When there is nothing passing through the photo interrupter we get a reading of a 1024 and when the coin passes through the sensor the reading changes to very low values.

     

    Figure 16: Photo-interrupter Schematic [8]

  • The second part of the programming was calculating the time difference between the two inter-rupts. We implemented it using a built-in function inherent to most of the Arduino boards called “millis()” [9], as this function starts a timer when we upload the code to the board.

    We used interrupt service routines (ISRs) to ensure that the time recorded by the microcontroller was as accurate as possible. It works by recording the time when the coin passes through the first interrupter and records the time through the second interrupter and then calculates the time difference between both the recorded times. For example, if the coin passed through the first photo-interrupter after 200 seconds of running the program and went through the second after 202 seconds which means that the coin took 2 seconds to pass through the ramp.

    Second Semester After successfully integrating the photointerrupters with the microcontroller in the first semester, we had a lot of additional programming to complete during semester number 2. Our code is pre-sented in Appendix E.

    One of the first things we did was to integrate an LCD monitor with the Arduino board. Our dis-play was a 16x2 monitor, meaning it could display 2 rows of up to 16 characters each. We used the serial LCD library, serLCD [10], to communicate with our monitor. Before we could use the library, we had to add a #include file and we also needed to create a serLCD object. Once that was accomplished, when we wanted to send data to the display, we first selected the line we wanted our data to print on and then we printed the actual data or text. We changed the splash screen to display ‘Coin ID Project’ every time the monitor started up to add a personalized as-pect. One piece of troubleshooting we did with regards to the monitor was to add 1 second de-lays between print commands to slow the rate at which the monitor changed from one display to another. These delays allowed you to read and comprehend the data before the next piece of in-formation was shown. During the E-days presentation, we displayed the time it took the coin to traverse the ramp in milliseconds, the denomination of the coin that was identified i.e. quarter, dime, nickel, penny, and the strength of the magnetic field.

    We added a Hall Effect sensor to our circuit and used it to capture the magnetic field strength to add another variable to use to identify the coins. We connected the output pin of the sensor to one of the analog input pins of the Arduino. We calibrated the sensor by recording the analog output pin value when no magnetic field was present. To determine the actual magnetic field strength, we subtracted the ‘no field’ value from the value detected by the sensor. The A1301 sensor can also detect the pole orientation of the magnetic field i.e. north or south. We added code that could display the field orientation but ultimately chose not to display that value on the LCD monitor.

    To further distinguish the different coins that were being detected by our machine, we added a common anode type RGB LED to our ramp. This LED lamp has the ability to display many dif-ferent colors using the same LED which saved us from having to wire and mount 5 different LEDs on our ramp. By using the pulse width modulation (PWM) pins on the Arduino, we were able to vary the signal to each LED pin to produce a different color for each coin denomination: green for a quarter, blue for a dime, white for a penny, purple for a nickel, and red for an un-known coin. For instance, to display red on the LED, we sent 255 to the red pin, and 0 to both the blue and green pins. This added a nice visual indicator to our ramp that reinforced the infor-mation shown on the LCD screen.

  •  

    Figure 17: Common Anode RGB LED [11]

    The core of our code is a multi-tiered if-else statement that uses the coin timing data that we rec-orded by testing hundreds of coins on our ramp. By averaging the coin roll times for each de-nomination, we were able to come up with timing ranges that successfully identified the correct coin over 95% of the time.

    Testing Decisions, Procedures, and Results First Semester The way we intend to program the controller to identify a rolled coin is by defining a unique roll time interval for each coin type within the code so that if a random coin is rolled and its roll time happens to fall in the range of one of the four coin types then the microcontroller will identify it as the coin it matched the range of.

    In order to define the time ranges for the four different coins, we tested ten different rolls for each coin and recorded the maximum (max) and the minimum (min) values for all coins which should define the time interval for each coin type. To further analyze our data, we calculated the mean and standard deviation values for the data of the different coins.

    Table 1 below lists all the data gathered for the four coin types and also shows the existence of time interval overlap between the following coins:

    Quarter & Dime

    Dime & Nickel

    Dime & Penny

    Penny & Nickel

    Run #  Quarter Time (s)  Nickel Time (s)  Dime Time  

    (s)

    Penny Time  

    (s)

    1  2.68  2.19 2.37  2.37 2  2.72  2.09 2.30  2.42 3  2.93  2.11 2.60  2.25 4  2.68  1.99 2.54  2.43 5  2.86  2.16 2.64  2.34 6  2.94  2.38 2.80  2.28 

  • 7  2.62  2.20 2.81  2.24 8  2.82  2.25 2.47  2.47 9  2.68  2.13 2.60  2.59 

    10  2.82  2.20 2.60  2.59 Min  2.62  1.99 2.30 2.24

    Max  2.94  2.38 2.81 2.59

    Mean  2.775  2.17 2.573 2.398

    Stand. Dev.  0.11385  0.10371 0.16391 0.12709

    Time Range 

    [MIN,MAX] 

    [2.94-2.775]  [1.99-2.38]  [2.30-2.81]  [2.24-2.59] 

    Table 1 : First Semester Coin Timing Data by Denomination

    This time overlap will create confusion within the microcontroller leading to false coin detection in a sense that it would be possible for the microcontroller to read a Quarter as a Dime and vice versa.

    Figures 16 through 19 below show the scatter plots for each of the four coin types.

     Figure 18: First Semester Quarter Timing Data Scatter Plot

  •  

    Figure 19: First Semester Dime Timing Data Scatter Plot

     

    Figure 20: First Semester Nickel Timing Runs Scatter Plot

    Nickel

  •  

    Figure 21: First Semester Penny Timing Data Scatter Plot

     

    We finally plot all gathered data for the four different coin types on one graph to check whether the min and max interval of the coins overlap or not. Unfortunately it turns out that an overlap exists between multiple coin types. You can see the results in the figure below.

     

    Figure 22: First Semester All Denomination Timing Data Scatter Plot

     

    We believe that this time overlap issue is a result of the high standard deviation values for the different coins. Lowering these standard deviation values of each coin is the key to tackling this issue especially knowing that each coin type has a unique mean value as seen in Table 1.

  • The figure below shows the standard normal curve of the Quarter data. Since the probability of having a reading within one standard deviation from the mean is 68.3%, decreasing the standard deviation will force readings to have greater probability of lying closer to the mean value, there-fore leading to more accurate results. Improving the accuracy of our readings will result in smaller differences in the Min and Max values of each coin.

    Throughout the data gathering process, we noticed that when the coins roll down in the ramp they randomly get slowed down at some points. After closely examining our ramp structure, we notice that the acrylic surface is actually rougher than we thought it would be. This eventually results in a friction force exerted on the coin whenever it comes into contact with the acrylic’s surface. We believe that smoothing out the acrylic’s surface would significantly reduce the standard deviation for each coin to the point where the min and max values would be close enough to the mean values to provide us with unique time ranges for each coin.

     

    Figure 23: Standard Normal Curve for Quarter

     

    Second Semester During the beginning of the second semester, our main concern was to obtain a unique time bracket for each coin type and overcome the issues we were facing during the first semester. We went ahead and took all the possible failure causes into consideration. We first started by smoothing out the surface of the coin runway as well as the acrylic sides to minimize the friction each coin faces when rolling down as much as possible.

    Changing the ramp’s height was another factor we took into consideration. We tried to rely on each coins weight characteristics to further differentiate between the coins roll time. We then went ahead and added two electromagnets that we created to slow down each coin by a certain amount of time depending on its metal composition.

    In addition to that, went a step ahead and created a coin launching system where the coin would roll down the ramp only by pulling the wire that initially keeps the coin still at the top of the ramp. We believe that this will create a more accurate and consistent reading for the coins espe-cially when we’re trying to be three numbers after the zero accurate.

  • By implementing these modifications to our system, we successfully managed to make our sys-tem work for more than 95% of the time.

    Table 2 below lists all the data gathered for the four coin types after the modifications made on the ramp. The new min and max values as well as the difference between them is recorded at the bottom of the table.

     

    Table 2: Second Semester Coin Timing Data by Denomination

    Figures 22 through 25 below show the new scatter plots for each of the four coin types where we can notice that the scatter plots for all the 4 coins are more compact and lie closer to each other when compared to the ones of last semester.

  •  

    Figure 24: Second Semester Quarter Timing Runs Scatter Plot

     

    Figure 25: Second Semester Dime Timing Runs Scatter Plot

  •  

    Figure 26: Second Semester Penny Timing Runs Scatter Plot

     

    Figure 27: Second Semester Nickel Timing Runs Scatter Plot

    Figure 26 below shows all the readings from different coin denominations in one graph. We can notice from the graph that a minor overlap between the dime and the penny still exists. We be-

  • lieve that this is happening due to similarities within the geometry of the coins as well as their metallic compositions.

     

    Figure 28: Second Semester All Denomination Timing Data Scatter Plot

    Running mean standard error tests on the coins showed that the quarter had the biggest error within its readings. This means that the quarter had the biggest value of standard deviation from the mean. To calculate the standard error of the mean, we used the following equation:

     

    Equation 4: Standard Error of theMean

    SEM = standard error of the mean

    s = sample standard deviation

    n = size (number of observations) of the sample

    To calculate the sample standard deviation we used the following formula:

     

    Equation 5: Sample Standard Deviation

    s = sample standard deviation

  • x1, ..., xN = the sample data set

    x̄ = mean value of the sample data set

    N = size of the sample data set

    Figure 27 below shows the standard error of the mean of the four coins.

     

    Figure 29: Standard Error of Mean for all four coin denominations

    Looking back at table 2 you notice that we grouped the readings for each coin type based on the year it was minted since coins minted in a different year have different metal compositions as shown in the table below.

    Table 3: Metal Composition of U.S. Coins [12]

  • Figure 28 below shows the Standard deviations of timing data by denomination and mint year. The most accurate coin was the 1972 Nickel where it had the most consistent readings of all the coins.

     

    Figure 30: Standard deviations of timing data by denomination and mint year

    Chapter 4 Conclusions & Future Work Conclusion Throughout the previous semester we failed to differentiate between the four coin denominations due to the ramp imperfections we had. In this semester we successfully overcame these issues and managed to get correct readings of the coins for more than 95% of the time. We strongly be-lieve that relying on the coin roll time isn’t necessarily the best mechanism for coin detection due to similarities within coin weight and geometries.

    Although adding more magnets as well as more photointerrupters to our system might lead to more accurate readings, we believe that the most accurate way to correctly identify coins would be by using a combination of a high proximity sensor and a digital imaging sensor. The high proximity sensor would act as a first checkpoint to identify the coins based on their metal com-positions, whereas the digital imaging sensor would act as a second checking point to further confirm the coin identity and verify that it’s not a fake or foreign coin by scanning the physical pattern on the coins surface and comparing it to a digital image kept on file.

    Building these two sensors and programing them would be very challenging and complicated, but it would certainly be a great challenge for any students willing to continue with this project for their senior design.

    All in all, we believe that this senior design project was a very fruitful experience where we had the chance to apply our knowledge from many classes in one project. It was also a great oppor-

  • tunity to prepare us for the work soon to come in the real world and it allowed us to get a feel for some of the challenges we might face during our careers.  

    Recommendations for continuation ● Etch circuit on circuit board. ● Mechanically sort coins into different bins. ● Make system compatible with other foreign coins. ● Involve a high proximity sensor to possibly detect coin composition.

    References  

    [1]   "Faraday's Law of Induction," [Online]. Available: http://en.wikipedia.org/wiki/Faraday%27s_law_of_induction..

    [2]   "Lenz's Law," [Online]. Available: http://en.wikipedia.org/wiki/Lenz%27s_law.

    [3]   "Vending Machine History," [Online]. Available: http://en.wikipedia.org/wiki/Vending_machine.

    [4]   "Hall Effect," [Online]. Available: http://www.electronics-tutorials.ws/electromagnetism/hall-effect.html.

    [5]   "Hall Effect Pin Out," [Online]. Available: ://www.google.com/url?q=http%3A%2F%2Fbildr.org%2Fblog%2Fwp-content%2Fuploads%2F2011%2F04%2Fus1881-400x295.png%3Fwidth%3D500&sa=D&sntz=1&usg=AFQjCNFwS40w1g_vwr4wFTDHvRtmbi0n0g.

    [6]   "Electromagnets," [Online]. Available: http://www.electronics-tutorials.ws/electromagnetism/electromagnets.html.

    [7]   "Electromagnetic Induction," [Online]. Available: http://www.electronics-tutorials.ws/electromagnetism/electromagnetic-induction.html.

    [8]   "Utopia Mechanicus," [Online]. Available: : http://www.utopiamechanicus.com/article/arduino-photo-interruptor-slotted-optical-switch/ ..

    [9]   "Arduino Millis Function," [Online]. Available: http://arduino.cc/en/reference/millis .

    [10] "Arduino Serial LCD Library," [Online]. Available: http://playground.arduino.cc/Code/SerLCD.

    [11] "RGB LED Fade," [Online]. Available: https://arduino-info.wikispaces.com/YourDuinoStarter_RGB-LED-Fade.

    [12] "Coin Metal Composition," [Online]. Available: http://www.usmint.gov/about_the_mint/?action=coin_specifications.

     

  • Appendix A Abbreviations  

    Wi-Fi Local area wireless internet technology

    US United States

    LCD Liquid Crystal Display

    USB Universal Serial Bus

    PC Personal Computer

    ECE Electrical and Computer Engineering

    CSU Colorado State University

    MMF Magnetomotive Force

    PWM Pulse Width Modulation

    PVC Polyvinyl Chloride

    RGB Red, Green, Blue

    LED Light Emitting Diode

    HDD Hard Disk Drive

    Tx Transmit

    DC Direct Current

    E-days Engineering Days

    IC Integrated Circuit

    VH Hall Voltage

    Ah Amp hour

    ISR Interrupt Service Routine

    SEM Standard Error of Mean

     

     

     

     

       

  • Appendix B Budget What was planned The preliminary studies made on the budget at the beginning of the semester ended up being more overpriced comparing to what we ended up paying to this point. When it comes to buying any product, there is always a tradeoff between price versus quality. The common idea that priced products usually provide better quality than cheaper ones is mostly true. Electrical appli-ances is one of the best examples to prove the idea right where more expensive products are usu-ally more durable, reliable, and even more efficient when comparing them to cheaper ones.

    We believe that finding the right balance between price and quality is the key when it comes to making the right product decisions and potentially avoid extra costs due to failures that will in-crease the overall project cost. In order to maintain a low project cost while maintaining good project quality, we made sure to extensively study each component individually before we actu-ally proceeded in buying it. As part of our planning our budget, we went ahead and compared our expected budget while using the cheapest components off the market versus the expected budget while using very expensive component as shown in table A.1 and A.2 respectively.

    Results for both budgets we’re very different as expected and the two budget models are not what we want to be ending up with. As mentioned earlier we looked for the best balance that would fit our needs. The initial project budget we came up with at the beginning of the semester is shown in Table A.3. We all agreed to the fact that this budget plan is tentative and is flexible to any changes that we might face throughout the project.

    As we initially expected, changes did indeed come up during the course of the project which ended up shaping our budget as well as the total cost of the project differently. Some of these changes were due to project decision changes and others were a result of part failure. Donations also had some minor impact on our budget which will be discussed later on. The only decision related changes made were regarding the LCD where we initially intended to buy a Chinese manufactured 16x2 LCD which was Arduino compatible, until our industry supervisor suggested buying the Sparkfun 16x2 LCD which he thought would be more reliable based on his experi-ence.

    As stated earlier, part failure also had an impact on our total cost due to bad decision making. The decision of buying a fairly cheap generic Arduino board turned out to be not very successful since the board’s USB port failed to work after 2 weeks of use only. We ended up buying anoth-er Nano board which was almost $10 more expensive.

  •    

    Inexpensive Budget  Brand Name Budget Realistic Budget

    Table 4 : Budgest Estimations

    Donations Run PC Computers and Repair was very kind to donate one of their unused hard drive magnets to our project. They were very cooperative and they also offered to donate more parts if needed. The donated magnet was worth $7. We used the donated hard drive to replace the need of buying magnetic cores which helped in lowering the total project cost in a small factor. Our industry advisor, Mr. Garrett Durland, also donated two hard drive magnets to our project at the end of the first semester.

    Estimate for labor The total hours per person spent on this project up to this point are expected to be around 292 hours. The breakdown of the total hours is as follows:

    ● 120 hours were spent on research ● 45 hours were spent on building and reconfiguring the ramp ● 33 hours were spent on building the circuit and connecting all hardware (i.e. sensors,

    LCD, microcontroller, magnets)

    ● 26 hours spent on hardware testing ● 68 Hours were spent on programming the microprocessor

     

  •  

    Figure 31 : Total Project Hours

    The total project cost was not affected by the labor hours since we’re the project owners and we’re serving our own project without hiring anyone else to do any labor or non-labor task.

    Total cost After taking the incurred losses as well as donations and plan changes into consideration, the new project total can be calculated as shown in the spreadsheet in Table 4 below. The total amount paid at this point totaled $123 including incurred losses from the first microcontroller. The spreadsheet also shows the second semester as well as the total expected project cost which turned out to be $29 and $152.29 respectively.  

     

    Figure 32: Final Project Cost

  • Funding We’re currently funding our project through the ECE student project fund which assigns $150 for each student working on ECE senior design project. Payments were initially made out of our pockets but we’re currently in the process of getting our refund through the ECE department at CSU.    

  • Appendix C Project Plan Evolution

    Phases  Start Date

    End date

    Group Member  Duration

    (Fall Semester Plan) 

    Phase 1: Develop design parameters, and de-sign the eddy current sensor. Model it using Pspice or cadence. 

    9/17/14 10/8/14 Mohammad  3weeks

    Phase 2(a): Build the self-oscillating circuit 10/8/14 10/29/14 Momin  3weeksPhase 2(b): Build a prototype of the eddy cur-rent sensor. 

    10/29/14 11/12/14 Frank 2week

    Phase 2(c): measure the prototypes’ electrical properties  

    11/12/14 11/19/14 Mohammad  1weeks

    Phase 3(a): build an improved prototype and measure its properties 

    11/19/14 12/3/14 Momin  2weeks

    Phase 3(b): Preparing final report and presen-tation. 

    11/26/14 12/10/14 Mohammad, Frank, Momin 

    2weeks

    (Spring Semester Plan) 

    Phase 4: connect oscillating circuit to a micro controller, and LCD screen 

    1/20/15 1/27/15 Frank 1week

    Phase 5: program the micro-controller to dis-play the distance of the metallic object on the LCD or on the PC screen 

    1/27/15 2/17/15 Mohammad  3weeks

    Phase 6: measure power consumption and the power of noise observed on the system by us-ing the oscilloscope. 

    2/17/15 3/3/15 Momin  2weeks

    Phase 7:Gather data and make table summa-rize the performance of the eddy current sensor

    3/3/15 3/24/15 Frank 3weeks

    Phase 8: Preparing final report and presenta-tion, E-day preparation. 

    3/24/15 4/14/15 Mohammad, Frank, Momin 

    3weeks

    Table 5 : Project Timeline - Sept. 17, 2014

    Phases  Start Date

    End date

    Group Member  Duration

    (Fall Semester Plan) 

    Phase 0: Project research and background. 

    8/25/14 9/17/14 Frank, Moham-mad, Momin 

    3 weeks

    Phase 1: Develop design parameters, and de-sign the eddy current sensor. Model it using Pspice or cadence. 

    9/17/14 10/8/14 Mohammad  3weeks

    Phase 2(a): Build the self-oscillating circuit 10/8/14 10/29/14 Momin  3weeksPhase 2(b): Build a prototype of the eddy cur-rent sensor. 

    10/29/14 11/12/14 Frank 2week

    Phase 2(c): measure the prototypes’ electrical properties  

    11/12/14 11/19/14 Mohammad  1weeks

  • Phase 3(a): build an improved prototype and measure its properties 

    11/19/14 12/3/14 Momin  2weeks

    Phase 3(b): Preparing final report and presen-tation. 

    11/26/14 12/10/14 Mohammad, Frank, Momin 

    2weeks

    (Spring Semester Plan) 

    Phase 4: connect oscillating circuit to a micro controller, and LCD screen 

    1/20/15 1/27/15 Frank 1week

    Phase 5: program the micro-controller to dis-play the distance of the metallic object on the LCD or on the PC screen 

    1/27/15 2/17/15 Mohammad  3weeks

    Phase 6: measure power consumption and the power of noise observed on the system by us-ing the oscilloscope. 

    2/17/15 3/3/15 Momin  2weeks

    Phase 7:Gather data and make table summa-rize the performance of the eddy current sensor

    3/3/15 3/24/15 Frank 3weeks

    Phase 8: Preparing final report and presenta-tion, E-day preparation. 

    3/24/15 4/14/15 Mohammad, Frank, Momin 

    3weeks

    Table 6 : Project Timeline - Oct. 8, 2014

    Phases  Start Date

    End date

    Group Member Duration

    (Fall Semester Plan) 

    Phase 0: Project research and back-ground. 

    8/25/14 9/17/14 Frank, Mohammad, Momin  3 weeks

    Phase 1: Develop design parameters for coin id system and necessary sen-sors. 

    9/17/14 10/8/14 Mohammad, Momin, Frank  3 weeks

    Phase 2(a): Build the self-oscillating circuit. 

    10/8/14 10/29/14 Momin 3 weeks

    Phase 2(b): Build a physical coin ramp. 

    10/29/14 11/12/14 Frank 2 weeks

    Phase 2(c): Build circuit and estab-lish software connection between photo interrupter and micro-controller. 

    10/29/14 11/9/14 Mohammad,Momin  1.5 weeks

    Phase 3(a): Coding interrupt service routine to implement timers with photo interrupts. 

    11/9/14 11/23/14 Mohammad,Momin,Frank  2 weeks

    Phase 3(b): Initial testing of entire system with implementation of sen-sors and permanent magnet. 

    (Note: This may carry over to the

    11/23/14 12/10/14 Mohammad, Frank, Momin  2.5 weeks

  • second semester depending on the time we have) Phase 4: Preparing end of semester report and presentation. 

    12/1/14 12/12/14 Mohammad, Frank, Momin  1.5 weeks

             (Spring Semester Plan) 

    Phase 5: Program micro-controller to display coin rolling time on LCD screen. 

    1/20/15 2/3/15 Frank, Mohammad  2 weeks

    Phase 6: Integrate Hall Effect sensor with system. 

    1/26/15 2/16/15 Momin 3 weeks

    Phase 7: Program micro-controller to display magnetic field strength on LCD. 

    2/3/15 2/24/15 Frank, Mohammad  3 weeks

    Phase 8: Test system with Hall Ef-fect sensor in place. Collect data on field strength. 

    2/17/15 2/24/15 Mohammad, Frank, Momin  1 week

    Phase 9: Modify circuit to integrate potentiometer, use to vary the mag-netic field. 

    2/24/15 3/10/15 Mohammad, Frank  2 weeks

    Phase 10: Test system with potenti-ometer in place. Collect data with variable field strength. 

    Measure power consumption and the noise observed on the system. 

    3/3/15 3/10/15 Momin 1 week

    Phase 11: Gather data; summarize the performance of our system. 

    3/10/15 3/31/15 Frank, Mohammad, Momin  3 weeks

    Phase 12: Prepare final report and presentation, E-day preparation. 

    3/31/15 4/21/15 Mohammad, Frank, Momin  3 weeks

    Table 7 : Project Timeline - Nov. 6, 2014

  • Appendix D: Programming Flow Chart

    Figure 33 : Programming Flowchart

  • Appendix E Microcontroller Code /* COIN ID PROJECT * * Purpose of code is to collect timing data from photointerruptor sensors and use * data to identify denomination of U.S. coin. Also, measures magnetic field * produced by variable strength electromagnet using a Hall Effect sensor type * A1301 from Allegra (2.5mV/Gauss) */ #include #include // pin assignments const int upper_photo = 2; // external interrupt pins for photointerrupters const int lower_photo = 3; const int LCDrx = 1; // set LCDrx to LCD's rx pin //RGB LED analog PWM pins int red_pin = 11; int green_pin = 10; int blue_pin = 9; serLCD lcd(LCDrx); // create serLCD object to use with serLCD library print functions // 'volatile' since these will change value inside ISRs volatile unsigned long current_time = 0; volatile boolean flag_upper = false, flag_lower = false; unsigned long start_time = 0, stop_time = 0, total_time = 0; #define NO_FIELD 504L // analog output measurement with no magnetic field present, used to calibrate sensor #define TO_MILLI_GAUSS 1953L // converts the analog voltage reading to milliGauss // values for Allegro A1301: 2.5 mV = 1 Gauss, and 1024 analog steps = 5 V, so 1 step = 1953 mG void setup(void) { pinMode(red_pin, OUTPUT); // set LED pins to output mode pinMode(green_pin, OUTPUT); pinMode(blue_pin, OUTPUT); attachInterrupt(0, startTime, FALLING); // interrupt on falling edge attachInterrupt(1, stopTime, FALLING); lcd.setBrightness(30); // set LCD backlight level (0=off, 30=full) lcd.clear(); //Serial.begin(9600); // uncomment if using with serial monitor and not using lcd screen } void loop(void) { if (flag_upper) { // when coin passes thru upper photoint, store current time as start time start_time = current_time; flag_upper = false;

  • } if (flag_lower) { // when coin passes thru lower photoint, store current time as stop time stop_time = current_time; flag_lower = false; total_time = stop_time - start_time; lcd.selectLine(1); // print routine to display coin roll time on LCD screen lcd.print("Roll time: "); lcd.print(total_time); lcd.selectLine(2); lcd.print(" milli seconds."); delay(3000); // delay to allow time for data to load to lcd and be read by observer lcd.clear(); coinID(total_time); // identifies coin based upon recorded time delay(3000); // delay to allow time for data to load to lcd and be read by observer lcd.clear(); measure_Field(); // take measurement of magnetic field using Hall Effect Sensor delay(3000); } } // ISR to store starting time void startTime(void) { flag_upper = true; noInterrupts(); // temporarily turns off interrupts to make sure current_time doesn't change while we read it current_time = millis(); interrupts(); } // ISR to store stopping time void stopTime(void) { flag_lower = true; noInterrupts(); // temporarily turns off interrupts to make sure current_time doesn't change while we read it current_time = millis(); interrupts(); } // Identify coin based on travel time between photointerruptors and effect of magnetic field on coin roll void coinID(unsigned long int t) { lcd.selectLine(1); lcd.print(" Coin is: "); lcd.selectLine(2); // These times are based upon measurements taken using a fixed magnetic field from hard drive magnets if (t > 4550){ lcd.print(" Unknown."); setColor(255, 0, 0); // LED displays red delay(1000);

  • } else if (t >= 3600){ lcd.print(" Quarter."); setColor(0, 255, 0); // LED displays green delay(1000); } else if ( t >= 2650) { lcd.print(" Dime."); setColor(0, 0, 255); // LED displays blue delay(1000); } else if (t >= 2250){ lcd.print(" Penny."); setColor(255, 255, 255); // LED displays white delay(1000); } else if (t >= 1700){ lcd.print(" Nickel."); setColor(80, 0, 80); // LED displays purple delay(1000); } else { lcd.print(" Unknown."); setColor(255, 0, 0); // LED displays red delay(1000); } } /*setColor Method for use with common anode (positive) type RGB LEDs that allows the user to change the color emitted by the LED based upon the value of the red, green, and blue pins of the LED. The color pins are connected to ground through 300 ohm resistors. */ void setColor(int red, int green, int blue) { // send chosen color to each pin analogWrite(red_pin, red); analogWrite(green_pin, green); analogWrite(blue_pin, blue); } /* measureField Use an Allegra A1301 Hall Effect Sensor as a magnetometer to determine magnetic field strength measured in Gauss based upon voltage measured on analog pin 0. Values for Allegro A1301: 2.5 mV = 1 Gauss, 1024 analog steps = 5 V, so 1 step = 1953 mG * Pin Layout - UA

  • * 1 VCC 5V * 2 GND * 3 Data -- connect to analog 0 */ void measure_Field() { int initialReading = analogRead(0); // analog output range : 0 to 1024 /*uncomment to print intial sensor reading for calibration of NO_FIELD constant with no magnetic field present lcd.selectLine(1); lcd.print("Initial reading: "); lcd.selectLine(2); lcd.println(initialReading); */ long adjusted = initialReading - NO_FIELD; // calculate actual field reading by adjusting field based on sensor calibration point long field = adjusted * TO_MILLI_GAUSS/1000; // convert field reading to Gauss lcd.selectLine(1); lcd.print("Field Detected: "); lcd.selectLine(2); lcd.print(field); lcd.print(" Gauss"); /* uncomment to display which pole of magnetic field is detected delay(3000); lcd.clear(); if (field > 0) { lcd.selectLine(1); lcd.print("(South pole)"); } else if (field < 0) { lcd.selectLine(1); lcd.print("(North pole)"); } else lcd.clear(); */ }

  • Acknowledgments We would like to extend our thanks to our Faculty Sponsor, Dr. George Collins, our Industry Advisor, Mr. Garrett Durland, and our Senior Design Professor, Olivera Notaros for their advice, guidance, support, and constructive criticism throughout the course of this project. We would also like to thank Josh Olson for lending us his Arduino Uno board after our Nano board burned out, the mechanical engineering lab for being generous with their tools, the graduate students in the Electromagnetics Lab for their willingness to help, and Professor Mario Marconi for his elec-tromagnet advice and encouragement.