Ultrasonic Distance Gun
2016-05-11 | By Onurhan Öztürk
License: General Public License
Project Description
This project is designed to measure distances using ultrasonic sensors. An MSP430G2553 microcontroller, Parallax 28015 ultrasonic distance sensor, and a Newhaven C0216CZ LCD display are used to measure distances in the range of 3cm to 3m. This project also discusses the use of decoupling caps, power and ground planes and switching boost regulators.
Introduction
- Basics of Ultrasonic Distance Measuring
- Basic Principle - Measuring distance with the properties of ultrasonic sound is easy to understand. It basically consists of a transmitter and a receiver transducer. A transmitter transducer transforms electrical energy into sound energy using ultrasonic waves. When propagating sound waves hit an object in their path, they reflect back to the receiver. Since the speed of sound in a medium is known, with the time difference between start of the transmission and end of the transmission, you can easily calculate the distance between source and the object.
- Effects of Ambient Temperature - The speed of sound waves in a medium is the primary parameter for measuring the distance. Therefore,it is important to keep in mind that speed of sound waves changes according the medium’s temperature. In order to compensate this error, MSP430G2553 microcontroller has to be calibrated in this project.
- Parallax 28015 Ultrasonic Distance Sensor
- Overview - 28015 ultrasonic distance sensor from Parallax Inc. is a ready to use sensor that can measure distances as little as 2 cm up to 3 m. It has only 1 pin to communicate with MCU which is very helpful in limited IO pin projects. 28015 requires 5VDC for normal operations and it is compatible with 5V TTL or 3.3V CMOS microcontrollers.
- Communication Protocol - When SIG pin is triggered high by MCU, (typically 5us) sensor will hold off for 750us. After this period 28015 will rise SIG pin to 5V indicating that the measurement has started. When 28015 detects a valid reflected sound wave it will lower the SIG pin to 0V indicating that the measurement is complete. Time difference between the rising edge and the falling edge of this signal is the amount of time that sound wave propagated in medium.
- Newhaven C0216CZ LCD Display
- Overview - NHD-C0216CZ is a chip-on-glass liquid crystal display module from Newhaven Inc. It has a built in ST7032 microcontroller, 2 lines with total of 32 characters and a 4 line serial interface. Total number of characters that are available in LCD is 240 and It is designed to work with voltage supplies from 2.7V to 3.3V DC. Backlight only consumes 15mA of current which makes NHD-C0216CZ suitable for battery powered applications.
- Communication Protocol - Each character on LCD represents a specific memory location at DDRAM. Using serial interface an MCU can easily read or write necessary binary blocks to these memories to get LCD display working. DDRAM addresses of LCD are straight forward which helps programmers to use loops in their code easily. For example first character located at the upper left corner starts with a DDRAM address of 00 and upper last character ends with a DDRAM address of 0F. Internal character table is designed according ASCII table which allows programmers to both save from mcu memory and time consuming chart arrangements.
NHD-C0216CZ has three different instruction tables. First table is a combined table of read and write commands where the second and third tables are all write commands depending on IS bit of Function Set register. Minimum clock period should be 200ns in order to make LCD work properly. It is always a good practice to give LCD more than that time.
Design
- Schematic
- LTC3525-3.3 - LTC3525-3 is a step-up boost converter with a built in schottky diode and a fixed 3.3VDC output. An extra 22uF tantalum-polymer capacitor is placed on VIN to compensate battery which is located more than few inches away.
- LTC3525-5 - LTC3525-5 is a step-up boost converter with a built in schottky diode and a fixed 5VDC output. An extra 22uF tantalum-polymer capacitor is placed on VIN to compensate battery which is located more than few inches away. Shdn pin is driven by MCU which allows to lower the current consumption in idle mode.
- Newhaven LCD Display - C8 is a decoupling capacitor placed on VDD of LCD. C6 is a buffer capacitor for the internal DC/DC converter of LCD, which should be connected to either VDD or VSS. In this case it is connected to 3.3V. C5 is a part of internal voltage booster circuit while R2 is just a current limiting resistor in series.
- Decoupling Capacitors - Even though DC power supplies are so called “DC”, they are not perfectly pure in real life and especially when a voltage regulator is added to system. When looked closely enough it is easy to see that there are fluctuations on DC voltage level depending on the source and regulation type. SMPS (Switch Mode Power Supplies) have the most fluctuations. These fluctuations can cause real problems in sensitive devices like op-amps. For example, a high enough noise at power rail can interfere and superposition on top of the output voltage. In order to prevent this, a capacitor as close as possible to IC must be connected between power pin and ground. Capacitor will act like a low-pass filter and filter out the high frequency ripples. For ripple reduction a capacitor around 0.1uF is usually enough. Generally a ceramic capacitor is preferred for this application due to low equivalent series resistance (ESR) they have. (Decoupling Techniques)
Another important power rail problem is instantaneous current consumption of the MCU. An integrated circuit is made up of hundreds of components which require different currents for normal operations. Their required current can change in nanoseconds. If power supply is located relatively far from MCU, extra current coming due to instantaneous change can exhibit inductive effects on transmission line which may eventually cause a voltage drop across the line. To prevent this usually a 10uF tantalum capacitor is connected between ground and power rail as a backup capacitor. Instead of pulling an instantaneous current from source, C2 will discharge in order to compensate MCU’s required current consumption
For more information about “the effectiveness of using the parallel combination of large-value and small-value capacitors” please refer to article Effectiveness of Multiple Decoupling Capacitors by Paul,Clayton R. from University of Kentucky published by IEEE.
- Software
- PCB Layout
- Component Selection - Inductors that are used in LTC3525 boost converters must have a value between 4.7uH and 15uH. Inductors should be able to stand peak currents up to 400mA without saturating, in other words without losing their inductive properties. Series resistance of inductors should be less than 0.5?. However lower resistance will result in better performances. Input capacitors should be ceramic since these caps exhibit lower ESR(equivalent series resistance). Output capacitor to smooth the regulated voltage should also be a ceramic capacitor with a temperature coefficient X7R or X5R, not Y5V. 22uF will be sufficient for this cap.
- Component Placement - All decoupling caps should be as close as possible to their IC. Inductors and capacitors of boost regulators must be as close possible to LTC3525 chips.
- Planes - Using a switching regulator in a PCB is serious issue and they require careful attention to planes in order to work with maximum efficiency. Planes designed without a careful attention may end up in poorly or even not working boost regulators. Please follow the recommended layout provided by Linear Technologies.
Conclusion
Measuring the distance between two objects can be a necessary function in robotics applications. Therefore we believe that 28015 built-in sensor allows users to effectively measure the distance between two objects using only 1 pin of a microcontroller. A good example can be the park sensors located at the rear bumper. This project also demonstrated the some usages C0216CZ 16x2 LCD display.
Have questions or comments? Continue the conversation on TechForum, DigiKey's online community and technical resource.
Visit TechForum