📜 ⬆️ ⬇️

Homemade phase laser range finder

image
In the article I will talk about how I did the laser range finder and about the principle of its work. Immediately, I note that the design is a layout, and it cannot be used for practical use. It was done only in order to make sure that the phase rangefinder is really to collect yourself.


Theory


Often it is necessary to meet the opinion that with the help of a laser the distance is measured only by direct measurement of the time of flight of a laser pulse from the laser to the reflecting object and back. In fact, this method (it is called pulsed or time-of-flight, TOF) is used mainly in cases where the distance to the desired object is large enough (> 100 m). Since the speed of light is very high, in a single laser pulse it is quite difficult to measure the time of flight of light, and therefore the distance, with great accuracy. The light passes 1 meter in about 3.3 ns, so the time measurement accuracy should be nanosecond, although the accuracy of the distance measurement will still be tens of centimeters. To measure the time intervals with such accuracy use FPGA and specialized chips.

image
However, there are other laser methods for changing distances, one of which is phase. In this method, unlike the previous one, the laser operates continuously, but its radiation is amplitude modulated by a signal of a certain frequency (usually it is less than 500 MHz). I note that the laser wavelength remains unchanged (it is in the range of 500 - 1100 nm).
The radiation reflected from the object is received by the photodetector, and its phase is compared with the phase of the reference signal - from the laser. The presence of a delay in the propagation of a wave creates a phase shift, which is measured by a rangefinder.
The distance is determined by the formula:

Where c is the speed of light, f is the laser modulation frequency, ph is the phase shift.
This formula is valid only if the distance to the object is less than half the wavelength of the modulating signal, which is equal to c / 2f.
If the modulation frequency is 10 MHz, then the measured distance can be up to 15 meters, and when the distance changes from 0 to 15 meters, the phase difference will change from 0 to 360 degrees. A change in the phase shift of 1 degree in this case corresponds to a movement of the object by about 4 cm.
When this distance is exceeded, ambiguity occurs - it is impossible to determine how many periods of the wave fit into the measured distance. To resolve the ambiguity, the modulation frequency of the laser is switched, after which the resulting system of equations is solved.
The simplest case is the use of two frequencies, the distance to the object is approximately determined at a low (but the maximum distance is still limited), the distance is determined at a high with the required accuracy - with the same accuracy of phase shift measurement, with high frequency the distance measurement accuracy will be much higher.
')
Since there are relatively simple ways to measure the phase shift with high accuracy, the accuracy of the distance measurement in such rangefinders can be up to 0.5 mm. It is the phase principle that is used in range finders that require high measurement accuracy - geodesic range finders, laser tape measures, scanning range finders mounted on robots.
However, the method also has drawbacks - the radiation power of a constantly operating laser is noticeably less than that of a pulsed laser, which does not allow the use of phase rangefinders for measuring large distances. In addition, the phase measurement with the required accuracy can take some time, which limits the speed of the device.

The most important process in such a rangefinder is the measurement of the phase difference of the signals, which determines the accuracy of the distance measurement. There are various ways to measure phase difference, both analog and digital. Analog is much simpler, digital give greater accuracy. In this case, using digital methods to measure the phase difference of high-frequency signals is more difficult - the time delay between signals is measured in nanoseconds (this delay occurs the same as in a pulse rangefinder).

In order to simplify the task, heterodyne conversion of signals is used - the signals from the photodetector and the laser are separately mixed with a signal of close frequency, which is formed by an additional generator - local oscillator. The frequencies of the modulating signal and the local oscillator differ by kilohertz or megahertz units. From the received signals using the low-pass filter, the signals of the difference frequency are extracted.

An example of a block diagram of a range finder with a local oscillator. M - laser modulation signal generator; G - local oscillator.

The phase difference of the signals in this conversion does not change. After that, the phase difference of the obtained low-frequency signals is measured by digital methods much easier - you can easily digitize signals with a low-speed ADC, or measure the delay between signals (it decreases noticeably with decreasing frequency) with a counter. Both methods are quite simple to implement on a microcontroller.

There is another way to measure phase difference - digital synchronous detection. If the frequency of the modulating signal is not very high (less than 15 MHz), then such a signal can be digitized by a high-speed ADC synchronized with the laser modulation signal. From the Kotelnikov theorem, it follows that the sampling frequency in this case should be twice as high as the laser modulation frequency. However, since a narrowband signal is being digitized (except for the modulation frequency, there are no other signals at the ADC input), a subsampling method can be used, thanks to which the ADC sampling frequency can be markedly reduced to units of megahertz. It is clear that the analog part of the rangefinder is simplified.
In more detail (with all the necessary formulas) this method is considered here (in English) and here (in Russian) .
The first article states that if the signal sampling rate (fsp) is related to the modulation frequency (fo) as follows:

where p is an integer, the phase calculation process is greatly simplified.
It is enough to take N samples of the signal X [i], after which the phase difference can be calculated by the following formulas:

I note that both of the above methods are often used together - low-frequency signals are fed directly to the ADC, high-frequency signals are transferred to lower frequencies due to the heterodyne conversion, and also fed to the ADC.

It is the second version of the phase meter, using 10 MHz modulation frequency, that I decided to implement in my layout a range finder.

Practice


The block diagram of my rangefinder:


In fact, the whole structure consists of 3 parts - a debug board with a microcontroller, a laser signal amplifier with the laser itself, and a photo-receiver with an amplifier and a filter.
In the above theory it was assumed that the laser radiation is modulated by a sinusoidal signal. It is not easy to form such a signal with a frequency of 10 MHz using a controller, so in my design I am applying a 10 MHz square wave to the laser. After amplifying the signal from the photodetector, unnecessary harmonics are cut off from the received signal by a band-pass LC filter tuned to a frequency of 10 MHz, with the result that a signal very close to sinusoidal appears at the filter output.

Analog part circuit (laser amplifier and receiver part):

The scheme was taken from the Ronja laser communication project , the description is in Russian . In this project, data transfer with a speed of 10Mbit is just implemented, which corresponds to the selected modulation frequency.
As can be seen from the diagram - the power amplifier for the laser is the simplest, assembled on a 74HC04 chip (contains 6 inverters). The inclusion of the chip is not entirely correct, but it works. The current through the laser is limited by resistors (also not the best solution). The power supply voltage of 5V for the amplifier is taken from the debug board.
In order for the signal from the amplifier not to be directed to the rest of the circuit, the amplifier body is made of metal, all wires are shielded.
The laser itself (red) is taken from a DVD burner, its power can be set high enough, and it is guaranteed to operate at a frequency of 10 MHz.

The receiver consists of a photodiode and an amplifier assembled on a field-effect transistor and a chip-high-speed amplifier. Since the illumination of the photodiode decreases strongly with increasing distance, the gain must be sufficiently large (in this scheme, it is approximately 4000). In addition, with increasing frequency, the signal at the output of the photodiode noticeably decreases (its capacity affects). I note that the amplifier in this design is the most important and most whimsical part. As it turned out, its gain is clearly not enough. Initially, I assumed that the gain could be changed (in order to attenuate the signal when it was too large), the scheme used allows doing this by changing the voltage on the second gate of the transistor. However, it turned out that when the gain changes, the phase shift introduced by the amplifier changes sufficiently, which degrades the accuracy of the distance measurement, so we had to set the gain to maximum by applying a 3V voltage from the battery to the gate of the transistor.
The receiver requires 12V for operation, so you have to use a separate power supply to power it.
The amplifier is very sensitive to external interference, so it must also be shielded. I took the finished case from a non-working optical sensor, and placed the amplifier in it (white stripe - foil for additional photodiode shielding):

I note that the pickup of the signal from the laser to the receiver rather worsens the accuracy of measuring the phase difference, so you need to control that there is no such pickup.

LC filter used in the rangefinder - taken from the receiver . Since the filter cuts off the DC component of the signal, and does not perceive negative signals from the ADC, it has to be added using the resistor divider R15, R16. The constant voltage applied to the divider is taken from the debug board (VCC).

Debug board - STM32F4-DISCOVERY. I chose it because for the formation of two sufficiently different frequencies a generator of sufficiently high frequency is needed (PLL STM32F4 can produce frequencies greater than 100 MHz).
In the formula linking the modulation and sampling frequencies, the “p” coefficient I assumed to be 6, so that at a modulation frequency of 10 MHz, the sampling frequency should be 1.6 MHz.

To generate a frequency of 10 MHz, a timer TIM2 is used, which operates in the PWM signal generation mode. With a system frequency of 160 MHz, its period is 16 ticks.
The ADC receives start requests from timer TIM2. To form a frequency of 1.6 MHz, its period is 100 "ticks". All data from the ADC using DMA are stored in an array, the size of which must be equal to two in the N degree. Both timers, ADC and DMA run once when turned on and are no longer disabled. Thus, since the timers are clocked from one source, and four data samples correspond to one period of the measured signal, it turns out that an integer number of signal periods always fall into the array.
Since it is not desirable to stop the DMA (this simplifies the management of data capture), when the first half of the array is filled, an interrupt is generated. Having found that half of the array is full, the controller copies its contents to another array (in order to simplify the program, the second half of the main array is not used). After that, the obtained data is processed - the average amplitude and phase of the signal are calculated, the phase shift is recalculated into the distance.
The obtained values ​​are displayed on the LCD indicator from the cash register, also connected to the debug board.

The range finder should know where the origin is. To calibrate it when turned on, the object is set at a “zero” distance from the range finder, after which a button is pressed on the debug board, the measured distance value is recorded in memory, after which this value will be subtracted from the distance measured by the range finder.

As I noted above, automatic gain control failed. In this case, a change in the amplitude of the received signal leads to a change in the phase shifts in the amplifier, and, consequently, to additional errors.
Therefore, I had to adjust the illumination of the photodiode with the help of a mechanical flap, turned by a servo - when the illumination is too high, the flap blocks the light flux. The PWM signal for controlling the drive is generated by the timer TIM3.

About optics. Without it, the range finder is impossible. Its design is clearly visible in the photos below. The laser is located inside a plastic tube installed vertically. A small sleeve with a mirror prism is inserted into it. The sleeve can be rotated, raised and lowered, thus moving the laser beam. Since I guessed that the gain was not enough, I used a large Fresnel lens to receive the signal.
Since the laser, lens and photodiode are aligned, then at close distances the laser closes its own beam from the photodiode. To compensate for this effect, I installed a second lens (magnifier with a rim), although the effect is not completely eliminated, so the maximum signal is observed at a distance of about 50-70 cm from the laser.

And here are the photos of the resulting structure:

On the indicator, the first number is the amplitude in ADC units, the second number is the distance in centimeters from the edge of the board.





Video of the rangefinder:


The range of the resulting rangefinder came out quite small: 1.5-2 m, depending on the reflection coefficient of the object.
In order to increase the range, you can use a special reflector, which will need to direct the laser beam.
For experiments, I made a lens reflector consisting of a lens in which the focus is matte paper. This design reflects the light at the same point from which it was released, however, the beam diameter increases.
Photo reflector:


Using a reflector:

As can be seen, the distance to the reflector is 6.4 meters (in reality, it was approximately 6.3). The signal increases so much that it has to be attenuated, directing the laser beam to the edge of the reflector.

The accuracy of the resulting rangefinder is 1-2 centimeters, which corresponds to the accuracy of measuring the phase shift - 0.2-0.5 degrees. At the same time, to achieve such accuracy, the data have to be averaged too long - it takes 0.5 seconds for one measurement. Perhaps this is due to the use of PLL to generate signals - it has quite a big jitter. Although I think that for an improvised layout, the analog part of which is made rather clumsily, in which there are quite long wires, even such accuracy is pretty good.
I note that I could not find on the Internet a single existing project of a phase rangefinder (at least with the design scheme), which was the reason for writing this article.

Controller program: link

Source: https://habr.com/ru/post/213749/


All Articles