Reference
Library
- Click to download DFRobot TF Mini Library
- Click to download DFRobot LCD library file
Communication Protocol Description
The standard version of TF03 supports two communication modes: TTL and CAN. Users can send commands to change the default TTL mode. The two modes cannot be used simultaneously.
Serial Port Mode
TF03 serial port mode adopts UART-LVTTL interface. The output level is LVTTL level (0~3.3V), and the details are shown below:
| Item | Content |
|---|---|
| Communication Protocols | UART |
| Band Rate | 115200 |
| Data Byte | 8 |
| Stop Byte | 1 |
| Check Byte | None |
Standard Serial Data Format(UART)
TF03 outputs data in the format shown below. All values are hexadecimal, and each frame contains 9 bytes. The data includes the measured distance (DIST); other bytes are reserved; the last byte is the checksum.
| Data Byte | Define | Description |
|---|---|---|
| Byte0 | Frame Head | 0x59 |
| Byte1 | Frame Head | 0x59 |
| Byte2 | DIST_L | DIST low eight bits |
| Byte3 | DIST_H | DIST high eight bits |
| Byte4 | Reserved | / |
| Byte5 | Reserved | / |
| Byte6 | Reserved | / |
| Byte7 | Reserved | / |
| Byte8 | Check | Low eights bytes of Checksum, Checksum=Byte0 + Byte1 + ...+ Byte7 |
Serial Port Pixhawk Data Format
Pixhawk data format is output in the form of string, unit m. For example, if the measured distance is 1.21m, then output the string 1.21. There is a linefeed behind each distance value. In serial communication, the output mode can be changed to pixhawk output mode via command.
High/Low Level Output
Set a threshold (adjustable), when the measured distance is more /less than the threshold, output high/low.
- a) The high/low level can be adjusted. By defaut, high level for short distance, low level for long distance.
- b) Adjustable buffer area(prevent level jumping caused by datashake)
- c) Adjustable delay function of High and low level
- Delay before triggering. Set a threshold 10m, and if the distance is less than 10m, output high. When the distance is less than 10m, add an adjustable delay(default as 0ms). Now if the distance is still less than 10m after the delay, output High.
- Delay after triggering. Set a threshold 10m, and if the distance is less than 10m, output high. When the output distance is more than 10m, add an adjustable delay(default as 0ms). Now if the distance is still more than 10m after the delay, output low.
For example:
- a) Set the output mode of TF03 as IO high/low level output, command: ---5a 05 05 05 69
- b) Set: When the distance is less than threshold, output high, otherwise, low. Command:---5A 05 61 01 C1
- c) Add a delay of 100ms for the level change when the distance increases or decreases. Command: ---5A 08 62 64 00 64 00 8C
- d) Set the distance threshold to 500cm, buffer area to 5cm. Command: ---5A 08 63 F4 01 05 00 BF
- e) Save the settings, command: ---5A 04 11 6F
- f) Restore the factory configuration(if necessary), command: ---5A 04 10 6E
CAN Bus Mode
The CAN communication protocol of TF03 can be customized. CAN band rate, ID, and Frame format are adjustable. As seen below:
| Item | Content |
|---|---|
| Communication Protocols | CAN |
| Band Rate | 1M |
| Receive ID | 0x3003 |
| Transmit ID | 0x3 |
| Check Byte | Transmit Frame is regarded as standard frame by default, and receive frame supports standard frame and expension frame |
The data format TF03 in CAN mode is shown below. All the data are hexadecimal number and there are 8 bytes in each data frame. The data includes real measured distance(DIST); the other bytes are reserved.
| Data Byte | Define | Description |
|---|---|---|
| Byte0 | DIST_L | DIST low eight bits |
| Byte1 | DIST_H | DIST high eight bits |
| Byte2 | Reserved | / |
| Byte3 | Reserved | / |
| Byte4 | Reserved | / |
| Byte5 | Reserved | / |
Principle
TF03 employs the pulsed time-of-flight principle. The unique design of the optical system and the signal processing circuit improved the detecting performance in a compact size.
Customized Configuration
General Command Description
The product parameters can be changed to meet requirements of various application. Users can send the related command to revise the original parameters, such as output data format, frame rate and so on. After the setting completed, input write-in configuration command then the parameters will be saved in Flash and users don't need to reset after restarting the device.
Please change the parameters according to the instruction, and do not try sending irrelevant or unstated command in case of causing unnecessary lost.
| Byte | byte0 | byte1 | byte2 | byte3~byteN-2 | byteN-1 |
|---|---|---|---|---|---|
| Description | Head | Len | ID | Payload | Checksum |
- Head: fixed
0x5A - Len: length of the entire command frame (bytes)
- ID: identifies the function of the command
- Payload: parameter field (varies by command)
- Checksum: sum of all bytes except checksum, low 8 bits
| Function | Downstream | Upstream | Description | Factory Configuration |
|---|---|---|---|---|
| Get firmware Version | 5A 04 01 5F | 5A 07 01 V1 V2 V3 SU | Version: V3.V2.V1; SU: checksum | / |
| System Reset | 5A 04 02 60 | Succeed: 5A 05 02 00 61; Fail: timeout 1s, no response | / | / |
| Set Output frame rate | 5A 06 03 LL HH SU | Succeed: same as downstream; Fail: timeout 1s, no response | / | 100fps |
| Enable Output | Enable: 5A 05 07 01 67; Disable: 5A 05 07 00 66 | Succeed: same as downstream; Fail: timeout 1s, no response | / | Enable |
| Single Trigger | 5A 04 04 62 | Data Frame | / | / |
| Set Output Format | 5A 05 05 LL SU | Succeed: same as downstream; Fail: timeout 1s, no response | LL: output format, for instance: 00:ASCII output(reserved);01: binary output; 02: PIX output; 05: IO output | Binary |
| Set serial band rate | 5A 08 06 H1 H2 H3 H4 SU | Succeed: same as downstream; Fail: timeout 1s, no response | band rate=(H4 << 24)+(H3 << 16)+(H2 << 8)+H1 | 115200 |
| Check and Enable | Enable:5A 05 08 01 68; Disable: 5A 05 08 00 67 | Succeed: same as downstream; Fail: timeout 1s, no response | / | Enable |
| Restore Factory Configuration | 5A 04 10 6E | Succeed: 5A 05 10 00 6F; Fail: 5A 05 10 ER SU | Fails if ER is not equal to 0 | / |
| Save Configuration | 5A 04 11 6F | Succeed:5A 05 11 00 70; Fail:5A 05 11 ER SU | Fails if ER is not equal to 0 | / |
| Configure Over Range Value | 5A 06 4F LL HH SU | Succeed: 5A 05 4F 00 AE; Fail: timeout 1s, no response | Over Range Value=(HH << 8) + LL, unit: cm | 18000 |
| Configure CAN transmit ID | 5A 08 50 H1 H2 H3 H4 SU | Succeed:5A 05 50 00 AF; Fail: timeout 1s, no response | ID=(H4 << 24)+(H3 << 16)+(H2 << 8)+H1 | 0x3 |
| Configure CAN receive ID | 5A 08 51 H1 H2 H3 H4 SU | Succeed: 5A 05 51 00 B0; Fail: timeout 1s, no response | ID=(H4 << 24)+(H3 << 16)+(H2 << 8)+H1 | 0x3003 |
| Configure CAN band rate | 5A 08 52 H1 H2 H3 H4 SU | Succeed:5A 05 52 00 B1; Fail: timeout 1s, no response | Baudrate=(H4 << 24)+(H3 << 16)+(H2 << 8)+H1 | 1000000 |
| Configure CAN transmit frame type | Standard frame:5A 05 5D 00 BC; Expanded Frame:5A 05 5D 01 BD | Succeed:5A 05 5D 00 BC; Fail: timeout 1s, no response | / | Standard Frame |
| Configure transmit mode | TTL: 5A 05 45 01 A5; CAN: 5A 05 45 02 A6 | Succeed: 5A 05 45 00 A4; Fail: timeout 1s, no response | / | TTL |
| Environment Compensation Algorithm | Enable:5A 05 64 00 C3; Disable: 5A 05 64 01 C4 | Succeed: 5A 05 64 00 C3; Fail: timeout 1s, no response | / | Enable |
| Configure offset | 5A 06 69 LL HH SU | Succeed:5A 05 69 00 C8; Fail: timeout 1s, no response | Offset = (HH << 8) + LL, unit: cm | 0 |
| Set Trigger level for short distance | 5A 05 61 LV SU | Succeed: 5A 05 61 00 C0; Fail: timeout 1s, no response | LV=0, low level trigger; LV=1, high level trigger | Low |
| Set IO output delay | 5A 08 62 L1 H1 L2 H2 SU | Succeed: 5A 05 62 00 C1; Fail: timeout 1s, no response | Delay1 = (H1 << 8) + L1,Delay2 = (H2 << 8) + L2 (unit:ms), respectively represent the delays of IO level change in short or long distance. Range: 0~65000 | 0, 0 |
| Set distance threshold and buffer distance | 5A 08 63 L1 H1 L2 H2 SU | Succeed: 5A 05 63 00 C2; Fail: timeout 1s, no response | Dist= (H1 << 8) + L1,Buff=(H2 << 8) + L2 (unit: cm), respectively represent the distance threshold and buffer distance of IO change. Range: 0~18000. | 18000,0 |
Description
- Supported output frame rates:
- 1, 2 … 9
- 10, 20 … 90
- 100, 200 … 900
- 1000, 2000 … 9000, 10000
- In trigger mode, disable continuous output before sending trigger commands.
- PIX format is
"x.yz\r\n"in meters. Example:"1.23"for 123 cm. - Supported CAN baud rates: 1M, 500K, 250K, 125K
- Firmware v1.11.3 and above supports user-commanded secondary laser calibration via “configure offset”
- The configured CAN ID must be valid; otherwise unexpected results may occur.
- To use IO trigger mode, set output format to IO mode and configure trigger level, delay, threshold, and buffer distance.
Was this article helpful?
