[Menu]>[Guide to use the PIC]>[Circuits Gallery]>[Ultrasonic Range Meter]

Improvement of Ultrasonic Range Meter

Actually, it doesn't work as assumed first when assembling a circuit and confirming operation.
I will explain the items which were improved including the point which wasn't normally worked when making this circuit below.

RA4 port
    At first, the control of the reception pulse detector(start/stop) was controlled by RA4 port.
    The RA4 port is a special port in the PIC16F series and I have made same mistakes before.
    The output of the RA4 port is an open type. So, when setting RA4 port to the H level condition, it is only separated from the grounding and it doesn't become H level. To make RA4 H level, the pull-up resistor must be put outside.
    Because mounting space of the printed board was limited at this circuit, I changed to use RA5 port.

Temperature revision data
    The sound wave propagation speed in air changes with the ambient temperature. A distance conversion value is made by A/D converted voltage whitch changed by variable resistor. The change range with this conversion value is very narrow. At first, I used the way that little voltage change by the variable resistor. However, in this way, it wasn't possible to make do stable operation by the influence by the induced voltage from outside. Therefore, I made a voltage change range by the variable resistor from 0 V to 5 V and to cope by the processing of data after A/D conversion. Upper 3 bits of A/D converted data are used as the variable data. With this, the influence of the induction from outside passed away.

Power supply voltage of the receiver circuit
    At first, I made the power supply voltage of the receiver circuit 5V according to PIC. However, I considered the voltage which generates with the receive sensor when receiving a ultrasonic and changed the voltage of the receiver circuit into 9V. In case of 5V, I think that an amplifier is saturated in the signal voltage and it isn't possible to do good detection operation. I am not verifying 5V receiver operation in detail.
    Because the signal holding circuit and PIC operate with 5V, the output of the signal detector(0V-9V) is divided with the resistor and is changed into TTL(0V-5V).

Capture start timing
    The capture function has the possibility to malfunction with the noise. In the first software, I was setting capture operation at the initialization processing. However, in the case, the illegal capture interruption occurred. Therefore, in the initialization processing, I made only the initialization processing of the timer1 to use for the capture. The setting of capture operation is done when starting capture operation (Immediately before the ultrasonic pulse sending-out).

    This circuit handles the analog signal of 40KHz. The level of the analog signal changes subtly by the circuit wiring. For this circuit, the wiring by the printed board considered grounding is better.
    When installing this circuit in the acrylic case, it should install a circuit onto the brass board as the ground board.

Adjustment of the transmission frequency
    40KHz for the ultrasonic is generating by the software. The resonant frequency of the transmission sonar is 40KHz. The transmission frequency must be adjusted to the resonant frequency. The transmission efficiency declines when not fitting. The adjustment of the frequency is done by the number of the steps of the software. It adjusts ON/OFF equally. Connect a simple level meter with the node of D1 and D2 and adjust soft steps for a level to be maximized. It is necessary to do while rewriting software using programmer. The equipment and the reflection board must be fixed to compare in the same environment. It isn't possible to compare when the reflected quantity has changed. This is a little bit hard work.

Length of the transmission pulse
    I set the length of the transmission pulse of this equipment in the 0.5 milliseconds. When the time of the pulse is long, the energy of the ultrasonic is big and the long-range measurement becomes possible. However, when making a transmission pulse long, the signal which influences a receiver increases. Therefore, the guard time must be made long and it becomes not possible to do the measurement of the short distance. The shortest measurement distance is decided by total value of guard time and the pulse sending-out time.(In this circuit, it's 1.5 milliseconds) This time, about 30 cm are the shortest measurement distance.

Calculation for 10th
    There was a mistake in the calculation of the 10th digit in the process which changes the captured distance value into the 100th, 10th, 1st digit. The 10th wasn't increased in case of the 1st digit value is 0, i.e. 10, 20, 30 иии 90. Therefore, the result becomes the value which is insufficient in 10. For example, when making a measuring distance short little by little from 112, it changes like 112, 111, 100(should be 110), 109, 108. This is the cause of the mistake of the following source code.
381        goto    digit_u         ;Yes. "R = 0"
    In this code, when the value(R) that 10 was subtracted is 0, it jumps to the 1st digit process without adding 1 to the 10th count area(disp_t).
    The correction cord is hereinafter.
381        goto    digit_t1        ;Yes. "R = 0"
    When the value that 10 was subtracted is 0, it makes jump to the process for adding 1 to disp_t.
Thank you for Mr. Ooi.