Welcome to SDM18 Laser Ranging Module repository
6.Get distance information_STM32
4.Get distance information_STM32
4.Get distance information_STM320. SDM18 brief introduction1. Experimental preparation2. Experimental wiring3.Experimental steps4.experimental result 5.Explanation of some important parameters and default values of SDM18
0. SDM18 brief introduction
- YDLIDAR SDM18 LiDAR is a high-performance single point LiDAR (hereinafter referred to as SDM18). This product is based on the principle of time-of-flight distance measurement and is designed with relevant optics, electronics, and algorithms to achieve high-precision laser distance measurement and output high frame rate point cloud data.
- Product features ➢ High ranging frequency, high internal sampling rate combined with filtering algorithm, data has high stability ➢ Long detection distance, up to 18 meters ➢ Lightweight, approximately 1.35g ➢ Laser power meets FDA Class I safety standards
1. Experimental preparation
- SDM18 laser ranging module
- The STM32F103C8T6 experiment in this tutorial for the stm32F1 series
2. Experimental wiring
| STM32 | SDM18 |
|---|---|
| PA3 | TX |
| PA2 | RX |
| GND | GND |
| 3.3V | 3.3V |
The wiring diagram is shown in the figure


| STM32 | USB to TTL module (no need to purchase it yourself) |
|---|---|
| RX | TX |
| TX | RX |
| GND | GND |
| 3.3V | 3.3V |
| usart1 Function: Communicate with the computer - output the receiving radar's ranging distance, signal strength, and baud rate of 115200 | |
| The PA9 of STM32 is connected to the RXD of the USB to TTL module | |
| The PA10 of STM32 is connected to the TXD of the USB to TTL module | |
| GND of STM32 to USB to TTL module | |
| VCC can be disconnected |
3.Experimental steps
- Download the program provided by the routine to stm32
- Open the serial assistant and set the baud rate to 115200
4.experimental result
After connecting the wires, under normal communication, the serial assistant can print out the distance measurement information obtained, as shown in the figure

- dis:distance In millimeters
- strength:strength
5.Explanation of some important parameters and default values of SDM18
- The SDM18 interface is shown in the figure:

- Serial port default configuration
SDM18 The default baud rate is 921600

- Important protocol commands based on serial port (all sent in hexadecimal format) The default mode for powering on SDM18 is idle mode. If you want to perform ranging, you need to start the ranging command first
- Start ranging:A5 03 20 01 00 00 00 02 6E
- Stop ranging: A5 03 20 02 00 00 00 46 6E
- Protocol Analysis for Receiving Distance Measurement
| header | Equipment number | Equipment type | Command type | reserved | Data length | Data segment | Verification code |
|---|---|---|---|---|---|---|---|
| 1 Byte | 1 Byte | 1 Byte | 1 Byte | 1 Byte | 2 Bytes | N Bytes | 2 Bytes |
| ➢ Packet header: The packet header flag of SDM18 is 0xA5; | |||||||
| ➢ Device number: The message device number flag for SDM18 is 0x03; | |||||||
| ➢ Equipment type: determined by the type of lower computer evaluation board, 0x20; | |||||||
| ➢ Command type: System command code, as shown in Development manual; | |||||||
| ➢ Reserved space: reserved status space for future use; | |||||||
| ➢ Data length: represents the length of response data; | |||||||
| ➢ Data segment: response content under different system commands, feedback of different data content, and their data formats are also different; | |||||||
| ➢ Verification code: The CRC16 verification result of all data, except for the verification code. |
eg: |header| Equipment type| Data length| Data segment| Verification code| |0xA5| 0x03| 0x20| 0x00 0E| ‥‥ |CRC16| Set the response content as:A5 03 20 01 00 00 0E FF FF FF FF FF FF F6 06 42 00 74 26 01 00 0B (transmission mode LSB)
- Data length = 0x00 0E,The number of bytes in the data segment is 14;
- Then the data segment is FF FF FF FF FF FF F6 06 42 00 74 26 01 00.
- 6bit-7bit:Representing distance (F6 06:distance: 0x06F6 = 1782mm)
- 10bit-11bit:strength (74 26:strength: 0x2674 = 9844)
- Calculation of checksum
Is this checksum calculated using the CRC-16 modelbus method, which calculates all bytes except for the checksum bit
The following figure shows the checksum calculation result of the command Start ranging

Other protocols will not be explained anymore. Interested parties can refer to the SDM18 development manual