Thursday, April 2, 2009

Ultrasonic Distance Sensor with the Microcontroller 1


Ultrasonic Distance Sensor Implemented
with the Microcontroller Project

Linear measurement is a problem that a lot of
applications in the industrial and consumer market
segment have to contend with. Ultrasonic technology is
one of the solutions used by the industry. However, an
optimized balance between cost and features are a must
for almost all target applications. The ultrasonic distance
measurer (UDM) is used mainly when a non-contact
measurer is required. This is the type of solution this
document explains using a simple robot toy
implementation.

Description
The UDM is a demo that shows capability and performance
of the MC9RS08KA2 and the ultrasonic sensor to build a
distance measurer. Figure 2 shows the basic building block of
this project.


The firmware generates a 40 kHz burst signal. After the 10 cycle
burst is completed, a variable that measures the distance is
activated. This variable measures the time sound takes to rebound
and is used for distance calculation.

The burst signal goes to the ultrasonic transmitter (US Tx) and is
transmitted as ultrasound through the air Figure 2. When the wave
is reflected off an object, this wave is captured by the ultrasonic
receiver (US Rx.) This received signal is amplified because it
attenuates as it travels. Afterwards, the signal goes back to the
microcontroller unit (MCU), filters it and calculates the distance.
A 40 kHz interrupt is generated by the timer in the MCU. To
perform this, the keyboard interrupt (KBI) is enabled and detects
the external signal. Every time the MCU is interrupted the counter
is increased by three. And the variable used as a counter is
decreased by one for the entrances to the modulus timer module
(MTIM) interrupt service routine (ISR). When this variable is bigger
than eight the ECHO signal is activated. The distance variable is then
set to 0. Refer to Figure 3 for timing diagram. For detailed information
about the firmware see Figure 3.


More pdf


Distance Sensing Project
devices for wireless distance and position determination
usefull as gesture controllers for robotic musical instruments
Since the early seventies we did build sonar devices to control our
self made analog electronic music synthesizers. In those years,
simple to use transducers were not readily available on the
electronic component market and so, we had to make our own,
based on designs used for underwater hydrophones. (Quarz crystals,
inductive devices, self made condensor microphones etc...). Although
the focus of our research later on became doppler based sonar
and radar movement detection and gesture analysis, we always had
quite a few pulsed sonar devices at hand. The easiest and cheapest
ones to build nowadays make use of the commonly available 40kHz
transducers. Two approaches are possible: either one uses a single
transducer as an emitter for a periodic burst of sinewaves and that
then is switched to microphone mode and connected to the input of a
voltage controlled amp (preferably a logamp, compensating for the
square law decay of amplitude with distance). The time between the
start of the burst and the reception of the first echo is a linear function
of the straight distance from the tranducer to the reflective object or
body.


Relate Post