Difference between revisions of "SIngle ToF"

From Diustou Wiki
 
(7 intermediate revisions by the same user not shown)
Line 2: Line 2:
 
|images=[[File:SIngle ToF_示意图.png|400px]]
 
|images=[[File:SIngle ToF_示意图.png|400px]]
 
|categories=
 
|categories=
{{Category|光传感器}}
+
{{Category|Sensor}}
{{Category|传感器}}
+
{{Category|optical sensor.}}
|brand=丢石头
+
|brand=Diustou
 
|features=
 
|features=
* 单点TOF激光测距传感器
+
* SIngle ToF
 
|interfaces=
 
|interfaces=
{{Category|UART接口}}
+
{{Category|UART}}
 
|related=
 
|related=
* [[Laser Sensor]]
 
* [[红外测距传感器]]
 
* [[激光测距传感器模块]]
 
 
}}
 
}}
  
 
== 测距原理 ==
 
== 测距原理 ==
TOF是Time of Flight的缩写,即飞行时间。具体是指通过周期性的向外发出红外光调制波,当调制波遇到被测目标后反射,然后用传感器接收从被测目标反射回来的调制波。通过测量调制波往返的相位差,可得到飞行时间,从而计算出传感器与物体目标之间的相对距离。示意图如下所示。
+
*TOF is an abbreviation for Time of Flight, which refers to the time it takes for a signal to travel. Specifically, it involves periodically emitting infrared modulated waves outward. When these waves encounter the target object, they are reflected back and received by the sensor. By measuring the phase difference of the modulated waves' round trip, the flight time can be obtained, allowing the calculation of the relative distance between the sensor and the target object. The schematic diagram is shown below.
 
+
*[[File:激光测距传感器模块_测距原理.png|600px]]
[[File:激光测距传感器模块_测距原理.png|360px]]
 
  
 
== 引脚说明 ==
 
== 引脚说明 ==
*[[File:SIngle ToF_引脚说明.png|300px]]
+
*[[File:SIngle ToF_引脚说明.png|400px]]
 
*[[File:SIngle ToF_引脚说明1.png|600px]]
 
*[[File:SIngle ToF_引脚说明1.png|600px]]
*'''短接TX与RX引脚后上电可实现硬件恢复出厂设置'''
+
*'''Shorting the TX and RX pins and then powering on can reset the hardware to factory settings.'''
  
 
== 产品参数 ==
 
== 产品参数 ==
*[[File:SIngle ToF_产品参数.png|700px]]
+
*[[File:SIngle ToF_产品参数.png|800px]]
  
== 使用说明 ==
+
== User Instructions ==
=== 演示示例 ===
+
=== Demonstration Example ===
 
[[File:SIngle ToF_演示视频.mp4|800px]]
 
[[File:SIngle ToF_演示视频.mp4|800px]]
  
=== Modbus协议 ===
+
=== Modbus Protocol ===
*单点TOF激光测距传感器采用了工业标准Modbus协议,Modbus通信指令分为两种,读命令与写命令,
+
*The single-point TOF laser ranging sensor adopts the industrial standard Modbus protocol. Modbus communication commands are divided into two types: read commands and write commands.
**读命令(0x03):读取相应寄存器数据。
+
**Read Command (0x03): Read data from the corresponding register.
**写命令(0x06):向相应寄存器写入数据。
+
**Write Command (0x06): Write data to the corresponding register.
*具体读写格式如下表:
+
*The specific read and write formats are shown in the following tables:
**上位机发送数据帧
+
**Data Frame Sent by the Host Computer
**[[File:SIngle ToF_发送格式.png|600px]]
+
**[[File:SIngle ToF_发送格式.png|800px]]
**模块回复帧
+
**Module Response Frame
**[[File:SIngle ToF_接收格式.png|600px]]
+
**[[File:SIngle ToF_接收格式.png|800px]]
**示例:读取测量距离
+
**Example: Reading Measurement Distance
***发送指令:50 03 00 34 00 01 c8 45
+
***Send Command: 50 03 00 34 00 01 c8 45
***接受数据:50 03 02 07 0B 06 7F
+
***Received Data: 50 03 02 07 0B 06 7F
***数据解析:
+
***Data Parsing:
****发送:0x50为Modbus ID(默认),0x03为命令号(读命令),0x34为寄存器地址(测量数据),0x01为读取长度(一位),0xc8 0x45为CRC校验位
+
****Send: 0x50 is the Modbus ID (default), 0x03 is the command number (read command), 0x34 is the register address (measurement data), 0x01 is the read length (one digit), 0xc8 0x45 are the CRC check digits.
****接收:0x50为Modbus ID(默认),0x03为命令号(读命令),0x02为数据长度(两位),0x07 0x0B为测量数据(0x070B对应的十进制为1803,测量距离为18036mm),0x06 0x7F为CRC校验位。
+
****Receive: 0x50 is the Modbus ID (default), 0x03 is the command number (read command), 0x02 is the data length (two digits), 0x07 0x0B is the measurement data (0x070B corresponds to 1803 in decimal, and the measurement distance is 18036mm), 0x06 0x7F are the CRC check digits.
 +
 
 +
=== Modbus Registers ===
 +
*'''System Restore'''
 +
**Register Address: 0x00
 +
**Send Format:
 +
**[[File:SIngle ToF_寄存器1.png|800px]]
 +
**Description (0xXX):
 +
***Write 0x01 to reset the sensor to factory settings.
 +
***Write 0x02 to restart the sensor.
 +
 
 +
*'''Baud Rate Setting'''
 +
**Register Address: 0x04
 +
**Send Format:
 +
**[[File:SIngle ToF_寄存器2.png|800px]]
 +
**Description (0xXX):
 +
***Write 0x00 to set the baud rate to 2400.
 +
***Write 0x01 to set the baud rate to 4800.
 +
***Write 0x02 to set the baud rate to 9600.
 +
***Write 0x03 to set the baud rate to 19200.
 +
***Write 0x04 to set the baud rate to 38400.
 +
***Write 0x05 to set the baud rate to 57600.
 +
***Write 0x06 to set the baud rate to 115200 (default).
 +
***Write 0x07 to set the baud rate to 230400.
 +
***Write 0x08 to set the baud rate to 460800.
 +
***Write 0x09 to set the baud rate to 921600.
  
=== Modbus寄存器 ===
+
*'''Modbus ID Setting'''
*'''系统恢复'''
+
**Register Address: 0x1A
**寄存器地址:0x00
+
**Send Format:
**发送格式:
+
**[[File:SIngle ToF_寄存器3.png|800px]]
**[[File:SIngle ToF_寄存器1.png|600px]]
+
**Description (0xXX):
**说明(0xXX):
+
***Write a value in the range of 0x00~0xFE. The factory default setting is 0x50.
***写入0x01,传感器恢复出厂设置
 
***写入0x02,传感器重启
 
  
*'''波特率设置'''
+
*'''Measurement Data'''
**寄存器地址:0x04
+
**Register Address: 0x34
**发送格式:
+
**Send Format:
**[[File:SIngle ToF_寄存器2.png|600px]]
+
**[[File:SIngle ToF_寄存器4.png|800px]]
**说明(0xXX):
+
**Description:
***写入0x00,设置波特率为2400
+
***Read the high 8 bits and low 8 bits of the distance data.
***写入0x01,设置波特率为4800
 
***写入0x02,设置波特率为9600
 
***写入0x03,设置波特率为19200
 
***写入0x04,设置波特率为38400
 
***写入0x05,设置波特率为57600
 
***写入0x06,设置波特率为115200(默认)
 
***写入0x07,设置波特率为230400
 
***写入0x08,设置波特率为460800
 
***写入0x09,设置波特率为921600
 
  
*'''Modbus ID设置'''
+
*'''System Mode'''
**寄存器地址:0x1A
+
**Register Address: 0x38
**发送格式:
+
**Send Format:
**[[File:SIngle ToF_寄存器3.png|600px]]
+
**[[File:SIngle ToF_寄存器5.png|800px]]
**说明(0xXX):
+
**Description (0xXX):
***写入范围为0x00~0xFE,出厂设置默认为0x50
+
***Write 0x00 to put the sensor in serial port print mode, where it directly prints strings.
 +
***Write 0x01 to put the sensor in Modbus mode (default).
 +
***Write 0x02 to put the sensor in calibration mode. After calibration is complete, it automatically reverts to Modbus mode.
  
*'''测量数据'''
 
**寄存器地址:0x34
 
**发送格式:
 
**[[File:SIngle ToF_寄存器4.png|600px]]
 
**说明:
 
***读取数据高8位与距离低8位
 
  
*'''系统模式'''
+
=== Host Computer ===
**寄存器地址:0x38
+
*'''Hardware Preparation:''' Single ToF Module, USB to TTL Module, Computer
**发送格式:
+
*'''Hardware Connection:'''
**[[File:SIngle ToF_寄存器5.png|600px]]
 
**说明(0xXX):
 
***写入0x00,传感器进入串口打印模式,直接打印字符串。
 
***写入0x01,传感器进入Modbus模式(默认)。
 
***写入0x02,传感器进入校准模式,校准完成后自动恢复为Modbus模式。
 
=== 上位机 ===
 
*'''硬件准备:'''Single ToF模块、USB转TTL模块、电脑
 
*'''硬件连接:'''
 
 
**[[File:SIngle ToF_上位机1.png|600px]]
 
**[[File:SIngle ToF_上位机1.png|600px]]
*'''使用步骤'''
+
*'''Usage Steps:'''
**将Single ToF接入USB转TTL模块的接口,将接好线的USB转TTL模块插入电脑USB接口,打开[[:File:SIngle ToF_windows上位机.zip|上位机]]软件。
+
**Connect the Single ToF module to the interface of the USB to TTL module, insert the wired USB to TTL module into the computer's USB port, and open the [https://wiki.diustou.com/cn/%E6%96%87%E4%BB%B6:SIngle_ToF_windows%E4%B8%8A%E4%BD%8D%E6%9C%BA.zip Host Computer].
**点击上位机软件中的 ''刷新串口'' ,然后选择模块对应的端口号,选择好端口号都点击 ''连接'' 。此时右侧的对话框内会出现 ''串口打开成功'' 字样。
+
**Click "Refresh Serial Port" in the host software, then select the corresponding port number for the module, and click "Connect" after selecting the port number. At this point, the phrase "Serial Port Opened Successfully" will appear in the dialog box on the right.
 
**[[File:SIngle ToF_上位机2.png|400px]][[File:SIngle ToF_上位机3.png|400px]]
 
**[[File:SIngle ToF_上位机2.png|400px]][[File:SIngle ToF_上位机3.png|400px]]
**点击左下角的 ''添加设备'' ,在出现的对话框内需要输入模块ID(默认ID为0x50),然后点击 ''OK''。
+
**Click "Add Device" in the bottom left corner, and in the dialog box that appears, enter the module ID (default ID is 0x50), then click "OK".
 
**[[File:SIngle ToF_上位机4.png|400px]][[File:SIngle ToF_上位机5.png|400px]]
 
**[[File:SIngle ToF_上位机4.png|400px]][[File:SIngle ToF_上位机5.png|400px]]
**设置ID成功后会弹出新的界面出来用来查看测量距离以及对模块进行设置,同时主界面的右侧会出现 ''添加设备成功 ID:0x50'' 字样。
+
**After successfully setting the ID, a new interface will pop up for viewing the measured distance and configuring the module. At the same time, the phrase "Device Added Successfully ID: 0x50" will appear on the right side of the main interface.
 
**[[File:SIngle ToF_上位机6.png|600px]]
 
**[[File:SIngle ToF_上位机6.png|600px]]
*'''校准:'''
+
*'''Calibration:'''
**连接模组。
+
**Connect the module.
**将模组放在距离白纸10cm的位置,点击 ''校准'' 按钮,校准对应ID的模组。
+
**Place the module 10cm away from a piece of white paper, click the "Calibrate" button to calibrate the module with the corresponding ID.
 
**[[File:SIngle ToF_上位机7.png|300px]]
 
**[[File:SIngle ToF_上位机7.png|300px]]
*'''设置ID:'''
+
*'''Set ID:'''
**连接模组。
+
**Connect the module.
**点击 ''设置ID'' 按钮,填入新的ID,范围01~fe,十六进制。
+
**Click the "Set ID" button, enter a new ID within the range of 01~fe in hexadecimal.
**重启模组生效,生效后需要用新ID重新连接模组。
+
**Restart the module for the changes to take effect. After it takes effect, you need to reconnect the module using the new ID.
 
**[[File:SIngle ToF_上位机8.png|300px]]
 
**[[File:SIngle ToF_上位机8.png|300px]]
*'''恢复出厂:'''
+
*'''Factory Reset:'''
**连接模组。
+
**Connect the module.
**点击 ''恢复出厂'' 按钮。
+
**Click the "Factory Reset" button.
**模组重启生效,生效后需要用默认ID(50)重新连接模组。
+
**The module will restart for the changes to take effect. After it takes effect, you need to reconnect the module using the default ID (50).
**恢复出厂后会清除校准参数,需重新校准。
+
**After a factory reset, the calibration parameters will be cleared, and recalibration is required.
 
**[[File:SIngle ToF_上位机9.png|300px]]
 
**[[File:SIngle ToF_上位机9.png|300px]]
*'''重启:'''
+
*'''Restart:'''
**连接模组。
+
**Connect the module.
**点击 ''重启'' 按钮,对应ID的模组会重启。
+
**Click the "Restart" button, and the module with the corresponding ID will restart.
 
**[[File:SIngle ToF_上位机10.png|300px]]
 
**[[File:SIngle ToF_上位机10.png|300px]]
  
 
=== Arduino ===
 
=== Arduino ===
*'''硬件准备:'''Single ToF模块、Arduino
+
*'''Hardware Preparation:''' Single ToF Module, Arduino
*'''硬件连接:'''
+
*'''Hardware Connection:'''
 
**[[File:SIngle ToF_arduino1.png|600px]]
 
**[[File:SIngle ToF_arduino1.png|600px]]
*'''使用步骤:'''
+
*'''Usage Steps:'''
**将Single ToF接入Arduino的接口,将接好线的Arduino接入电脑。
+
**Connect the Single ToF module to the Arduino interface, and connect the wired Arduino to the computer.
**用Arduino IDE打开代码,并选择对应的板型和串口号。
+
**Open the code with Arduino IDE and select the corresponding board type and serial port number.
 
***[[File:SIngle ToF_arduino2.png|400px]]
 
***[[File:SIngle ToF_arduino2.png|400px]]
**根据实际传感器与arduino的硬件连接修改传感器连接的串口的IO口编号。
+
**Modify the IO port number for the serial port where the sensor is connected, based on the actual hardware connection between the sensor and the Arduino.
 
***[[File:SIngle ToF_arduino3.png|600px]]
 
***[[File:SIngle ToF_arduino3.png|600px]]
**根据实际情况修改传感器数量和传感器ID
+
**Modify the number of sensors and sensor IDs according to the actual situation.
 
***[[File:SIngle ToF_arduino4.png|800px]]
 
***[[File:SIngle ToF_arduino4.png|800px]]
**编译和上传
+
**Compile and upload the code.
**打开串口监视器,波特率选择115200,观察结果。
+
**Open the Serial Monitor, set the baud rate to 115200, and observe the results.
 
***[[File:SIngle ToF_arduino5.png|600px]]
 
***[[File:SIngle ToF_arduino5.png|600px]]
 +
  
 
=== Raspberry Pi ===
 
=== Raspberry Pi ===
Line 159: Line 158:
 
  Restart the Raspberry Pi
 
  Restart the Raspberry Pi
 
:*Modify the number of sensors and sensor IDs in the code on the PC according to the actual hardware connection.
 
:*Modify the number of sensors and sensor IDs in the code on the PC according to the actual hardware connection.
**[[File:SIngle ToF_树莓派2.png|600px]]
+
:*[[File:SIngle ToF_树莓派2.png|600px]]
**Navigate to the directory where the example code is located and compile it using gcc
+
:*Navigate to the directory where the example code is located and compile it using gcc
 
<pre>
 
<pre>
 
sudo gcc vl53_tof.c -o vl53_tof  
 
sudo gcc vl53_tof.c -o vl53_tof  

Latest revision as of 17:42, 10 January 2025

SIngle ToF
SIngle ToF 示意图.png
Information

Categories: Sensor optical sensor.

Brand: Diustou

Description
Features
  • SIngle ToF

Interfaces

UART

Related products

测距原理

  • TOF is an abbreviation for Time of Flight, which refers to the time it takes for a signal to travel. Specifically, it involves periodically emitting infrared modulated waves outward. When these waves encounter the target object, they are reflected back and received by the sensor. By measuring the phase difference of the modulated waves' round trip, the flight time can be obtained, allowing the calculation of the relative distance between the sensor and the target object. The schematic diagram is shown below.
  • 激光测距传感器模块 测距原理.png

引脚说明

  • SIngle ToF 引脚说明.png
  • SIngle ToF 引脚说明1.png
  • Shorting the TX and RX pins and then powering on can reset the hardware to factory settings.

产品参数

  • SIngle ToF 产品参数.png

User Instructions

Demonstration Example

Modbus Protocol

  • The single-point TOF laser ranging sensor adopts the industrial standard Modbus protocol. Modbus communication commands are divided into two types: read commands and write commands.
    • Read Command (0x03): Read data from the corresponding register.
    • Write Command (0x06): Write data to the corresponding register.
  • The specific read and write formats are shown in the following tables:
    • Data Frame Sent by the Host Computer
    • SIngle ToF 发送格式.png
    • Module Response Frame
    • SIngle ToF 接收格式.png
    • Example: Reading Measurement Distance
      • Send Command: 50 03 00 34 00 01 c8 45
      • Received Data: 50 03 02 07 0B 06 7F
      • Data Parsing:
        • Send: 0x50 is the Modbus ID (default), 0x03 is the command number (read command), 0x34 is the register address (measurement data), 0x01 is the read length (one digit), 0xc8 0x45 are the CRC check digits.
        • Receive: 0x50 is the Modbus ID (default), 0x03 is the command number (read command), 0x02 is the data length (two digits), 0x07 0x0B is the measurement data (0x070B corresponds to 1803 in decimal, and the measurement distance is 18036mm), 0x06 0x7F are the CRC check digits.

Modbus Registers

  • System Restore
    • Register Address: 0x00
    • Send Format:
    • SIngle ToF 寄存器1.png
    • Description (0xXX):
      • Write 0x01 to reset the sensor to factory settings.
      • Write 0x02 to restart the sensor.
  • Baud Rate Setting
    • Register Address: 0x04
    • Send Format:
    • SIngle ToF 寄存器2.png
    • Description (0xXX):
      • Write 0x00 to set the baud rate to 2400.
      • Write 0x01 to set the baud rate to 4800.
      • Write 0x02 to set the baud rate to 9600.
      • Write 0x03 to set the baud rate to 19200.
      • Write 0x04 to set the baud rate to 38400.
      • Write 0x05 to set the baud rate to 57600.
      • Write 0x06 to set the baud rate to 115200 (default).
      • Write 0x07 to set the baud rate to 230400.
      • Write 0x08 to set the baud rate to 460800.
      • Write 0x09 to set the baud rate to 921600.
  • Modbus ID Setting
    • Register Address: 0x1A
    • Send Format:
    • SIngle ToF 寄存器3.png
    • Description (0xXX):
      • Write a value in the range of 0x00~0xFE. The factory default setting is 0x50.
  • Measurement Data
    • Register Address: 0x34
    • Send Format:
    • SIngle ToF 寄存器4.png
    • Description:
      • Read the high 8 bits and low 8 bits of the distance data.
  • System Mode
    • Register Address: 0x38
    • Send Format:
    • SIngle ToF 寄存器5.png
    • Description (0xXX):
      • Write 0x00 to put the sensor in serial port print mode, where it directly prints strings.
      • Write 0x01 to put the sensor in Modbus mode (default).
      • Write 0x02 to put the sensor in calibration mode. After calibration is complete, it automatically reverts to Modbus mode.


Host Computer

  • Hardware Preparation: Single ToF Module, USB to TTL Module, Computer
  • Hardware Connection:
    • SIngle ToF 上位机1.png
  • Usage Steps:
    • Connect the Single ToF module to the interface of the USB to TTL module, insert the wired USB to TTL module into the computer's USB port, and open the Host Computer.
    • Click "Refresh Serial Port" in the host software, then select the corresponding port number for the module, and click "Connect" after selecting the port number. At this point, the phrase "Serial Port Opened Successfully" will appear in the dialog box on the right.
    • SIngle ToF 上位机2.pngSIngle ToF 上位机3.png
    • Click "Add Device" in the bottom left corner, and in the dialog box that appears, enter the module ID (default ID is 0x50), then click "OK".
    • SIngle ToF 上位机4.pngSIngle ToF 上位机5.png
    • After successfully setting the ID, a new interface will pop up for viewing the measured distance and configuring the module. At the same time, the phrase "Device Added Successfully ID: 0x50" will appear on the right side of the main interface.
    • SIngle ToF 上位机6.png
  • Calibration:
    • Connect the module.
    • Place the module 10cm away from a piece of white paper, click the "Calibrate" button to calibrate the module with the corresponding ID.
    • SIngle ToF 上位机7.png
  • Set ID:
    • Connect the module.
    • Click the "Set ID" button, enter a new ID within the range of 01~fe in hexadecimal.
    • Restart the module for the changes to take effect. After it takes effect, you need to reconnect the module using the new ID.
    • SIngle ToF 上位机8.png
  • Factory Reset:
    • Connect the module.
    • Click the "Factory Reset" button.
    • The module will restart for the changes to take effect. After it takes effect, you need to reconnect the module using the default ID (50).
    • After a factory reset, the calibration parameters will be cleared, and recalibration is required.
    • SIngle ToF 上位机9.png
  • Restart:
    • Connect the module.
    • Click the "Restart" button, and the module with the corresponding ID will restart.
    • SIngle ToF 上位机10.png

Arduino

  • Hardware Preparation: Single ToF Module, Arduino
  • Hardware Connection:
    • SIngle ToF arduino1.png
  • Usage Steps:
    • Connect the Single ToF module to the Arduino interface, and connect the wired Arduino to the computer.
    • Open the code with Arduino IDE and select the corresponding board type and serial port number.
      • SIngle ToF arduino2.png
    • Modify the IO port number for the serial port where the sensor is connected, based on the actual hardware connection between the sensor and the Arduino.
      • SIngle ToF arduino3.png
    • Modify the number of sensors and sensor IDs according to the actual situation.
      • SIngle ToF arduino4.png
    • Compile and upload the code.
    • Open the Serial Monitor, set the baud rate to 115200, and observe the results.
      • SIngle ToF arduino5.png


Raspberry Pi

  • Hardware Preparation: Single ToF Module, Raspberry Pi
  • Hardware Connection:
  • SIngle ToF 树莓派1.png
  • Usage Steps
    • Burn the Raspberry Pi OS onto an SD card and copy the example code to the system files on the Raspberry Pi.
    • Connect the Single ToF module to the Raspberry Pi interface and insert the SD card with the burned OS into the Raspberry Pi.
    • Enable the serial port function on the Raspberry Pi.
Execute Command:sudo raspi-config
Select:Interfacing Options
Select:Serial
Select:NO(Would you like a login shell to be accessible over serial?)
Select:YES(Would you like the serial port hardware to be enabled)
Select:YES(The serial login shell is disabled.....)
Restart the Raspberry Pi
  • Modify the number of sensors and sensor IDs in the code on the PC according to the actual hardware connection.
  • SIngle ToF 树莓派2.png
  • Navigate to the directory where the example code is located and compile it using gcc
sudo gcc vl53_tof.c -o vl53_tof 
  • SIngle ToF 树莓派3.png
  • Execute the compiled executable file and observe the results
sudo ./vl53_tof
  • SIngle ToF 树莓派4.png

Product Information

FAQ

Icon-mail.png Contact Diustou

Our working hours are: 09:00-18:00 (UTC+8 Monday to Saturday)