Docsity

Wireless Distance Tracking System with PIC Microcontrollers, Study Guides, Projects, Research of Electrical and Electronics Engineering

Partial preview of the text

Download Wireless Distance Tracking System with PIC Microcontrollers and more Study Guides, Projects, Research Electrical and Electronics Engineering in PDF only on Docsity!

Personal Trip-odometer

By

Akin Adekoya

David Chung

ECE Senior Design Project

Fall 2004

TA: Richard Cantzler

Project No. 14

Abstract

  • Countless advances in sport and athletics can be attributed to technological breakthroughs throughout history. Professional and casual athletes alike have been able to improve the efficiency and effectiveness of their workouts utilizing the technology. Along those same lines a common dilemma facing those who train outdoors is accurate distance measurement. For instance someone who regularly runs outdoors may have a predetermined route that he or she usually follows but may have grossly misestimated that value. For example, a device that tracks distance by counting steps currently exists. This method is however, terribly inaccurate and would only serve the most casual of athletes. In an attempt to assist a wider range of athletes from nonchalant to professional, we have developed a personal trip-odometer. While being worn on the runner’s shoe the device will calculate, up to the second, the precise distance the jogger has traveled with the use of an accelerometer. ii

Appendix C – The Code………………………………

C.1. Main code………………………………………………………………….. C.2. Display code………………………………………………………………..

References……………………………………………..

iii

1.Introduction

  • In attempting this project we tried to develop something that could have significant use in industry and society. We wanted to develop something worthwhile, not only for possible future monetary purposes, but also in hopes of somehow making life easier for people everywhere. Our joint interests included circuit design, digital logic design, and hardware control. We are also both very active and enjoy athletics. Our project encompasses all of those facets. When a person decides to go for a run or even possibly a walk, without the use of some sort of indoor/outdoor track it becomes very difficult to decipher how far he or she has traveled. Unless that person has marked out their path beforehand and measured it out, they cannot conveniently know how far they have run. In an attempt to help the causal exerciser or even the serious professional athlete we have decided to develop a personal trip-odometer. The device will obviously be portable and able to be comfortably worn on the jogger’s shoe. From this position, the odometer (with the use of an accelerometer) will calculate how far the jogger has traveled. In addition we will implement a stopwatch into the device. It will transmit the information to a small hand held receiver that displays all of this information on a screen. This receiver could be held in their pocket or strapped to their arm. One of our major challenges will be to facilitate the communication between the accelerometer and the microprocessor and so that it may use the information from the accelerometer to make the proper calculations. Design the circuit with the PIC that will make the necessary calculations we need in order to arrive at the needed values such as distance traveled and time. We also wish to establish reliable communication between the transmitter on the main device and the display device. Once we have accomplished these individual goals we were able to synchronize the entire system so that all elements work independently and bring them together to achieve our final goal. 1.1 Block Diagram: Fig. 1.1 is the block diagram for the entire device. It will be a two-piece device consisting of the main device and the receiver or display device. The main device will be worn on the user’s shoe and the display device will strapped onto their arm in some fashion.

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. Design Procedure

2.1 Design Decisions

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 Tools Used

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

  • We used the ADXL 202 accelerometer for our sensor device. This device senses with a 312mV/g sensitivity and can sense from -2g to +2g. We used a 120kOhm resistor at pin 2 to set a duty cycle of 1ms. Period T = R / 125M (3.1) This is approximately 1ms. We used an analog output that would be varying voltage values rather than the digital output that depended on the duty cycle. We used a 0.1uF capacitor that connects the output of pin 7 (Xflit) to ground so that we can output a clear analog output. This capacitor also serves as a selector for the bandwidth and noise values. The trade off is that the smaller value of capacitance filters less noise and uses more bandwidth. However, with large capacitance, the time constant RC value will be greater. We chose
    • μ P

(+) (–) 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

  • We used the HP-2 series of transmitter and receiver. We matched the devices to channel 0 that operated at a frequency of 903.37MHz. The operating temperature of the device was 0 ~ 70oC, which would give problems in real applications. The input and output were 8bit digital data while the device could send and receive up to 10bits at a time. The device was suitable because it had almost no noise and would easily transmit in the range that is necessary for our project (approx. less than 2m).

Fig 3.5 Pin layout of the PIC

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)

Now these are the equations used to arrive at the acceleration in m/s^

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

Once we arrive at this value we can just implement the basic physics

equations as seen in equations (3.8) and (3.9)

Vf = Vi + at (3.8) X = Vit + 0MHz Oscillator for clock.5at^2 (3.9)

  • We tried to test the sensitivity of the accelerometer in order to confirm the data sheet. With multiple measurements of the 0g output voltage, our values were consistently between the values of 2.35V and 2.48V. The problem occurred when we titled our device. Apparently, our accelerometer also measures the tilt on the device and it is a dual axis. For our project, we assumed that the device will be calibrated as the user turns the device on and the amount of tilt will not change. For example, if we attach the device on the ankle, even though there is a small amount of tilt, that tilt will become the reference 0g value as the user turns the device on. When taking a step, the device will not be tilted and any acceleration in the vertical axis will cancel out to be 0 since a step will be taken back to ground. Also, we are only interested in the horizontal distance traveled. When the tilt was 90o upward, the device read a -1g and gave us a value that is approximately 312mV smaller than 0g. When the device was 90o^ downward, the output value was about 312mV greater. For more information on the tilt, refer to the appendix B.2. After measuring the acceleration due to gravity, since gravity is the only known constant acceleration, we decided to drop the accelerometer with the axis facing down. We measured the acceleration to be 2g. As we can see in the figures below, we can use the values to calculate the output per g. (2.977V-2.352V)/2g = 312.5mV/g (4.1) This is consistent with the values given by the data sheet. Fig. 4.1 Voltage reading at 0g 12

Fig. 4.2 Voltage reading at 1g Fig. 4.3 Voltage reading at 2g (freefall) 4.1.2 Transmitter and Receiver testing

  • Our PIC outputs an 8bit digital signal at 60Hz. For our testing purpose, we sent in a 60Hz 5V pp square wave signal into the transmitter and measured the output at the receiver output. As we can see from the Fig. 4.4, the amplitudes and periods are identical. The only difference is that there are a few microseconds of delay. This will vary accordingly to the distance between the devices, but as long as the entire device stays synchronous, there will be no problem with small delays. 13

Fig. 4.5 Final Circuit on PCB 15

5. COST

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.

Total Estimate Project Cost = $16,096.