























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!
























Abstract
C.1. Main code………………………………………………………………….. C.2. Display code………………………………………………………………..
iii
The user will be able to press a button in order to restart the odometer at the beginning of each trip. They will also be able to toggle between the distance traveled and the time spent on the display. These buttons will be directly on the display device. 1 Fig. 1.1 Block Diagram of our Device 1.2 Specifications Accurate calculation of how far the person has ran or walked Accurate calculation of how long the person has been running or walking Convenient way to maintain strict workout regiment Light and easy to carry as you run or jog Easy to use (push button controls) Easy to maintain Easy way to exercise on vacation or in an area user is not familiar with In order for our entire system to function properly, our refresh rate for the accelerometer will be crucial. We anticipate the microprocessor having to take the accelerometer’s reading approximately every 5 seconds and calculating the data that it has received. It will also have to tabulate the distance traveled over that 5-second interval and add it to the previous sum. The velocity calculating will be more straightforward because it will not have to keep track of any summation as it does for the distance. Once we have all of the components functioning properly, our main focus will be on improving the accuracy of the device, as we can foresee that as being a substantial hurdle. Our goal would be to have the distance and speed measurement to have less than a 2% error, and less than a 1% error in the time duration.
2.1.1 Analog /Digital Accelerometer The analog output accelerometer was the only feasible option considering the microcontroller that we were using. We used the PIC 16F877, which handled analog to digital conversion with one input very smoothly. Also, using a digital output accelerometer would have involved digital signal processing, which neither of us had taken. Considering this we chose the ADXL etc…, which gave us an output voltage ranging, form 2 to 3 volts that we could easily manipulate within the PIC. 2.1.2 Single/Dual Axis Accelerometer output The ADXL202….. is a dual axis accelerometer with analog output available for the x and y axis. We chose to use the only the X- axis output because there was really no way we could manipulate both values within one PIC. A single PIC can only do analog to digital conversion with on input at a time. The acceleration cannot truly by decipher using merely one axis; both the X and Y-axis values of the accelerometer must be known. However, in this project the capabilities of the microcontroller dictated that we do otherwise. For simplicity we chose to only use one axis with hopes to follow though with the project and eventually observe how the accelerometer values varied in practice due to movement and tilt. We anticipated possibly implementing the second axis at the end of the project. 2.1.3 Microcontroller selection Coming into the project we did not anticipate the microcontroller to be a very pivotal part of the project. We anticipated that once we understood the workings of the accelerometer the microcontroller would merely be used for the relative simple calculations and relaying the signal to the display portion of the device. We chose the PIC 16F877 largely due to a recommendation from our T. A. The PIC was programmable in C and that was convenient. Implementing the LCD with the PIC was also very smooth. However, several setbacks did occur with the capabilities of the PIC. These included things such as memory capacity, inability to use floating-point numbers, ADC accuracy, and serial transmission. We were able to overcome these adversities for the most part. At
the very least we now understand the exact specifications of the microcontroller that would be needed for a project like this in the future. 4
2.2.1 PIC C Compiler We used a microcontroller compiler to execute the program code without burning into the microcontroller by the PicStart programmer each time. It helped us to debug and modify the program code much faster and more easily. 2.2.2 PicStart Plus We used this PIC programmer to burn the code into the microcontroller at the end of code testing, so it could be put into the PC board without being connected with emulator. It also assisted us greatly with testing our code for functionality during the design process. 2.2.3 Oscilloscope The oscilloscope was used to monitor any output waveform from the PIC , the transmitter, and receiver. 2.2.4 Power Supply The power supply with +5 VDC output has been used for all of our logic circuit. 2.2.5 Function Generator The function generator was used to input different voltages into the PIC to emulate the same sort of values that the accelerometer would at times when the accelerometer was not available for testing, such as when it was being soldered onto the PCB.
3.2 Accelerometer
(+) (–) Over-voltage Protection Polarity Protection Fuse (eg. 1A) 1N5822 or 1N 1N5339 (eg. 5.6V) Parts shop: 1N Schottky diode + μ P - (+) (–) Zener diode Fig 3. Fig 3.
the 0.1uF capacitor for moderate values. For details of our selection, please refer to the Appendix B.1. The 0.1uF will give us 1.8mg of noise. At 1g, this corresponds to 1.8mg * 312mV/g = 0.5616mV/g (3.2) This is a negligible value in our calculations. The accelerometer gives a non-steady random 0g value between 2.3 ~ 2.7 Volts. Please refer to Appendix B.3. However, with our measurements, we received the values of 2. ~ 2.48V in most cases. We saw the value around 2.43V a lot and for simplicity, we standardized it to 2.43V. Fig 3. 7 3.3 Transmitter/Receiver
3.4.1 Analog to Digital Conversion on first PIC On the first PIC the calculation of the integration of the acceleration was being done. However, before we could calculate the distance we had to make sense of the acceleration value with the analog to digital converter. We used a 10-bit analog to digital converter with a 2V offset. Which means that for example a voltage of 2.5 Volts would be input into the ADC input pin, then the PIC would subtract whatever the negative
voltage reference was from that( in this case 1V). Then it would multiply it by 2^10 = 1024 and finally divided by the size of the offset (in this case 2V)to achieve its digital value which is just a fraction of that total capacity of 1024. So for example since our ADC range is from 1 to 3 Volts a voltage of 2 in the input would ADC calculations: Input = A0 Volts ADC Positiive voltage reference = 3V ADC Negative voltage reference = 1V Digital Signal = (ADC_VALUE) bits = ((A0 –1 Volt)*1024 bits))/(3-1)Volts (3.3) As you can see form the units the volts cancel out and only bits are remaining. Once we had the ADC value we subtracted the offset voltage of the accelerometer. We found that the accelerometer always gave out a voltage of approximately 2.43 volts when stationary. This is without any movement whatsoever. Any acceleration in any direction would cause that voltage to either drift higher or lower than that value. Through several trials we deciphered that the ADC value for that offset voltage was roughly 733. ADC_VALUE bits – 733(stationary) bits = (acceleration) bits = change in value due to movement (3.4)
g = acceleration due to the earth’s gravitational pull = 9.8m/s^ Accelerometer sensitivity = .312V/g Now converted to bits/g .312 V/g * (1024bits/2V) = 160 bits/g (3.5) (acceleration) bits / (160 bits/g ) = (acceleration) g (3.6) (acceleration) g / 9.8 = (acceleration) m/s^2 (3.7) 10
Vf = Vi + at (3.8) X = Vit + 0MHz Oscillator for clock.5at^2 (3.9)
Fig. 4.2 Voltage reading at 1g Fig. 4.3 Voltage reading at 2g (freefall) 4.1.2 Transmitter and Receiver testing
Fig. 4.5 Final Circuit on PCB 15
5.1 Labor Cost $40/hr x 2.5 x (80hours) = $ $8000 x 2 people = $16000 total. 5.2 Part Cost PIC 16F877 $5.11 x 2 = $10. 2 x 20MHz Oscillator $2.13 x 2 = $4. *1 x Transmitter (TXM - HPII) $23. *1 x Receiver (RXM - HPII) $31. 6 x Resistors $0.07 x 6 = $0. (750Ω, 2kΩ, 2 x 3kΩ, 2 x 47kΩ, 125kΩ) 3 x 0.1uF Capacitors $0.19 x 3 = $0. 2 x Switch $1.19x 2 = $2. LCD $15. 1 x Accelerometer (ADXL202) $8. Total Part Cost = $96. *HP2 series discontinued so using HP3 series standard.