In order to effectively mask the PWM transmission from the receive line,
correct synchronization of the transmit and receive masking signals is necessary. This
is possible by using the "One Ramp" Waveform Generation mode of Timer/Counter Type D
(for more information, refer to the device data sheet). As can be seen in the figure
below, the compare values can be configured to generate two synchronized outputs able to
be used as masks to control transmission and reception utilizing the transducer.
Figure 1. Generation of Synchronized
Transmit and Receive Masking Signals using TCD One Ramp Mode
The different compare values have the following roles and should be
customized according to the hardware being used:
- The CMPASET value is set to
'
0
', indicating that the receive line should be disabled
from the beginning of a measurement cycle (when an ultrasonic burst is being
transmitted)
- The CMPBSET value indicates the
length of a transmission. Decreasing this value will decrease both the minimum
and maximum ranges. Increasing this value will increase the range to a certain
point, however, once there is a part of the reflected burst with no attenuation,
no advantage is gained from increasing transmission time.
- The CMPACLR value indicates when
the receive line is enabled. This value should be customized according to the
hardware being used, and the situational requirements. It should be long enough
that resonance due to nonoptimal hardware is considered, and short enough that
the reflected burst is not masked along with the transmission signal.
- The CMPBCLR value defines the
length of a measurement cycle. This should be long enough that all reflected
signals have been sufficiently attenuated (some signals can bounce back and
forth between the sensor and the barrier several times). Decreasing this value
will also decrease the resolution of measurement calculations (for example,
CMPBCLR = 0xFFF gives a distance measurement resolution of one cm).