Introduction

TOF Sense is a TOF-based (Time of Flight) laser ranging sensor that offers 1cm-5m detection range, 1mm resolution, ± 1.5cm error, and 10Hz data update frequency. The sensor supports 15 ° ~ 27 ° adjustable FOV, UART and CAN communication (selected by setting). Besides, it allows users to actively query the output data, making data acquisition much easier. With a size of 35.58 * 12 * 8.05mm, this small and compact sensor can be used as a distance-measuring tool for distance detection, a robot to avoid obstacles, and can also be used in drones areas such as altitude setting and route planning.

The difference from other ranging sensors is that this sensor reserves two identical communication interfaces. When setting IDs for each sensor and connecting multiple sensors in series, the ranging information of all sensors can be read by just one communication interface.

warning_yellow.png NOTE: The UART interface supports a maximum of 8 cascades, and the CAN interface supports 7 cascades at most. Under cascade distance-measuring, it is suitable for UART query, CAN query, and CAN active output.

Specification

Board Overview

TOF_Sense

Color Name Description
Black GND -
Red VCC +
Blue TTL_RXD/CAN_H Serial port receive/ CAN bus
Green TTL_TXD/CAN_L Serial port send/ CAN bus

Module Description

Principle

TOF is an absolute distance detection technique in which the sensor emits a debugged near-infrared light, which is reflected after an object, and the sensor converts the distance of the subject by calculating the time difference or phase difference of light emission and reflection to generate depth information. Compared with the binocular scheme and the 3D structural light scheme, TOF has the advantages of working distance, wide application scene, and higher accuracy over long distance. Therefore, it is often used in personnel proximity detection, robot barrier avoidance, camera autofocus and other occasions. In the outdoor environment, there is near-infrared light from the sun's light, which affects the measurement of the module.

Distance Measurement Principle

Function

TOFSense supports short, medium and long distance measurement modes, each of which can output information such as distance measurement dis, distance status dis status, signal strength signal strength, etc.

Outputs: TOFSense supports active output, query output.

Connection: TOFSense supports UART and CAN outputs. These two output methods share the same set of physical interfaces. Among them, the UART output supports the active output, the query output, and the query output under multiple cascading connections of a single module. The CAN output supports the active output, query output, and the active output and query output under multiple module cascading connections.

Interfaces and Baut Rate

The TOF Sense standard version supports both UART and CAN communication methods, which share a single interface. The factory default is UART communication, if you need to use CAN communication mode, you can configurate it via the module host computer.

UART Communication

Under serial communication, the Baud rate setting range is shown below.

UART_Baudrate Note
115200,230400,460800,921600,1000000,1382400,1843200,2000000,2764800,3000000 924600(baud rate in default)

CAN Communication

Under CAN communication, the Baud rate setting range is shown below.

CAN_Baudrate Note
100K, 250K, 500K, 1M, 2M, 3M 1M (baud rate in default)

Distance Status

The module can output the current distance state, and the user can process the data in conjunction with the distance state, as shown in the table below.

Value Note
0 Valid measurement of distance
1 Standard deviation is greater than 15mm
2 Signal strength is below 1Mcps
4 Phase is out of bounds
5 HW error or VCSEL error
7 Mismatch phase
8 Internal algorithm underflow fault
14 Invalid measurement of distance

Signal Strength

Indicates the strength of the current return signal, and a higher value indicates that the returned signal is stronger.

FOV

The size of the field of view angle determines the field of view of TOFSense, and the module can change the X-way field-of-view angle fov.x, the Y-direction field angle fov.y, the X-directional offset fov.x_offset, and the Y-direction offset fov.y_offset. X, Y direction field of view angle setting range is 15° to 27°, X, Y direction field of view angle offset setting range is -6° to 6°.

Indicator Light

The indicate lights have two flashing states, flashing 50ms quickly and 100ms flashing slowly. The status and meaning of the LED are shown in the table below.

Status Note
Flash quickly(interval 0.1s) Module start-up phase/module firmware update
Flash slowly(interval 1s) The module is working properly

Module protocol resolution

The protocol consists of Frame Header, Function Mark, Data, sum Check. Among them, Frame Header and Function Mark are fixed values. Data is the data of transfer content. Sum Check is the lowest byte of the sum (that is, all the following bytes added) of Frame Header, Function Mark, and Data. The composition of the agreement: Frame Header + Function Mark + Data + Sum Check

1.Example This example takes a single-module continuous ranging with the UART active output mode as the scenario.

Raw data: 57 00 ff 00 9e 8f 00 00 ad 08 00 00 03 00 ff 3a

The instruction format is as follows:

Data Type Length(Bytes) Hex Result
Frame Header uint8 1 57 0x57
Function Mark uint8 1 00 0x00
Reserved uint8 1 ff *
ID uint8 uint8 1 00
System_time uint32 4 9e 8f 00 00 36766ms
dis * 100 uint24 3 ad 08 00 2.221m
dis_status uint8 1 00 0
signal_strength uint16 2 03 00 3
Reserved * 1 ... *
Sum Check uint8 1 3a 0x3a

Cascade ranging measurement

The ranging information for all sensors can be read through a single communication interface by configuring multiple sensors with different IDs and in series. The connection diagram is shown in the following image.

600px-SEN0337 Cascade range

Please note that cascade range is only suitable for UART queries, CAN queries, and CAN active output.

Tutorial: Arduino Debugging(PC serial port)

Requirements

Since TOF Sense is a serial port device, while the average Arduino has only one hardware serial port. So, it is recommended to use a soft serial port to work with sensors, and users can also use multiple serial devices, such as Arduino Leonardo, Arduino Mega2560, etc. The most common one--Arduino UNO is used here as a controller, defining D10 and D11 as soft string ports.

Connection Diagram

Use the PC-side serial port software to display the distance detected and to power the entire system.

TOF_Sense Serial port connection

Sample Code

PC serial tool is required, and the data read will be displayed in the serial tool interface

/*
  * @File  : DFRobot_TFmini_test.ino
  * @Brief : This example use TFmini to measure distance
  *         With initialization completed, we can get distance value and signal strength
  * @Copyright   [DFRobot](https://www.dfrobot.com), 2016
  *             GNU Lesser General Public License
  *
  * @version  V1.0
  * @date  2018-1-10
*/

#include <SoftwareSerial.h>
SoftwareSerial mySerial(11,10); // RX, TX
int i;
int dat[32]={0};
unsigned long a,p,q,z;
void setup()
{
 Serial.begin(9600);
 mySerial.begin(115200);
}

void loop()
{
    if(mySerial.available()>=32)
    {
      if(millis()-a>500)
      {
        a=millis();
        for(i=0;i<32;i++)
        {
          dat[i]=mySerial.read();
        }
        for(i=0;i<16;i++)
        {
          if(dat[i]==0x57&&dat[i+1]==0&&dat[i+2]==0xff&&dat[i+3]==0)
          {
            if(dat[i+12]+dat[i+13]*255==0)
            {
              Serial.println("Out of range!");
            }
            else
            { 
          z=dat[i+11];
          Serial.print("Status = ");
          Serial.print(z);
          p=dat[i+12]+dat[i+13]*255;
          Serial.print("  Strength = ");
          Serial.print(p);
              q=dat[i+8]+dat[i+9]*255;
              Serial.print("  Distance = ");
              Serial.print(q);
              Serial.println("mm");
            }
             break; 
          }
        }
      }
    }
}

Expected Results

SEN0321result

FAQ

Q&A Some general Arduino Problems/FAQ/Tips
A For any questions, advice or cool ideas to share, please visit the DFRobot Forum.

More Documents

DFshopping_car1.png Get TOF Sense Laser Ranging Sensor(5m) from DFRobot Store or DFRobot Distributor.

Turn to the Top