Laser Rangefinder Reference Design · 2020-07-08 · Laser Rangefinder Reference Design WAS-18A1EN...
Transcript of Laser Rangefinder Reference Design · 2020-07-08 · Laser Rangefinder Reference Design WAS-18A1EN...
Laser Rangefinder Reference Design
WAS-18A1EN V1.00 1 / 14 July 1, 2020
Laser Rangefinder Reference Design
D/N: WAS-18A1EN
Introduction
There are many techniques for laser rangefinding. The Holtek laser rangefinder adopts a phase
method, which is one of the Time-of-Flight (TOF) technologies. The advantage of the phase method
is that it provides higher accuracy, which can reach up to the millimeter level. However, the phase
method requires more complex calculations, for which asynchronous sampling synchronization,
differential frequency phase measurement, Fourier transformation, distance synthesis and other
algorithms are required. Holtek has integrated these complex operating principles mentioned above
into this solution, providing users with a reference to enable product development cycles to be
effectively reduced.
Figure 1
Applications
Indoor distance measurements
Laser Rangefinder Reference Design
WAS-18A1EN V1.00 2 / 14 July 1, 2020
Solution Features
1. Laser ranging function: use a laser to quickly and accurately measure the distance to an object.
Laser measurements provides higher accuracy than ultrasonic measurement methods and is less
susceptible to external interference. However, laser rangefinders require a more complex and
quick calculation capability, therefore for this reason the 32-bit Arm® Cortex®-M0+ based MCU
HT32F52352 is used.
2. The phase method (TOF method): measures the phase delay generated by a laser round-trip to
calculate the actual object distance, here the theoretical measurement accuracy can reach up to
the millimeter level.
Algorithm Principle Description
Algorithm Process
Laser distance calculations can be divided into three parts. These are laser echo signal acquisition,
echo signal phase calculation and distance synthesis calculation. Attention should be paid to the
sampling time point of the laser echo signals on the internal and external optical path. A fast Fourier
transform (FFT) algorithm is then applied to the captured echo signals to obtain the echo signal phase,
after that, several groups of different measurement rulers are used to calculate the actual length.
Start
Laser echo signal acquisition(Four frequencies, internal & external optical path, 8 groups of data in total)
Echo signal phase ranging calculation(Four groups of direct rulers, six groups of indirect rulers)
Distance synthesis calculation
END
Figure 2
Laser Rangefinder Reference Design
WAS-18A1EN V1.00 3 / 14 July 1, 2020
Differential Frequency Phase Measurement
This algorithm uses the differential frequency phase measurement principle. A clock chip is used to
generate a high frequency main oscillation signal and local oscillation signal. The main oscillation
frequency is used to modulate the laser while the local oscillation signal is overlaid on the APD
backward voltage. The main oscillation signal and local oscillation signal are mixed by a frequency
mixer circuit to produce a invariant phase low frequency signal. This process provides a reduced
circuit complexity as well as making it easier for MCU echo signal acquisition.
Modulation Optical Frequency First Group Second Group Third Group Fourth Group Main Oscillation Frequency (MHz) 152 153 160 200 Local Oscillation Frequency (MHz) 151.99 152.99 159.99 199.99 Differential Frequency 10kHz
Table 1
It can be seen from the above table that the echo signal frequency passed through the frequency
mixer circuit is 10kHz, therefore the MCU can use the ADC to capture the echo signals.
Laser Echo Signal Acquisition
The laser rangefinder echo signal frequency is a 10kHz sinusoidal signal. By using the HT32F52352
internal ADC together with the PDMA function, the echo signals can be captured quickly and
accurately.
Figure 3
This algorithm uses four optical modulation signals with different frequencies to implement
distance measurement. The echo signal of each ruler corresponds to two signals on an internal
optical path and external optical path. By calculating the phase difference between the signals on
the external optical path and the internal optical path, the distance value measured by this
measurement ruler can be obtained.
Laser Rangefinder Reference Design
WAS-18A1EN V1.00 4 / 14 July 1, 2020
Figure 4
To implement the distance measurement of a ruler, it is necessary to capture the phase difference
between the signals on the internal and external optical paths with high accuracy. In this algorithm,
the ADC function is used together with the PDMA function to accurately control the time and
interval of the ADC capture operation. An FFT operation is then applied to the captured data to
calculate the phase value of each echo signal.
Phase Ranging Calculation Figure 5 shows the phase method laser ranging principle diagram. It can be seen that the distance
is given by D = 12
× c × t, (c: speed of light, t: time difference), assuming that the modulation
frequency is f, then the modulation signal wavelength λ = C𝑓𝑓 , the phase delay generated in a laser
round-trip over the distance to be measured D is φ, then the corresponding time difference will be
t = T × φ / 2π (T: modulation light period). As a result, the distance to be measured, D, can be
calculated by the following equation:
D =12
× 𝑐𝑐 × 𝑡𝑡 =12 ×
c𝑓𝑓 ×
φ2𝜋𝜋 =
λ2 �𝑁𝑁 +
Δφ2𝜋𝜋� = 𝐿𝐿𝐿𝐿(𝑁𝑁 + Δ𝑁𝑁)
(Ruler length 𝐿𝐿𝐿𝐿 =λ2
,𝑁𝑁: 2𝜋𝜋 integer multiple,Δ𝑁𝑁: 2𝜋𝜋 𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟 𝑓𝑓𝑟𝑟𝑟𝑟𝑐𝑐𝑡𝑡𝑟𝑟𝑓𝑓𝑟𝑟𝑟𝑟𝑓𝑓 𝑝𝑝𝑟𝑟𝑟𝑟𝑡𝑡)
Distance D Δϕ Wavelength λ
Laser Emitter
Laser Receiver
ϕ Figure 5
Laser Rangefinder Reference Design
WAS-18A1EN V1.00 5 / 14 July 1, 2020
Direct and Indirect Measurement Rulers
In this solution, the minimum measurement ruler frequency used by the rangefinder is 152MHz.
According to the measurement ruler length formula mentioned above, the corresponding maximum
direct measurement ruler length is 0.987m, which is not able to support long distance measurements.
For this reason, an indirect measurement ruler is utilised to implement long distance measurements.
The difference of any two direct ruler frequencies can be used as a new indirect ruler frequency, the
length of which is determined by the indirect ruler frequency. The phase difference is calculated by
the difference between the phase difference of the two original direct rulers.
The corresponding direct and indirect measurement rulers for this solution is shown in Table 2. For
example, an indirect ruler signal of 40MHz can be obtained from two ruler frequencies of 200MHz
and 160MHz, and the indirect ruler length is 3.75m; an indirect ruler signal of 1MHz can be
obtained from two ruler frequency signals of 152MHz and 153MHz, and the indirect ruler length
is 150m.
Measurement ruler length (𝐿𝐿) =Speed of light (𝑐𝑐)2 × frequency (𝑓𝑓)
Direct Ruler
Modulation Frequency 200MHz 160MHz 153MHz 152MHz
Ruler Length 0.75m 0.9375m 0.9805m 0.987m
Indirect Ruler
Modulation Frequency 48MHz 47MHz 40MHz 8MHz 7MHz 1MHz
Ruler Length 3.125m 3.1915m 3.75m 18.75m 21.42m 150m
Table 2
Distance Synthesis Calculation
This algorithm uses a total of 10 groups of measurement rulers, the length of which are 150m,
21.42m, 18.75m, 3.75m, 3.19m, 3.12m, 0.98m, 0.98m, 0.93m, 0.75m respectively. According to
the above formula, it can be seen that specific rulers can only reach the distance whose
corresponding phase difference does not fulfill 2π, i.e. the maximum measuring range of each ruler
will not exceed its ruler length.
In order to ensure ranging accuracy, a small measurement ruler is needed. However, in order to
ensure the measurement distance, a longer measurement ruler is needed. Therefore, it is necessary
to use the multiple measurement ruler connection algorithm to obtain both high accuracy and long
distance measurement.
When more than two measurement rulers are used for distance measurement, assuming that the
ruler lengths are 𝐿𝐿𝐿𝐿1, 𝐿𝐿𝐿𝐿2, 𝐿𝐿𝐿𝐿3 … respectively with a relationship of 𝐿𝐿𝐿𝐿1 > 𝐿𝐿𝐿𝐿2 > 𝐿𝐿𝐿𝐿3 > ⋯, in
which Ls1 is greater than the distance to be measured, therefore N1 = 0:
D1 = 𝐿𝐿𝐿𝐿1 × (𝑁𝑁1 + ∆𝑁𝑁1) = 𝐿𝐿𝐿𝐿1 × ∆𝑁𝑁1
Substitute the first ruler calculated distance in the secondary ruler equation and the result is:
D2 = 𝐿𝐿𝐿𝐿2 × �int �𝐿𝐿𝐿𝐿1 × ∆𝑁𝑁1
𝐿𝐿𝐿𝐿2� + 𝛥𝛥𝑁𝑁2�
Laser Rangefinder Reference Design
WAS-18A1EN V1.00 6 / 14 July 1, 2020
As a result, the ith calculation result will be:
D𝑖𝑖 = 𝐿𝐿𝐿𝐿𝑖𝑖 × �int �D𝑖𝑖−1
𝐿𝐿𝐿𝐿𝑖𝑖� + 𝛥𝛥𝑁𝑁𝑖𝑖�
In this way, the final synthesized distance can be obtained.
Operating Principles
A laser rangefinder is composed of a master control board, laser receiver board and keypad. The master
control board includes an integrated HT32F52352 MCU, which can control the laser transmission and
reception, and calculate the distance between rangefinder and object. The laser receiver board is
mainly used for laser echo signal reception and amplification, the amplified signals will be sent back
to the master MCU. Refer to the following chapters for a more detailed introduction.
Hardware Description
Figure 6
According to their functions, the laser rangefinder master board can be subdivided into several parts.
These include the Master MCU circuit, power control circuit, accelerometer circuit, APD high voltage
bias circuit, oscillator signal coupling circuit and laser modulation transmitting circuit. The master
MCU circuit contains the HT32F52352 MCU mentioned above and the peripheral basic circuits. The
power control circuit provides power-related control such as the USB power supply, battery charging
management and device power regulation, etc. The product current state can be obtained via the
accelerometer circuit, in which the angle can be calculated for calculations in other modes including
Laser Rangefinder Reference Design
WAS-18A1EN V1.00 7 / 14 July 1, 2020
Pythagoras algorithm (2-point), Pythagoras algorithm (3-point), height measurement, level
measurement, etc. The APD high voltage bias circuit is used to provide a laser receiving required
voltage. The laser echo receiving sensitivity can be adjusted by controlling this voltage. The oscillator
signal coupling circuit will overlay a high frequency signal during laser transmitting and use a
frequency to couple with the echo signal during laser receiving. Finally, the echo signal phase can be
obtained via differential frequency phase measurement. The laser modulation circuit is used for laser
transmitting adjustment power control.
The laser rangefinder in this solution adopts a phase measurement method. Two laser emitters are
used for internal and external optical paths and the laser echo signal is received by the same laser
receiver. The distance between the rangefinder and an object can be calculated by the phase
difference of the laser signals on the internal and external optical paths. If the distance is short, the
phase difference of the internal and external optical paths is less, otherwise the phase difference
will increase if the distance is far. The phase calculation uses a Fast Fourier Transform (FFT)
algorithm. Several different frequencies are applied to measure the object with the same distance
to obtain an accurate distance value.
Layout and Hardware Considerations
Figure 7 and Figure 8 show the front view and back view of the master board PCB layout.
Figure 7. PCB Layout Front View
Figure 8. PCB Layout Back View
Laser Rangefinder Reference Design
WAS-18A1EN V1.00 8 / 14 July 1, 2020
PCB BOM Table
Laser Rangefinder Reference Design
WAS-18A1EN V1.00 9 / 14 July 1, 2020
Software Description
Start
初始化
Key scan
Measurement key is pressed?
Mode key is pressed?
Reference/Unit key is pressed?
History key is pressed?
Read history
Refresh TFT-LCD
Switch reference/unit mode
Switch measurement mode
Distance measurement
Mute key is pressed?
Disable buzzer
Clear key is pressed?
Clear data
Y
Wake up?
Key scan
N
N
Power key is pressed?
Wait for external interrupt wakeup
N N N
N N N
YY
YYYY
Y
System sleep
Initialisation
初始化 Library function
Other mode calculation
When the system is started the peripheral functions are initialised first, including ADC, PDMA, PWM
and other functions required for measurement. The measurement-related initialisation can be
implemented by calling the library function named Laser_SysInit.
The main function of laser rangefinder is distance measurement which can be implemented by directly
calling the library function named Laser_measure, where the returned value is the distance. If an error
has occurred during the distance measurement, the returned distance value will be “0”, and the
corresponding error code can be read.
Laser Rangefinder Reference Design
WAS-18A1EN V1.00 10 / 14 July 1, 2020
Other functions of the laser rangefinder such as area, volume, Pythagoras algorithm (2-point),
Pythagoras algorithm (3-point), height measurement, level measurement, etc., are implemented by
using the library functions to obtain the distance value first and then calculating it together with the
angle calculated by the accelerometer to get the final value.
Library Function Description
Start
GPIO Initialisation
Communication Interface Initialisation
Laser_SysInit
APC PWM Initialisation
APD PWM Initialisation
ADC Initialisation
PLL IC Initialisation
End
Laser_measure
Start
Calculate and return the distance value
APC calibration is successful?
APD calibration is successful?
First measurement is successful?
Second measurement is successful?
Third measurement is successful?
Fourth measurement is successful?
End
Return error message
N
Y
N
N
N
N
Y
Y
Y
Y
N
Y
The library function can implement APC and APD power auto adjustment and execute an ADC on
the captured echo signal. After this, an FFT algorithm is applied to obtained the echo signal phase, the
result of which will be used to calculate the actual distance. The final value is then returned to the
function. If an error has occurred during the calculation process, the returned distance value will be
zero, in such cases, the error message can be obtained through the error code, Err_Code. The distance
data can also be used together with an accelerometer to extend different measurement modes. The
accelerometer can obtain the tilt angle which is used in many other calculation modes, such as
Pythagoras algorithm (2-point), Pythagoras algorithm (3-point), height measurement, level
measurement and so on.
Laser Rangefinder Reference Design
WAS-18A1EN V1.00 11 / 14 July 1, 2020
Code Cause of Error Err 261 Exceed measuring range Err 501, 502 APC, APD initialisation failure Err 510 Si5351A communication failure Err 520, 521 ADC sampling error
Table 4
void Laser_SysInit(void)
Function: Initialise the measurement required peripheral functions, including GPIO, PWM, ADC,
PDMA, etc.
Input: None.
Output: None.
float Laser_measure(void)
Function: Distance measurement.
Input: None.
Output: Return the distance value (float). If the returned value is “0”, it indicates the measurement has
failed, the error code can be read from the “Err_code”.
void Laser_SysOff(void)
Function: Disable the MCU peripheral functions, including timers, ADC, PWM, etc.
Input: None.
Output: None.
Laser_On
Function: Turn on the laser.
Input: None.
Output: None.
Laser_Off
Function: Turn off the laser.
Input: None.
Output: None.
Laser Rangefinder Reference Design
WAS-18A1EN V1.00 12 / 14 July 1, 2020
Operation Description
Figure 9. Prototype Front View
Figure 10. Prototype Back View
1. Measurement key
After the measurement mode is selected, a short press on the measurement key will start the
measurement. If the key is held down for a longer period, the device will enter the continuous
measurement mode.
2. Function key
Pressing this key can switch to different measurement modes, including area, volume, Pythagoras
(2-point), Pythagoras (3-point) ①, Pythagoras (3-point) ②, auto level and auto height.
3. Reference/Unit key
The default rangefinder reference is rear reference, a short press on this key will switch the
reference mode, including front reference, tripod screw hole reference and rear reference. A
long press will switch the measuring unit to be meters (m), feet (ft) or inches (in).
Note: After the machine is restarted, the measuring reference will automatically switch to the
default setting, namely the rear reference.
4. Laser icon
5. 2.0 inch TFT-LCD display
Display the measurement mode and data calculation results.
6. History key
Press this key to directly check the historical measurement data. The last 20 measurements or
calculated data will be displayed in a reverse order.
7. Add/Subtract (+/-) key
In single distance measurement, area and volume measurement mode, a short press implements
the “add” function while a long press implements the “subtract” function.
8. Mute key
Press this key to turn off or turn on the buzzer.
9. Startup & shutdown/clear/return key
A long press on this key will start up or shut down the machine while a short press will clear
the previous operation or return.
10. Battery compartment
11. Tripod screw hole
Laser Rangefinder Reference Design
WAS-18A1EN V1.00 13 / 14 July 1, 2020
Solution Comparison
Holtek Solution Industry Solution
Function Distance measurement, angle calculation (Can be extended to other functions)
Distance measurement, angle calculation (Can be extended to other functions)
Performance Time-taken: <400ms for each time Flash: 26.5KB SRAM: 4.3KB
N/A
Cost Standard MCU + laser drive circuit Standard MCU + laser drive circuit Others Provide algorithm technology support N/A
Conclusion
This document has introduced a laser rangefinder solution implemented using the HT32F52352 master
MCU together with Holtek self-developed algorithms. The HT32F52352 provides a high speed ADC
sampling function which can implement laser signal capture and effectively reduce the error generated
in phase calculations. The MCU provides a core speed of 48MHz, allowing the laser rangefinder to
quickly calculate the object distance in 500ms.
Reference Material
Reference file: HT32F52352 Datasheet.
For more information, consult the Holtek website www.holtek.com .
Version and Revision
Date Author Issue 2019.11.29 洪瑋廷 Initial version
Laser Rangefinder Reference Design
WAS-18A1EN V1.00 14 / 14 July 1, 2020
Disclaimer
All information, trademarks, logos, graphics, videos, audio clips, links and other items appearing
on this website ('Information') are for reference only and is subject to change at any time without
prior notice and at the discretion of Holtek Semiconductor Inc. and its related companies
(hereinafter 'Holtek', 'the company', 'us', 'we' or 'our'). Whilst Holtek endeavors to ensure the
accuracy of the Information on this website, no express or implied warranty is given by Holtek to
the accuracy of the Information. Holtek will bear no responsibility for any incorrectness or leakage.
Holtek will not be liable for any damages (including but not limited to computer virus, system
problems or data loss) whatsoever arising in using or in connection with the use of this website by
any party. There may be links in this area, which allow you to visit the websites of other companies.
These websites are not controlled by Holtek. Holtek will bear no responsibility and no guarantee to
whatsoever Information displayed at such sites. Hyperlinks to other websites are at your own risk.
Limitation of Liability
In no event shall Holtek Limited be liable to any other party for any loss or damage whatsoever or
howsoever caused directly or indirectly in connection with your access to or use of this website, the
content thereon or any goods, materials or services.
Governing Law
The Disclaimer contained in the website shall be governed by and interpreted in accordance with
the laws of the Republic of China. Users will submit to the non-exclusive jurisdiction of the
Republic of China courts.
Update of Disclaimer
Holtek reserves the right to update the Disclaimer at any time with or without prior notice, all
changes are effective immediately upon posting to the website.