Design & Integration Files
- Bill of Materials
- Gerber Files
- PADS Layout Files
- Assembly Drawing
Part Numbers with "Z" indicate RoHS Compliance. Boards checked are needed to evaluate this circuit
- EVAL-CFTL-6V-PWRZ ($17.00) 6V Universal Power Supply
- EVAL-CN0343-EB1Z ($115.00) Ultrasonic Distance Measurement
Features & Benefits
- Self-Contained Ultrasonic Distance Measurement
- 50cm to 10m range
- 2cm resolution
- Small PCB Footprint
Markets and Technologies
Circuit Function & Benefits
The circuit shown in Figure 1 is a completely self-contained distance sensor that utilizes an ultrasonic transmitter and sensitive analog receiver in conjunction with a precision analog micro-controller to provide distance measurements. Unlike complicated PLL-based receivers, the sensor shown in Figure 1 uses a sensitive window comparator circuit, thereby minimizing real estate and cost.
The approximate range is from 50 cm to 10 m with a resolution of about 2 cm. Temperature compensation is provided by the integrated temperature sensor and ADC contained in the microcontroller.
In industrial applications, distance measurement is a common requirement, such as fluid level sensing or sensing the distance between solids. Industrial fluids are often corrosive or contain solids and debris, as in wastewater purification or chemical processing. Therefore, ultrasonic techniques are advantageous because the sensor does not contact the liquid or object directly, as in the case of flotation-based sensors.
For sensing the levels of thick liquids or foamy water, the ultrasonic level sensor is a better choice than capacitance, reed, or float sensors. In very dusty or corrosive environments, the ultrasonic sensor is the sensor of choice.
Ultrasonic Measurement Theory
Figure 2 shows a typical ultrasonic distance measurement system. The time between the transmitted sound and the received sound, t, is used to measure the distance, d:
where CAIR is the velocity of sound.
In the dry air, the speed of sound in m/s is approximately
where T is the temperature in °C.
At 25°C, CAIR = 346.13 m/s. Ultrasonic distance measurements must have temperature compensation to yield accurate results, because the error in the distance measurement due to the velocity variation is approximately 0.18% of the distance for a 1°C error in the temperature measurement.
The acoustic impedance, Z, of a medium is defined as
When sound strikes a medium, the amount reflected is defined by the reflection coefficient, R:
Z1 is the acoustic impedance of air.
Z2 is the acoustic impedance of the medium.
The acoustic impedance of liquids or solids is much greater than that of air, therefore R ~ 1, and most of the sound is reflected.
In a typical system, the ultrasonic transmitter is first driven and emits a short burst at the resonant frequency of the transmitter. The receiver then listens for the echo. When the echo is detected, the time interval is measured by the processor and the distance is calculated.
The receiver must be disabled during the time the transmit pulse occurs until it decays. This time is called the blanking time and it prevents the transmitter from affecting the receiver. The minimum distance the system can measure, dMIN, is determined by the duration of the blanking time, tBLANK.
The maximum distance the system can measure is determined by the sensitivity of the receiver circuit. The resolution of the system is determined by the resolution of the timer.
The ultrasonic ceramic transmitter is a 400ST160 made by Pro-Wave Electronics Corporation. The maximum driving voltage is 20 V rms (57 V p-p), and the resonant frequency is 40 kHz. The transmitter is driven by the ADP3629 dual MOSFET driver connected to the 18 V ADP1613 boost supply. This produces a 36 V p-p differential drive signal. The ADP3629 is driven by the PWM0 and PWM1 outputs of the ADuC7126 precision analog microcontroller. When the PWM output is disabled, the outputs are high, which forces the ADP3629 outputs to ground.
When the ceramic transmitter is driven with the 40 kHz pulse train, it produces a sound wave at the self-resonant frequency of 40 kHz. When the 40 kHz drive signal is removed, it takes approximately 1 ms for the transmitter to stop resonating. This requires a blanking interval of about 2 ms to prevent the receiver from false triggering.
The ADuC7126 precision analog microcontroller has an ARM7TDMI core with 126 kB flash and 32 kB SRAM. The ADuC7126 also contains precision analog peripherals on-chip, including a 12-bit ADC, temperature sensor, reference, and 12-bit DACs. The ADuC7126 is programmed to control the timing and readout functions as well as to perform temperature compensation. The time between the transmit and receive signals is determined by using the ADuC7126 internal timer that operates on a 41 MHz clock.
The receiver consists of a Pro-Wave 400SR160 receiver followed by a two-stage amplifier and a window comparator. The overall circuit acts as a 40 kHz band-pass filter where C10/R6, C16/R10, C30/R15||R17, and C31/R16||R18 are the high-pass sections, and U8A (C13/R4) and U8B (C21/R12) are the low-pass sections. Each stage is tuned for −3 dB bandwidth of 40 kHz. The calculated gain of each stage at 40 kHz is as follows:
- C10/R6, HPF: 0.696
- U8A, LPF: 20.4
- C16/R10, HPF: 0.691
- U8B, LPF: −19.4
- C30/R15||R17: 0.694, C31/R16||R18: 0.701
The total gain at 40 kHz from the receiver transducer to the input of the comparator stage is obtained by multiplying the above values and is approximately 132, or 42.4 dB. The output of the U8B gain stage drives an ADCMP670 dual comparator configured as a window comparator. The bias voltages that set the upper and lower limits of the window voltage are determined by dividers R15/R17 and R16/R18. The nominal window voltages at +INA and −INB are 427.1 mV and 371.4 mV, respectively. The corresponding window width is 55.7 mV. The threshold voltage of the window is set by the ADCMP670 internal reference voltage of 400 mV. When the comparator input signal exceeds the window threshold in either direction, the output INT signal goes low. A change of 25 mV in either direction triggers the INT, corresponding to an input change of approximately 25 mV/132 = 189 μV. The operation of the circuit is as follows:
- Microprocessor enables the interrupt input.
- 40 kHz PWM transmission pulse train generated.
- Transmission detected by receiver, and INT goes low.
- Interrupt time captured by the ADuC7126 internal timer.
- Transmitted pulses stopped.
- Interrupt input disabled for 2 ms blanking period.
- Interrupt input enabled.
- INT goes low when echo signal detected.
- Interrupt time captured by the timer.
- Difference between interrupt times used to calculate distance.
- Temperature compensation performed by digitizing the output of internal temperature sensor with on-chip ADC.
- Result displayed on LCD display.
The interrupt signals from the window comparator are not handled by the microprocessor but are captured by the ADuC7126 internal timer. This minimizes software latency, and the 41.77 MHz timer provides a resolution of 23.9 ns.
The ADuC7126 has a calibrated on-chip temperature sensor and 12-bit ADC that can be used for temperature compensation. Additionally, the ADuC7126 has an on-chip high precision voltage reference which is buffered by the AD8541 and used to generate the high precision window comparator threshold voltages and the common-mode voltage for the AD8692 gain stages.
Window Comparator Design
While some ultrasonic receivers use PLLs driven by variable gain amplifiers (VGAs) to detect the echo, the receiver in Figure 1 uses a high gain two-stage amplifier and a window comparator to convert the 40 kHz sinusoidal transmitted signal and then the received echo signal to digital interrupts.
The ADCMP670 is a precision dual comparator with a 400 mV reference and has one inverting input and one noninverting input, making it suitable for use as a window comparator. The window comparator generates interrupts for both rising edge and falling edge of the echo signal.
In standard atmosphere at 25°C, the 40 kHz ultrasonic wavelength in the air is
If there is a 1 cycle error in the detection of the 40 kHz echo, the corresponding distance error is approximately 8.65 mm/2 = 4.32 mm.
Proper selection of the threshold voltages is critical to the operation of the circuit. If the difference window voltage is too large, there is a loss in sensitivity. On the other hand, if the window voltage is too small, the circuit may produce false interrupts due to noise.
The ADCMP670 dual comparator (3.3 V supply, 0°C to +70°C) must have a +INA threshold of greater than 409 mV and a −INB threshold of less than 383.5 mV. If these conditions are not met under the worst case conditions, then the window comparator does not operate properly.
The following must therefore be considered in selecting the +INA and −INB bias voltages and the corresponding divider resistors, R15, R16, R17, R18:
- Initial accuracy 2.5 V ±5 mV) and temperature variation (15 ppm/°C) of ADuC7126 2.5 V reference voltage.
- Maximum offset voltage over temperature (7 mV) for AD8541.
- Initial tolerance (1%) and temperature coefficient (100 ppm/°C) of bias resistors R15, R16, R17, R18.
Assuming a 25°C ±50° temperature range, the minimum and maximum reference voltage is given by:
For the window comparator not to have spurious triggering, the ADCMP670 input bias voltages must satisfy the following conditions:
To reduce the system cost, choose E24 type 1%, 100 ppm/°C resistors for R15, R16, R17, and R18.
Over a 50°C temperature range, the 1% resistor values can change an additional 0.5%. Therefore the ratios R15:R17 and R16:R18 can be either 3% above or below the nominal value in the worst case.
For the V+INA pin of the ADCMP670:
For the V−INB pin of the ADCMP670:
Assuming nominal values for the resistors and the reference voltage, V+INA = 427.1 mV, V−INB = 371.4 mV, the window voltage is approximately 55.7 mV.
The values of C30 and C31 are selected such that they form 40 kHz high-pass filters with R15||R17 and R16||R18, respectively.
Reference Buffer Circuit
The reference output of the ADuC7126 has only 5 μA drive capability and therefore must be buffered for use in the circuit. The AD8541 was chosen because of its low supply current (45 μA) and single supply capability.
The AD8541 drives a large 10 μF decoupling capacitor required for charge storage and transient suppression. Therefore, the op amp must be properly compensated to maintain stability. Most rail-to-rail output op amps require some type of compensation when driving capacitive loads because their output stage typically has a higher impedance than traditional emitter-follower or source follower stages.
The compensation network used in the circuit consists of R13, R14, and C29. Details for selecting the proper values can be found in the following references: Op Amps Driving Capacitive Loads (Ask the Applications Engineer—25), Analog Dialogue 31-2, Analog Devices and Practical Techniques to Avoid Instability Due to Capacitive Loading (Ask the Applications Engineer—32), Analog Dialogue 38-2, Analog Devices.
Power Supply Circuits
The circuit in Figure 1 is powered from a single external +6 V supply or wall wart. The 5 V and 3.3 V supplies are developed from the ADP7104-5 and ADP7104-3.3 LDOs, respectively.
The 18 V required by the ADP3629 ultrasonic transmitter drivers is supplied by the ADP1613 boost circuit shown in Figure 3. The design is based on the ADP161x downloadable Boost Regulator Design Tool, one of a number of useful power management design tools available at ADIsimPower.
Printed Circuit Board (PCB) Layout Considerations
Because of the clock speeds of the ADuC7126 and the high sensitivity of the receiver circuit, careful attention must be given to excellent PCB layout, grounding, and decoupling techniques. Please refer to Tutorial MT-031 and Tutorial MT-101 for details on grounding and decoupling.
Complete schematics, layouts, Gerber files, and bill of materials for the EVAL-CN0343-EB1Z board can be found in the CN0343 Design Support Package.
The EVAL-CN0343-EB1Z comes pre-loaded with the code required to make distance measurements. The code can be found in the CN0343 Design Support Package at http://www.analog.com/CN0343-DesignSupport in the CN0343-SourceCode.zip file.
The user interface consists of the six push button keys, as shown in Figure 4.
The default functions of the buttons are as follows:
After power-on, the LCD shows the welcome screen for about three seconds:
After the welcome screen, the circuit enters the working mode and displays the home screen, which shows the target distance and the temperature. The temperature displayed is that measured by the ADuC7126. The distance measurement is corrected for the measured temperature.
Distance: X.XXX m
Press the OK key to cause the processor to enter the menu status. The UP, DOWN, LEFT, and RIGHT keys each display different menu items, respectively, Calibrate Temperature, RS-485 Interface Baud Rate, and RS-485 Interface Address.
Display the desired menu item, such as Calibrate Temperature:
Press the OK key and the following display appears:
Set to: YY.Y°C
The temperature set to value (up to ±50°C) is set as follows: Use the LEFT and RIGHT keys to select the numerical digit, and then the UP and DOWN keys to increase or decrease the digit. Repeat this for each temperature digit.
The temperature set to feature allows the user to offset the temperature measured by the ADuC7126 internal sensor and make it agree with the actual air temperature measured for higher accuracy.
Once the desired temperature offset is entered, press the OK key.
Note that pressing the CANCEL key at any time cancels the current operation and returns the user to the previous screen.
The RS-485 baud rate setting is 75 Hz to 250 kHz, and the RS-485 address range is 1 to 255.
The default system settings are: temperature offset, 0°C; RS-485 baud rate, 115200; RS-485 address, 1.
More information regarding the actual ADuC7126 source code can be found in the CN0343 Design Support Package at http://www.analog.com/CN0343-DesignSupport.
Although the maximum drive voltage for the ADP3629 is 18 V, larger sound levels from the transmitter can be achieved by using a higher drive voltage and an analog switch with a higher voltage capability such as the ADG5436. For output voltages greater than 20 V, the ADP1613 boost circuit can be modified by adding an external MOSFET switch as described in the ADP161x downloadable Boost Regulator Design Tool, which is one of a number of useful power management design tools available at ADIsimPower.
Circuit Evaluation & Test
This circuit uses the EVAL-CN0343-EB1Z circuit board.
The following equipment is needed:
- EVAL-CN0343-EB1Z circuit board
- 6 V power supply or wall wart (EVAL-CFTL-6V-PWRZ)
- CN0343 Source Code: http://www.analog.com/CN0343-DesignSupport
Connect the 6 V power supply (EVAL-CFTL-6V-PWRZ) to the EVAL-CN0343-EB1Z circuit board J1.
Turn on the power by connecting the EVAL-CFTL-6V-PWRZ, put the EVAL-CN0343-EB1Z board at the front of target distance in 50 cm to 10 m, and make sure the ultrasonic sensors U3 and U4 are facing the target. The target must have a large, smooth, non-absorbing surface.
Make sure there are no objects within the circular cone angle of about 60° from the sensor. The target surface must be perpendicular to the sensor.
To use the EVAL-CN0343-EB1Z in the standalone mode, the only requirement is to connect the power. To use the board in the network mode, connect a PC with an RS-485 interface, to connect to J2. Pin 1 (close to J1) is the signal B, Pin 2 is GND, and Pin 3 is signal A.
After setting both the EVAL-CN0343-EB1Z and the PC to the same RS-485 baud rate, use the PC to send the xxx query\r\n, where command xxx is the CN0343 decimal address, and \r\n are the return characters. The CN0343 replies to the command with the address, temperature, and distance information.
Connectivity for Prototype Development
The EVAL-CN0343-EB1Z is designed to be powered with the EVAL-CFTL-6V-PWRZ wall wart 6 V power supply. In the standalone working mode, the power supply is the only connection required.
In the network mode, any device with an RS-485 interface can read the results from EVAL-CN0343-EB1Z. The largest numerical address allowed is 255.
A typical PC connection diagram showing an RS-485 to RS-232 adapter is shown in Figure 6.
|AD8541||General-Purpose CMOS Single Rail-to-Rail Amplifier||
|ADM3483||3.3 V, Low Power, RS-485/RS-422 Transceiver (Half Duplex, 250 kbps, Slew Rate Limited, DE/RE)||
|ADP7104||20 V, 500 mA, Low Noise, CMOS LDO||
|AD8692||Low Cost, Low Noise, Dual CMOS Rail-to-Rail Output Operational Amplifier||
|ADP1613||650 kHz /1.3 MHz Step-Up PWM DC-to-DC Switching Converter with 2.0 A Current Limit||
|ADUC7126||Precision Analog Microcontroller, 12-Bit Analog I/O, Large Memory, ARM7TDMI MCU with Enhanced IRQ Handler||
|ADCMP670||Dual Low Power 1.5% Comparator With 400 mV Reference||
|ADP3629||High Speed, Dual, 2 A MOSFET Driver, inverting A/B input pins||