Docsity

Vehicle Collision Avoidance System - Lecture Notes | ECE 445, Study Guides, Projects, Research of Electrical and Electronics Engineering

Partial preview of the text

Download Vehicle Collision Avoidance System - Lecture Notes | ECE 445 and more Study Guides, Projects, Research Electrical and Electronics Engineering in PDF only on Docsity!

Vehicle Collision Avoidance System

by Alan Bull and Ta-Mao Hwang ECE 345 – Senior Deign TA: Shao Hsia 5/1/ Project #

Abstract

The purpose of this paper is to present the design process used in making a vehicle collision avoidance system. We will give design details and show a step-by-step procedure of how the final product was designed, produced and tested. The project’s main goal is to alert a driver when his or her vehicle comes too close to another object or when the object is approaching at a high rate of speed. An LCD display shows the distance between the vehicle and the foreign object. The project has the ability to modify distance calculations based on the ambient temperature. Many of the challenges that arose while working on this project will be discussed, as will the specifics of the Basic Stamp II microcontroller, our circuit design, and the ultrasonic sensors used. ii

1. Introduction

1.1 Functionality and block diagram Figure 1.1 shows the block diagram of the vehicle collision avoidance system and the following is a brief description of the flow of this design. Figure 1.1 can be found at the end of the chapter.

  1. Ambient temperature is taken by temp probe and sent to the microcontroller (Basic Stamp II) which uses the information to calculate the speed of sound
  2. The BSII initializes the LCD display (which takes about 1 second).
  3. BSII tells the transmitter circuit when to send out a 40kHz signal, produced by the 40kHz oscillator, through the transmitter circuit, to drive the sensors at the appropriate frequency.
  4. When transmitter sends the pulse, the BSII starts timing.
  5. When the pulse is received, it is amplified through logic circuitry and sent to the BSII, at which point the timing stops.
  6. BSII then calculates the distance based on the Time of Flight (TOF) and the velocity of the approaching object.
  7. Results are displayed on the LCD and the speaker sounds a warning tone if the object is within the specified distance (rear) or the specified approach speed (front).
  8. Process repeats 1.2 Performance Variables and Specifications Several variables pertain to the performance of this project. They are the speed at which sound travels, the distance from the sensors to the object, the object’s ability to reflect sound, and the time it takes the BSII to calculate and display all information. The speed at which sound travels is varied based on the ambient temperature, according to the following equation: 273

320 / * K

Temp Velocitym s (equation 1.1). Speed could also vary based on humidity and other external factors; however they have a very limited effect on the speed, and since the BSII doesn’t make floating point calculations (it is only able to do integer math), these would not change the calculated speed of sound. The distance from the sensor to the object is the most important variable, and is what our project was designed to ascertain. The range at which we were able to get reasonable results was 7cm-250cm. The time it takes the BSII to calculate and display data was very minimal and had no effect on our calculated distance and resolution. The object’s ability to reflect sound was noticed when we tested various objects and in one case got differing results. We found that our project worked best with metal objects, that plastic and wood objects were very close to metal, and that accuracy was worst with human beings. 1.3 Major Design Components There are four major design components used in this project. They are the sensors, the circuits, the BSII microcontroller, and the user interface. The user interface consists of an LCD display and an audio warning. There are five different circuits used, the voltage regulation circuit, the temperature sensor circuit, the 40kHz oscillator circuit, the transmitter circuit, and the receiver circuit. MuRata Electronics donated the sensors for this project. They are the MA40B8R/S. A data sheet about the sensors can be found at http://www.murata.com/murata/weblibrary.nsf/pdf/c18/$file/ma40.pdf. The BSII was the last major component of the project that we had to develop. It was simply a matter of writing code to

make sure it did what we wanted it to. Information about the BSII can be found at http://www.parallaxinc.com/. BASIC Stamp II Microcontroller Transmitter Amplifier Receiver Signal Conditioning Ultrasonic Transmit Ultrasonic Receive Ultrasonic Transmit Ultrasonic Receive Receiver Signal Conditioning 40kHz Oscillator Front Rear Operation Mode Inputs 2x16 LCD Display Output Speaker Output A/D Temp Sensor Figure 1.1. Block Diagram of Vehicle Collision Avoidance System

We decided to use the BSII microcontroller for one main reason, its ease of use. Although the Motorola HC12 has a lot more capabilities, we felt that we could do everything we needed with the BSII and saw no reason to add another level of complexity to our project. The BSII controls all the logical operations of our design as well as the user interface. Figure 2.2 shows the operation flow of the BSII. This figure can be found at the end of the chapter. The following is a brief description of this flowchart.

  1. The LCD is initialized (takes about 1 second).
  2. The ambient temperature is taken.
  3. User decides weather to display temperature or distance. If temperature is chosen, this information is sent to the user interface, then loops to step two.
  4. When distance mode is selected, the user next has to decide whether to take readings from the front or rear sensors.
  5. A 40 kHz pulse is transmitted.
  6. The echo is received
  7. Distance is calculated based on the time of flight.
  8. Distance and velocity information are sent to the user interface.
  9. Program loops back to step two. 2.4 User Interface The user interface consists of an LCD display and an audio alert. Both are controlled by the BSII. We decided to use an LCD so that the user can determine the exact distance that s/he is away from the object. We considered using LEDs of differing colors for various distances but decided that it would be better for the user to be able to tell the exact distance herself. The audio alert sounds when the object is approaching at a rapid rate from the front, or if the object is with 15cm in the rear. We felt that a user could tell how far an object was away from them in the front. It is, however, imperative that users know whether or not an object is approaching at a high rate of velocity from the front so they can make the necessary driving adjustments. However, it is much more unlikely that drivers will see objects at the rear of the vehicle, which is why the audio alert goes off at a specified distance in the rear.

Figure 2.1. Sensors (left are JameCo sensors, right are MuRata sensors)

3. Design Details

3.1 Sensors The sensors are fairly easy to use. The only requirement is that the transmitter must receive a 40kHz signal in order to transmit. Although slight variations in frequency are allowed, they can degrade sensor performance. The datasheet (http://www.murata.com/murata/weblibrary.nsf/pdf/ c18/$file/ma40.pdf) specifies that the signal can have a maximum peak-to-peak voltage of 40V. 3.2 Oscillator The 40kHz oscillator consists of a LM555 timer IC and the necessary resistors and capacitors. The circuit used is suggested by National Semiconductors in the LM555 datasheet at http://www.national.com/ds/LM/LM555.pdf. The LM555 is configured for stable operation in our implementation, which means it will send out a continuous oscillation. According to page 8 of the datasheet, the resistor and capacitor values can be calculated for a certain frequency. The equation is R R C f ( a (^2) b )*

  1. 44   (^) (equation 3.1) The complete circuit diagram is shown in Appendix I figure A1.1. 3.3 Transmitter The transmitter circuit consists of a DM7408 AND gate and a LF357 op-amp. The purpose of the AND gate is to act as a switch for activating the transmitter. One input of the AND gate is connected to the BSII while the other is connected to the output of the oscillator. Thus the 40kHz square wave generated by the oscillator will not activate the transmitter circuit unless instructed to do so by the BSII. The next component of the transmitter circuit is the LF357 op-amp. Its main function is to act as a comparator. The LF357 is powered by a 12V split voltage supply. The LF357’s positive input is connected to the output of the AND gate and its negative input is connected to the 2.5V reference voltage. The voltage from the AND gate output is then compared with the reference voltage. If the voltage of the AND gate is higher than the reference (5V peak of square wave) then the output of the LF357 will swing towards the positive supply (+12V). If the positive input is lower than the reference (0V of square wave) then the op-amp output will swing towards the negative supply (-12V). This in effect amplifies the original TTL square wave to a 20Vpp square wave. The LF357 was selected because it provides a very high slew rate, which is important in generating a signal with large peak-to-peak voltages. The transmitter circuit and its output are shown in Appendix I figures A1.2 and A1.3. 3.4 Receiver The receiver signal conditioning circuit consists of an amplifier and a comparator. The amplifier consists of a LM358 op-amp. The AC amplifier circuit is similar to the one suggested in the LM358 datasheet at http://www.national.com/ds/LM/LM358.pdf. The negative input is connected to a 2.5V reference. This serves to introduce a DC component to the received signal and center it at 2.5V. The positive input is connected to the ultrasonic receiver transducer. The

output of the transducer is essentially a 40kHz sine wave with maximum amplitudes of up to 300mV. This AC signal is amplified by the op-amp with a gain of 101. Thus the output of the amplifier circuit will be a sine wave centered at 2.5V. The output of the amplifier was connected to the positive input of the comparator, a LM393. The LM393 is chosen because it is capable of outputting TTL compatible signals. The operation of the comparator is similar to that of the one described in the transmitter circuit. The difference is that instead of acting as an amplifier, the comparator will generate a TTL compatible signal capable of being read by the BSII. The circuit and waveforms are shown in Appendix I figures A1.4, A1.5, and A1.6. 3.5 Voltage There are three key voltages generated in this design. The first is a +5V used to power logic devices. This voltage is generated using a voltage regulator, the MC7805, which takes in the 12V supply voltage and regulates it to 5V. Two reference voltages are generated from the 5V. The first is a 2.5V reference voltage generated simply by using a voltage divider. This voltage is used in the transmitter and receiver circuits described above. The second reference voltage is the decay reference used by the comparator in the receiver circuit. The purpose of the decay reference is to eliminate the cross- talk effect between the sensor pairs. The receiver might inadvertently pickup pulses directly from the transmitter instead of detecting an echo when the transmitter is sending pulses. Therefore when the transmitter sends a pulse the pulse voltage also charges the capacitor in the decay voltage circuit, which raises the voltage output of the reference much higher than 2.5V. Once the pulse ends the output will slowly decay to 2.5V as the capacitor discharges. By raising the reference voltage to the comparator we can in effect blank out the receive signals for a short period of time. Comparing figures A1.5 and A1.8 shows the blanking effect. In this design the blanking signal lasts for about 2ms before decaying down to 2.5V. This corresponds to the time of flight of about 7cm, which is our minimum range. The circuits for generating these voltages are shown in Appendix I figure A1.7. The decay voltage is shown in A1.8. 3.6 Temperature Sensor Circuit The temperature circuit consists mainly of a LM335 temperature sensor and an ADC0831 A/D converter. The LM335 temperature sensor is capable of detecting temperature in the –40C to +100C range. It is essentially a zener diode with a breakdown voltage that corresponds to the temperature in degrees Kelvin. Thus a voltage of 3.00V means the temperature is at 300K, or 27C. According to the datasheet (http://www.national.com/ds/LM/LM135.pdf) the temperature sensor is accurate to about 1C without any adjustments and has 10mV voltage increments. The voltage output from the temperature sensor is fed into the analog input of the A/D converter. The ADC0831 is an 8-bit serial converter. Thus it is capable of 256 resolutions. The voltage resolution can be determined by setting the reference voltages. For example setting the references at +5V and ground will result in a resolution of (5-0)/256 = 0.195mV. Since the maximum temperature sensor output is around 3.73V, the upper reference voltage is set to 3.73V with a potentiometer. This gives a resolution of about 15mV.

the A/D clock pin is used to shift in the 8-bit binary value. Once the 8-bit value is obtained it needs to be converted since the value is relative to the A/D references. The temperature in degrees Kelvin can be obtained by: 256 (max) * ADCvalue T (^) kV (^) ref (equation 3.2) The ShowTemp subroutine merely converts the temperature into degrees Celcius by subtracting 273 and takes into account negative temperatures. Then it displays the temperature on the LCD. The Ping subroutine is responsible for commanding the transmitter circuit to send out a series of pulses. The PULSOUT command allows about 16 oscillations from the oscillator circuit to enter the transmitter circuit. A RCTIME command is issued immediately after the pulse is sent. RCTIME measures the amount of time it takes for the receive echo pin to change state from 0 to

  1. Once this time of flight is counted, the distance can be found by using the distvelocity * time formula. Notice how the formula is modified for our implementation to accommodate the BSII. Speed is represented as us/cm because RCTIME records time in 2us counts. The CalcVelocity subroutine simply compares the current distance with a previous distance and finds the difference to approximate a rate of approach to an obstacle. The Display subroutine outputs the distance as well as the approximate rate of approach, which is represented in bar graph form, to the LCD display. The display subroutine also determines whether there is a need to sound an audio warning. If front sensors are used an audio warning is issued if the rate of approach to an object is great. For rear sensors the warning sounds if an object is detected within 15cm. The Sound subroutine is called to drive the speaker output.

4. Design Verification

4.1 Sensor Verification To verify that our sensors were working correctly, we hooked the transmitter up to a function generator and the receiver to an oscilloscope to be sure that we were sending and receiving signals. The MuRata parts worked with out difficulty, although there was a little crosstalk between the pair of devices. The JameCo parts did not work as well, as there was a lot of crosstalk, and objects were hard to pick-up. Both products gave us voltages in the range of 50- 250mV. For this reason, we decided to use time-of-flight (TOF) instead of voltage to determine the distance of objects. To measure the TOF we had to use the BSII, so we were unable to test this part of the sensors without the BSII. 4.2 Circuit Verification We tested each of the five circuits separately to verify that they were working correctly before we hooked them together. For the amplifier circuits in the transmitter and receiver, we hooked the input up to a constant voltage and then hooked the output up to an oscilloscope. With the transmitter circuit, we verified that we were sending out a 20-V peak-peak signal so that we would receive a strong echo. This was amplified from the 5 V peak-peak that we were inputting. Please see figure A1.2 in appendix 1. The receiver circuit was tested in the same manner to be sure that we were sending out a 5 V square wave that could be used by the BSII. Please see figure A1.5 in appendix 1. To test our voltage regulation circuits, we used a very similar process. With the reference voltage that was used for the transmitter circuit, we made sure that the circuit was outputting a constant 2.5 V signal that could be used by the comparator. The reference voltage that was used for the receiver circuit needed to be a decaying reference voltage so that it would help to eliminate crosstalk. This was discussed previously in section five of the design details chapter. Also, figure A1.7 found in appendix 1 shows the decaying reference voltage. For verification of our temperature sensor circuit, we needed to hook it up to the BSII so we could tell if it was outputting the correct temperature. The temperature sensor was discussed in section six of the design details chapter. The temperature sensor was surprisingly accurate and responded to temperature changes very quickly. To test our oscillator circuit we hooked it up to an oscilloscope to be sure that it was generating a pulse at 40kHz. 4.3 Entire Project Verification To verify that our design was working as expected, we tested the overall project on a variety of different materials. Included below in table 4.1 and 4.2 are the data that we recorded for metal and plastic objects. When we tested our project on wood, we got very similar results to those listed below. The only tests in which we obtained different results were tests on humans. Because clothes sit at varying angles on a person’s body, they tend not to reflect the sound wave back to the receiver as well as with other objects. For this reason we were only about to get about one meter of range when we tested on humans.

5. Costs

5.1 Labor: 5.2 Parts and Supplies

    1. Introduction……….…………………………………………………………….… Page - 1.1 Functionality and block diagram………….………………………………….. - 1.2 Performance variables and specifications…………………………………….. - 1.3 Major Design Components……………………………………………………
      1. Design Procedure…………………………………………………………….…… - 2.1 Sensors…………………………...…………………………………………… - 2.2 Circuits………………………………………………………………………... - 2.3 BSII Microcontroller………………………………………………………….. - 2.4 User Interface………………………………………………………………….
    1. Design Details…………………………………………………………………….. - 3.1 Sensors………………………………………………………………………... - 3.2 Oscillator……………………………………………………………………… - 3.3 Transmitter……………………………………………………………………. - 3.4 Receiver……………………………………………………………………….. - 3.5 Voltage………………………………………………………………………… - 3.6 Temperature Sensor Circuit…………………………………………………… - 3.7 User Interface………………………………………………………………….. - 3.8 BASIC Stamp II………………………………………………………………...
    1. Design Verification……………………………………………………………… - 4.1 Sensor Verification………………………………………………………….. - 4.2 Circuit Verification………………………………………………………….. - 4.3 Entire Project Verification…………………………………………………...
    1. Costs……………………………………………………………………………... - 5.1 Labor………………………………………………………………………… - 5.2 Parts and Supplies…………………………………………………………… - 5.3 Total Cost…………………………………………………………………….
    1. Conclusions……………………………………………………………………....
      • Appendix 1………………………………………………………………………………
    • 2($5080*2.5) = $20,000. The cost of labor for both people is:
  • MC7805CT +5V voltage regulator 1 $0.30 $0. Part # Description Quantity Price Subtotal
  • LM335AH Temperature sensor IC 1 $8.11 $8.
  • ADC0831CCN 8-bit A/D converter 1 $2.17 $2.
  • 3352W-1-103 Potentiometer 10K 3 $1.02 $3.
  • MA40R8S MuRata ultrasonic sender 2 $5.26 $10.
  • MA40R8R MuRata ultrasonic receiver 2 $5.26 $10.
  • LF357N Op-Amp IC 1 $1.61 $1.
  • LM555N Timer IC 1 $0.32 $0.
  • DM7408-ND AND Gate IC 1 $1.03 $1.
  • LM358 Dual Op-Amp IC 1 $0.31 $0.
  • LM393N Comparator IC 1 $0.54 $0.
  • BS2-IC Parallax BASIC Stamp II 1 $41.65 $41.
  • BPI-216N 2x16 LCD display 1 $45.00 $45.
  • 52-125 Speaker 8-Ohm 1 $1.93 $1.
  • 76SB04 DIP Switch 4-positions 1 $0.88 $0.
  • D1N914 Diode 1 $0.10 $0. - Capacitor 10uF 3 $0.38 $1. - Capacitor 0.01uF 10 $0.14 $1. - Capacitor 0.015uF 1 $0.15 $0. - Capacitor 0.33uF 1 $0.15 $0. - Capacitor 0.1uF 1 $0.15 $0. - Resistor 100K 5 $0.02 $0. - Resistor 3K 2 $0.02 $0. - Resistor 1M 1 $0.02 $0. - Resistor 10k 1 $0.02 $0. - Resistor 1.2k 2 $0.02 $0. - Resistor 33ohms 1 $0.05 $0. - Total $131.
    • Labor+Parts: $20,000.00+$131.31 = $20,131. 5.3 Total Cost
  • Total Cost = $20,131.

6. Conclusions

The vehicle collision avoidance system is very useful in today’s society. It makes drivers more aware of their surroundings; therefore it will be easier for them to avoid collisions. With parking lots becoming more and more crowded and with more people driving larger vehicles that are hard to maneuver, a device like this becomes almost essential. The implementation for our product was very successful, with no real problems found. We were able to implement each of the four major subprojects without too much difficulty. Changing the offset a little more might allow us to get perfect distance readings, but being off only a couple of centimeters is not of much concern. If we were to produce this product commercially, we would use a more sophisticated microcontroller that would allow us to eliminate the rounding problems and would therefore make for near perfect distance readings. Also, we would have to find and use lower cost parts in order to make something like this feasible for a company to produce and to sell to a car manufacturer. For real world implementation of this device, a few things would need to be ironed out. The first problem is that we would need an array of sensors on both the front and the back of the vehicle, possibly on the corners of the bumpers for the product to be fully useful. It may also be advantageous to add sensors to the sides of the vehicle to allow for detection in those directions. We would also need to do testing with the higher velocities at which vehicles travel to be sure that the sensors could detect them. The final thing that could be considered for real world implementation is to add an automated response to the system. If the sensor saw that there would be a collision without an immediate response, it could apply the brakes for the user. This might be hard to implement, but it greatly increases safety in the vehicle, which could be a big selling point, especially to families with children.

Figure A1.3. Transmitter Circuit Output Figure A1.4. Receiver Circuit

Figure A1.5. Receiver Circuit Amplifier Output Figure A1.6. Receiver Circuit Comparator Output to BSII