Difference between revisions of "SIngle ToF"

From Diustou Wiki
Line 95: Line 95:
 
***写入0x01,传感器进入Modbus模式(默认)。
 
***写入0x01,传感器进入Modbus模式(默认)。
 
***写入0x02,传感器进入校准模式,校准完成后自动恢复为Modbus模式。
 
***写入0x02,传感器进入校准模式,校准完成后自动恢复为Modbus模式。
=== 上位机 ===
+
=== Host Computer ===
*'''硬件准备:'''Single ToF模块、USB转TTL模块、电脑
+
*'''Hardware Preparation:''' Single ToF Module, USB to TTL Module, Computer
*'''硬件连接:'''
+
*'''Hardware Connection:'''
 
**[[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]]
  

Revision as of 17:32, 10 January 2025

SIngle ToF
SIngle ToF 示意图.png
Information

Categories: 光传感器 传感器

Brand: 丢石头

Description
Features
  • 单点TOF激光测距传感器

Interfaces

UART接口

Related products

测距原理

TOF是Time of Flight的缩写,即飞行时间。具体是指通过周期性的向外发出红外光调制波,当调制波遇到被测目标后反射,然后用传感器接收从被测目标反射回来的调制波。通过测量调制波往返的相位差,可得到飞行时间,从而计算出传感器与物体目标之间的相对距离。示意图如下所示。

激光测距传感器模块 测距原理.png

引脚说明

  • SIngle ToF 引脚说明.png
  • SIngle ToF 引脚说明1.png
  • 短接TX与RX引脚后上电可实现硬件恢复出厂设置

产品参数

  • SIngle ToF 产品参数.png

使用说明

演示示例

Modbus协议

  • 单点TOF激光测距传感器采用了工业标准Modbus协议,Modbus通信指令分为两种,读命令与写命令,
    • 读命令(0x03):读取相应寄存器数据。
    • 写命令(0x06):向相应寄存器写入数据。
  • 具体读写格式如下表:
    • 上位机发送数据帧
    • SIngle ToF 发送格式.png
    • 模块回复帧
    • SIngle ToF 接收格式.png
    • 示例:读取测量距离
      • 发送指令:50 03 00 34 00 01 c8 45
      • 接受数据:50 03 02 07 0B 06 7F
      • 数据解析:
        • 发送:0x50为Modbus ID(默认),0x03为命令号(读命令),0x34为寄存器地址(测量数据),0x01为读取长度(一位),0xc8 0x45为CRC校验位
        • 接收:0x50为Modbus ID(默认),0x03为命令号(读命令),0x02为数据长度(两位),0x07 0x0B为测量数据(0x070B对应的十进制为1803,测量距离为18036mm),0x06 0x7F为CRC校验位。

Modbus寄存器

  • 系统恢复
    • 寄存器地址:0x00
    • 发送格式:
    • SIngle ToF 寄存器1.png
    • 说明(0xXX):
      • 写入0x01,传感器恢复出厂设置
      • 写入0x02,传感器重启
  • 波特率设置
    • 寄存器地址:0x04
    • 发送格式:
    • SIngle ToF 寄存器2.png
    • 说明(0xXX):
      • 写入0x00,设置波特率为2400
      • 写入0x01,设置波特率为4800
      • 写入0x02,设置波特率为9600
      • 写入0x03,设置波特率为19200
      • 写入0x04,设置波特率为38400
      • 写入0x05,设置波特率为57600
      • 写入0x06,设置波特率为115200(默认)
      • 写入0x07,设置波特率为230400
      • 写入0x08,设置波特率为460800
      • 写入0x09,设置波特率为921600
  • Modbus ID设置
    • 寄存器地址:0x1A
    • 发送格式:
    • SIngle ToF 寄存器3.png
    • 说明(0xXX):
      • 写入范围为0x00~0xFE,出厂设置默认为0x50
  • 测量数据
    • 寄存器地址:0x34
    • 发送格式:
    • SIngle ToF 寄存器4.png
    • 说明:
      • 读取数据高8位与距离低8位
  • 系统模式
    • 寄存器地址:0x38
    • 发送格式:
    • SIngle ToF 寄存器5.png
    • 说明(0xXX):
      • 写入0x00,传感器进入串口打印模式,直接打印字符串。
      • 写入0x01,传感器进入Modbus模式(默认)。
      • 写入0x02,传感器进入校准模式,校准完成后自动恢复为Modbus模式。

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)