circuitcellar.com
Magazine Support   Digital Library   Products & Services   Suppliers Directory 
 
 





 

Issue 150 January 2003
The PSoC RangeFinder
A Simple Ultrasonic Distance Meter


PRACTICAL CONSTRUCTION

Constructing the circuit isn’t difficult. It will take you just a few minutes. You may download the single-sided PCB design from the Circuit Cellar ftp site. The corresponding component layout is available on the ftp site, as well.

First, you have to mount the two wire links. The links are followed by the microcontroller socket, two resistors (mounted vertically), and two capacitors. Pay attention to the polarity of C2, which is a tantalum electrolytic capacitor. Follow with the two headers and jumper. J1 is a four-pin male header for the power supply and output connections. J2 is a 14-pin female header for the LCD connection.

The two ultrasonic transducers are soldered directly to the copper-sided padstacks. These common 40-kHz ultrasonic transducers are the kind used in car alarms. Make sure you position the two ultrasonic transducers correctly. Usually, the negative terminal is soldered to the case for good noise immunity. You can make the connection to the LCD by soldering a 14-pin male connection to the LCD module with a flat ribbon cable or a set of individual flexible wires. After a final inspection of the populated board, you can insert a programmed PSoC microcontroller into its 28-pin socket.

POWER AND CALIBRATION

This circuit needs a 5-V regulated and filtered power supply. Because of the reduced circuit size, the voltage regulator is not included. If an external 5-V power source isn’t available and all you have is an unregulated 8-V supply, you can use a three-legged voltage regulator (i.e., 78L05 at 5 V–100 mA maximum) and some capacitors to increase ripple rejection and transient behavior.

You must calibrate the unit before it’s installed. The calibration procedure is simple. First, place the rangefinder 50 cm in front of a perpendicular, flat obstacle (e.g., a wall or wood panel). Second, remove jumper JP1 and power up the circuit by connecting the 5-V regulated power supply. Finally, insert jumper JP1 and power down the circuit. At this point the circuit is calibrated and the offset value is stored in EEPROM. The value will be read from the software at each circuit power-up and used in the distance calculating operation.

Figure 5 shows the text displayed on the LCD in Normal and Calibration modes. This text is easy to change, because it’s stored as ASCII strings. You may download the strings from the main.asm file on the Circuit Cellar ftp site.

(Click here to enlarge)

Figure 5—The LCD text that appears in Normal and Calibration mode is fairly easy to change. Note that NNN represents the measured value.