Difference between revisions of "TOF Laser Range Sensor (B)"

From Waveshare Wiki
Jump to: navigation, search
Line 23: Line 23:
 
</div>
 
</div>
 
<div class="tabbertab" title="Resources">
 
<div class="tabbertab" title="Resources">
== Resources ==
 
 
===Demo code===
 
===Demo code===
*[[File:TOF-Laser-Range-Sensor-Demo.7z|Demo code]]
+
*[https://www.waveshare.com/w/upload/0/01/TOF-Laser-Range-Sensor-B-Demo.zip Demo code]
 
===Software===
 
===Software===
*[[:File:Waveshare_TOFAssistant.zip|TOF Assistant PC Assistant (Windows 7/10 64-bit machine)]]
+
*[https://www.waveshare.com/w/upload/2/23/Waveshare_TOFAssistant.zip TOF Assistant PC Assistant (Windows 7/10 64-bit machine)]
*[[:File:Waveshare_TOFAssistant_32bit.zip|TOF AssistantPC Assistant (Windows 7/10 32-bit machine)]]
 
 
</div>
 
</div>
 
<div class="tabbertab" title="FAQ">
 
<div class="tabbertab" title="FAQ">
==FAQ==
+
{{TOF Laser Ranger Sensor B FAQ}}
{{FAQ|Can it be used under outdoor (high light) conditions?
+
 
|The module is affected by natural light. Generally speaking, the stronger the natural light, the greater the impact, which manifests as the shorter the ranging distance, the worse the accuracy, and the larger the fluctuation. Under strong light conditions (such as sunlight), it is generally recommended to use in close-range detection scenes.}}
 
{{FAQ|Is there interference in the work of multiple modules?
 
|No interference. When multiple modules work at the same time, even if the infrared rays between each other cross or hit the same position, it will not affect the actual measurement.}}
 
{{FAQ|Why is there no data output in TOFSense?
 
|Each module is shipped after strict testing. If there is no data, please check whether the mode, wiring, baud rate and other configurations are correct; for CAN output mode, please check whether it contains a terminal resistance (usually 120Ω).}}
 
{{FAQ|What should I pay attention to when installing?
 
|When installing, avoid obstruction in the FOV angle. In addition, attention should be paid to the height of the ground, and similar reflective surfaces such as ground occlusion in the FOV should be avoided.}}
 
{{FAQ|Is the module's UART and CAN the same interface?
 
|The UART interface of the module and the CAN interface share the same physical interface, and the corresponding line sequence can be changed for different communication modes.}}
 
{{FAQ|How to configure the module for UART or CAN communication mode?
 
|In the UART communication mode, the module can be configured to the CAN communication mode through the host computer; in the CAN communication mode, you need to press and hold the button and then power on the module. When the indicator light flashes slowly, release the button. When the module is forced to enter the UART mode, and then write the UART configuration through the host computer.}}
 
{{FAQ|The shortest distance, the longest distance or the average distance when the module outputs?
 
|A single test volume of the module will get multiple sets of distance values, and the internal processor will process the largest distance.}}
 
{{FAQ|Does the module support output point cloud information?
 
|The module can only output one distance at a time, and does not support the output of point cloud information temporarily.}}
 
{{FAQ|If reports an error "The MSVC***.dll file cannot be found...". It may be that the computer lacks the corresponding runtime components of Microsoft.?
 
| [https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads Visual C ++ Redistributable for Visual Studio 2017], if the above installation fails or shows success, but opening the NAssistant program still prompts that the dll file is missing.Note, please select the patch for the computer system.}}
 
{{FAQ| The software report an error "Because Qt***.dll cannot be found..."?
 
|Please check whether the installation file is silently intercepted by security software , please exit the security software and reinstall it. Also run with administrator rights.}}
 
 
</div>
 
</div>
 
<div class="tabbertab" title="Supports">
 
<div class="tabbertab" title="Supports">

Revision as of 08:30, 14 December 2021

TOF Laser Range Sensor (B)
TOF Laser Range Sensor B

VL53L1X Distance Sensor
{{{name2}}}

{{{name3}}}

{{{name4}}}

{{{name5}}}

Introduction

The TOF Laser Range Sensor (B) is a TOF-based (time of flight) laser ranging sensor with an embedded MCU and ranging algorithm, which is capable of offering up to 15m measuring range, ±2% accuracy, and 1mm resolution. It supports UART or I2C communication bus, features a longer measuring distance and higher light interference resistance capability due to its ultra-narrow FOV, suitable for either indoor or outdoor conditions.
This sensor can be widely used in applications like common distance measuring, robot obstacle avoidance/route planning, as well as drone altitude setting/ceiling detection, and more...

Specification

TOF-Parameter.png

Applications

  • Unmanned aerial vehicle height setting,ceiling detection
  • Robot obstacle avoidance
  • Measuring and detecting
  • Intelligent gesture control
  • 1-dimension gesture identification

Technology Overview

TOF is one absolute distance detecting technology, that is the sensor emits the near-infrared light to be debugged, and it will reflect after encountering the object. The sensor calculates the distance of the subject being photographed by calculating the time difference or phase difference for the emission and reflection of light so as to produce depth information. Compared with the binocular plan and 3D structural light plan, TOF has the advantages of long working distance, wide application scenarios, and high precision of long-distance, etc. Therefore, it is always applied to personnel proximity detection, robot obstacle avoidance, camera automatic focusing, etc. The near-infrared light coming from the sunlight in the outdoor environment will generate an impact on the measuring effect of the module.

TOF-Laser-Range-Sensor-work.jpg

Function Description

【ID】

  • ID is one variable designed for distinguishing the different sensors, which is used to identify each sensor during the cascade connection.

【Interface & Baudrate】

TOF Laser Range Sensor (B) supports UART, I2C and I/O .

UART

The communication baud rate setting range is as follows:

UART Baud Rate Note
115200,230400,460800,921600,1000000,1200000,2000000,3000000 921600 (by default)

The UART interface mode supports "active output" and "query output":
PC download:

  • TOF Assistant (For Windows 7/10 64 bits)
  • TOF Assistant (For Windows 7/10 32 bits)
  • Active Output:
    • The active output mode can only be used with a single module. In this mode, the module actively outputs measurement information at a frequency of 50 Hz, the format of output data is based on the NLink_TOFSense_Frame0 protocol.
    • Users can connect the Sensor to Windows PC by USB to TTL module and configure the module by Waveshare TOFAssistant software. Just like the picture below. You need to click the "Write Parameter" button to save the setting and don't forget to check them by "Read Parameter".
TOF-B-UART-Active-inquire.jpg
  • Query Output:
    • The query output mode can be used in a single module. In this mode, the controller sends a query command containing the module ID to the desired query module, and the module can output one frame of measurement information. The query command is based on NLink_TOFSense _Read_Frame0 protocol, and the output data from the module is based on the NLink_TOFSense_Frame0 protocol.
    • Connect the TOF series products to the Waveshare TOFAssistant software through the USB TO TTL module (line sequence and power supply voltage reference data sheet), click to enter the setting page after the identification is successful, the UART query output mode configuration is as shown in the figure below, after configuring the parameters, you need to click the write parameter button To save the parameters after the parameters are written successfully, you can read the parameters once to confirm whether the parameters are written successfully. (After changing the baud rate parameter of the module, you need to re-plug the USB TO TTL module to automatically identify the module):
TOF-B-UART-Inquire.jpg

I2C

  • The baudrate rate
I2C baudrate Description
Max 400KHz Max 4000KHz, it is defined by the host device
  • I2C address
I2C address Description
0x08 ~ 0x77 The default address is 0x08 (7 bits), the slaver address of the module is 0x08 + ID, you can change the device address by modifying the module ID. Please take care of offset and the behavior bit while communicating. for example, if the device address is 0x08, if you need to write data, you need to add the write bit and the byte sent should be 0x10, if you need to read data, you need to add the read bit and the byte sent should be 0x11.
In the I2C communication mode, the controller sends a reading frame to the expected query module of the specified slave address, and then the information such as the distance of the module can be obtained. In addition, various parameters such as the output mode of the module can also be changed through I2C communication. The reading frame and write frame format follow the protocol NLink_TOFSense_IIC_Frame0. You can connect the sensor to the PC by USB to the TTL module and change the device address (0x08 + ID, the ID should in the range 0 ~111) by the Waveshare TOFAssistant software. Note that, the Waveshare ToFAssitant software can only support UART mode.
TOF-B-I2C.jpg

I/O output

  • In I/O output mode, it doesn't output distance data. The voltage of I/O is toggled when the distance is over threshold.
When the module is in UART mode, users can connect it to the Windows PC by USB to TTL module and configure the band data by the Waveshare TOFAssistant software. The distance value is converted to high and low level output through hysteresis comparison. TX/SCL and RX/SDA output complementary levels. The hysteresis comparison diagram is shown in Figure 5. After configuring the parameters, you need to click the Write Parameters button to save the parameters. Note: After switching to I/O mode, you can refer to the FAQ chapter to change back to UART mode.
For example, Band_Start and Bandwidth are both set to 500, which corresponds to 0.5 meters. When the distance measurement value is 0.3 meters, RX is high, TX is low, the distance measurement value increases to 0.8 meters, RX is high, TX is low, and when the distance measurement value exceeds 1 meter, the level is reversed and RX is low, TX is high. When the distance measurement value drops from more than 1 meter to 0.8 meters, RX is low and TX is high. When the distance measurement value drops below 0.5 meters, the level is reversed, RX is high and TX is low.
TOF-B-IO.jpg
  • The range of Band_Start, Bandwidth is 0~15000 and 0~25000
TOF-B-Bandwidth.jpg

【Distance Status】

The module can output the current distance status, the user can perform the data processing with the combination of distance status,The meaning of distance status is as follows:

Value Note
0 Measuring distance is invalid
1 Measuring distance is valid

【Signal Strength】

Indicate the strength of current return signal, and the larger this value indicates the stronger the return signal.

【Range Precision】

Indicate the precision of current signal, smaller the data, higher the prevision.

【FOV】

The field angle FOV determines the vision scope of TOFSense. The FoV of the ToF Sensor (B) is 1~2°

【Mode Switch】

If the sensor is in UART mode, users can connect it to PC and chnage it to I2C or I/O mode by the Waveshare TOFAssistant software. If the sensor is in I2C mode, users can send commands to switch the mode to UART. And users can check the FAQ chapter about how to change to UART from I/O mode.

Protocol Analysis

  • The protocol is composed of Frame Header, Function Mark, Data, and Sum Check.
    • The Frame Header and Function Mark are fixed values;
    • Data is the content of the transmitted data;
    • Sum Check is the lowest byte after the addition of Frame Header, Function Mark, and Data (that is, the addition of all the previous bytes).
  • Agreement composition:
 Frame Header + Function Mark + Data + Sum Check

Note: Protocol packets follow the principle of little-endian mode, that is, the low byte is first and the high byte is last.

  • The frame:
Protocol Type Description
NLINK_TOFSENSE_FRAME0 Fixed length UART output data, contain the timestamp, distance, distance status and signal strength, etc.
NLINK_TOFSENSE_READ _FRAME0 Fixed length UART read, contain device ID
NLINK_TOFSENSE_IIC_FRAME0 Flexible length I2C data, contain distance, distance status and signal strength, etc.

NLink_TOFSense_Frame0

    • Data Sources: Connect the module to the host computer and configure the UART as active output mode.
    • Raw data:
 57 00 ff 00 9e 8f 00 00 ad 08 00 00 03 00 06 41
  • Analysis table:
Data Type Length (Bytes) Hex Result
Frame Header uint8 1 57 0x57
Function Mark uint8 1 00 0x00
reserved uint8 1 ff *
id uint8 1 00 0
System_time uint32 4 9e 8f 00 00 36766ms
dis*1000 uint24 3 ad 08 00 2.221m
dis_status uint8 1 00 0
signal_strength uint16 2 03 00 3
range_precision uint8 1 06 6cm
Sum Check uint8 1 41 0x41

NLink_TOFSense_Read_Frame0

    • Data Sources: Connect the module to the host computer, configure it as UART query output mode. Host device send cmmand to query the data
    • Raw data:
57 10 FF FF 00 FF FF 63
  • Analysis table:
Data Type Length (Bytes) Hex Result
Frame Header uint8 1 57 0x57
Function Mark uint8 1 10 0x10
reserved uint8 2 ff *
id uint8 1 00 0
reserved uint8 2 ff *
Sum Check uint8 1 63 0x63

NLink_TOFSense_IIC_Frame0

    • Device Address: The sensor works as slaver device, the default device address is 0x08 (7bits), the whole device address is 0x08 + ID, user can change the device address by modifying the ID.
    • Register address: If the register is NULL, the output is 0xff by default
AD 08 00 00 03 00 FF FF
  • Analysis table:
NLink TOFSense IIC Frame.png

I2C communication

NLink TOFSense IIC comunication3.png

Start: starting signal
W: read the flag bit 1
R: Write the flag bit 0
ACK: response
NACK: no response
Stop: stoping signal

NLink TOFSense IIC comunication4.png

Sent by the host
Sent by the slave

NLink_TOFSense_Setting_Frame0

    • Data Sources:: Setting Commands
  • Analysis table:

TOFSense-B-Setting-Frame.png

Software

TOF Assistant is the debugging software supporting the TOF laser ranging module. Its main functions are configuration debugging, status display, function application, and firmware upgrade:

  • Configuration and debugging: used to configure node-related parameters, such as ID, working mode, baud rate, etc.
  • Functional application: used for application development, such as data import and export, motion track storage, historical track playback, etc.
  • Firmware upgrade: used to upgrade the product by wired firmware.

Dimensions

  • TOF-Laser-Range-Sensor-B-details-size.jpg

Work with Raspberry Pi

Enable UART

If the module is set to UART mode and is connected to the UART interface of the Raspberry Pi, the UART of the Raspberry Pi also needs to be enabled accordingly. Since the Raspberry Pi serial port is used for terminal debugging by default, if you want to use the serial port, you need to modify the Raspberry Pi settings. Execute the following command to enter the Raspberry Pi configuration:

sudo raspi-config

Choose Interfacing Options -> Serial -> No -> Yes
You need to disable the login shell and enable the hardware serial

L76X GPS Module rpi serial.png

Reboot Raspberry Pi

sudo reboot

Enable I2C Interface

Open a terminal and run the following commands:

sudo raspi-config 
Choose Interfacing Options -> I2C ->yes 

Reboot Raspberry Pi:

sudo reboot

RPI open i2c.png

Module parameter Settings

The UART baud rate of the TOF Laser Range Sensor module needs to be set to: 921600 through the host computer;
The effect of using TOF Laser Range Sensor module on Raspberry Pi is as follows:
Tof-module-para.png

Hardware Connection

Connect to UART
Tof-Uart.png
Connect to I2C
Tof-I2c.png

Working with Jetson Nano

Hardware Connection

Tof-jetson.png

Software Settings

The UART baud rate of the TOF Laser Range Sensor module needs to be set to 115200 by the host computer;
Tof-software-set.png

The effect of Jetson nano using TOF Laser Range Sensor module is as follows:
Tof-jetson-sensor.png

Working with Arduino

Hardware Connection

TOF-Laser-Range-Sensor-Arduino-connected.jpg

Software Settings

  • The UART baud rate of the TOF Laser Range Sensor module needs to be set to: 115200 by the host computer;
Tof-software-set.png
TOF-Arduino-Test.jpg
 Answer:
The module is able to used in outdoor.
{{{3}}}
{{{4}}}

{{{5}}}


 Answer:
No interference. When multiple modules work at the same time, even if the infrared rays between each other cross or hit the same position, it will not affect the actual measurement.
{{{3}}}
{{{4}}}

{{{5}}}


 Answer:
Each module is shipped after strict testing. If there is no data, please check whether the mode, wiring, baud rate, and other configurations are correct; for I2C mode, please check if you have to use the correct device address; for I/O mode, please check the Introduction part
{{{3}}}
{{{4}}}

{{{5}}}


 Answer:
When installing, avoid obstruction in the FOV angle. In addition, attention should be paid to the height of the ground, and similar reflective surfaces such as ground occlusion in the FOV should be avoided.
{{{3}}}
{{{4}}}

{{{5}}}


 Answer:
All the interfaces of the module share the same physical interface, and the corresponding line sequence can be changed for different communication modes.
{{{3}}}
{{{4}}}

{{{5}}}


 Answer:
The TOFAssistant software can only support UART mode. If you have set the Sensor to other modes, please switch it back to UART mode first.
{{{3}}}
{{{4}}}

{{{5}}}


 Answer:
  • In UART mode, users can configure the module to I2C or I/O mode by the software.
  • In I2C mode, users need to send commands to the module through I2C communication to switch the mode to UART or I/O.
  • In I/O mode, you should use a USB to TTL adapter which should support 921600 baudrate.
    • Connect the TX, TX, and GND pins (do not connect the VCC now) of the adapter to the Sensor.
    • Connect the adapter to PC, open the TOFAssistant software and enter the SerialPort interface, **Configure the baud rate to 921600. Select the COM port of the adapter and click the "Connect" button.
    • In the input box, type the following commands:
54 20 00 ff 00 ff ff ff ff 00 ff ff 00 10 0e ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 7b
  • Set the sending interval time (right-bottom) to 20ms and check the Timed Send(ms) option
  • Connect the 5V pin of the adapter to the VCC pin of the Sensor
  • If the Sensor is switched to UART mode (UART data are received), you can disconnect the adapter, restart the sensor, and check.
{{{3}}}
{{{4}}}

{{{5}}}


 Answer:
If the measured distance is larger than 15m, the output data is random and it will be 0 if the distance is larger than 20m
{{{3}}}
{{{4}}}

{{{5}}}


 Answer:
The module can only output one distance at a time and does not support the output of point cloud information temporarily.
{{{3}}}
{{{4}}}

{{{5}}}


 Answer:
The connector is GH1.25.
{{{3}}}
{{{4}}}

{{{5}}}


 Answer:
For example, if the data received is ad 08 00. Because the data is saved in little-endian mode, it should be taken as 0x0008ad, convert it to DEC mode it should be 2221, and divide with 1000 you can get the distance data 2.221m.
{{{3}}}
{{{4}}}

{{{5}}}


 Answer:
The checksum is to add all the previous bytes and take the lowest byte of data. For example, the checksum of
55 01 00 ef 03 is 0x55+0x01+0x00+0xef+0x03=0x0148

then the checksum is 48, so The complete data of this frame is 55 01 00 ef 03 48.

{{{3}}}
{{{4}}}

{{{5}}}


 Answer:
In IIC mode, the device's SDA and SCL pins are recommended to be output in open-drain mode. At this time, a pull-up resistor is required on the bus. During communication, functions such as start, stop, read, write, and response should be programmed according to the standard IIC communication sequence. When communicating with the TOF module, refer to the NLink_TOFSense_IIC_Frame0 protocol in the user manual to read and write the registers. Pay special attention to the shift of the 7-bit slave address and increase the read/write bit to send
{{{3}}}
{{{4}}}

{{{5}}}


 Answer:
Visual C ++ Redistributable for Visual Studio 2017, if the above installation fails or shows success, but opening the assistant program still prompts that the DLL file is missing. Note, please select the patch for the computer system.
{{{3}}}
{{{4}}}

{{{5}}}


 Answer:
Please check whether the installation file is silently intercepted by the security software, please exit the security software and reinstall it. Also, run with administrator rights.
{{{3}}}
{{{4}}}

{{{5}}}


Support