目录
Tools and connection methods for connecting PC for testing:
Radar, Radar cable, TTL-USB board, USB cable, Computer, General serial port assistant,USB-IIC converter
Connect the “radar”, “data cable”, “TTL - USB adapter board” and “USB cable” in turn to ensure no looseness, and then connect the “USB cable” with the “computer”. At this time, the status is in the serial port mode. After sending the command to modify the radar mode, disconnect the above connection, and connect the “radar”, “data cable” and “USB-IIC converter” in turn. After ensuring that there is no looseness, insert the converter into the computer. At this time, the status is in the IIC mode. (TFLuna can connect to USB-IIC converter directly without using command to change mode)
How to use the general serial port assistant:
Open the serial port assistant, select the correct port number (if there is no serial port number, you may need to install the driver of the converter), and set the matching baud rate (the baud rate matching with the radar is usually 115200 in the serial port mode, and 9600 in the IIC mode).
Tip: Please deselect RTS.
Example of sending command by serial assistant:
TF-Luna
1. IIC mode switching
When pin 5 is grounded, TF Luna starts to IIC mode.
2. Meaning of data returned in IIC mode
According to the beginning of this article, after the radar is successfully connected with the computer, enter the following command “53 20 01 00 50 53 21 02 50”
Command explanation:
0x53: s command of usb-iic adapter, start signal; (see adapter manual for details)
0x20: slave address 0x10, write operation; (the high 7 bits represent the address, and the lowest bit represents read / write; the binary of 0x10 represents 00010000, and the high 7 bits in IIC are the address, so the first left shift bit is 00100000, and the lowest bit is 0, so it is 00100000, that is, 0x20)
00x1 slave register address high 8 bits;
0x00: slave register address 8 bits lower; (read radar data, register address is 0x0100, see tfluna manual for details)
0x50: P command of usb-iic adapter, start stop signal
0x53: s command of usb-iic adapter, start signal
0x21: slave address 0x10, read operation; (the high 7 bits represent the address, and the lowest bit represents read / write; the binary of 0x10 represents 00010000, and the high 7 bits are the address, so the first left shift is 00100000, and the lowest bit read is 1, so it is 00100001, that is, 0x21)
0x02: read 2 bytes of data;
0x50: P command of usb-iic adapter, which initiates stop signal (see adapter manual for details);
At this time, the return value is two bits, which is the hexadecimal writing of the distance value. The first bit is the lower eight bits of the distance value, and the second bit is the higher eight bits of the distance value.
As shown in the figure, the distance value shown in the figure should be 00 + 13 * 16 + 2 = 210cm
3. Method of returning to serial port mode
The serial port mode can be restored when the No.5 pin is suspended during restart.
TFmini-S
1. IIC mode switching
TFmini-S needs to be connected to the PC and send relevant configuration instructions to the product through TF host computer or other serial port debugging software to adjust parameters; customers can also send relevant instructions through their own serial port tools. All instructions are common in UART and IIC mode. Tfmini-s communication interface is factory configured as UART.
Input after connection: 5A 05 0A Mode SU
Where mode = 0 (UART) or 1 (IIC), Su is the check sum.
Important: after sending the parameter configuration command, be sure to send the “save configuration (5A 04 11 6F)” command, otherwise the parameters will be reset when connecting the product again.
2. Meaning of data returned in IIC mode
Combined with TFmini-S read data timing and USB-IIC adapter protocol, the serial port is used to send the corresponding read command.
Example of read command: if the IIC slave address of TFmini-S is 0x10 (factory default), the computer reads the test data of tfmini plus through the serial port.
The command of measuring distance is: “53 20 05 5A 05 00 01 60 50 53 21 09 50”.
Command explanation:
0x53: S command of USB-IIC adapter, start signal; (see adapter manual for details)
0x20: slave address 0x10, write operation; (the high 7 bits represent the address, and the lowest bit represents read / write; the binary of 0x10 represents 00010000, and the high 7 bits in IIC are the address, so the first left shift bit is 00100000, and the lowest bit is 0, so it is 00100000, that is, 0x20)
0x05: write 5 bytes of data;
0x5a: tfmini plus data protocol frame header;
0x05: the command frame contains 5 bytes of data;
0x00: get ranging result;
0x01: data format is 9-byte hexadecimal, CM unit;
0xc0: data check sum of this frame;
0x50: the P command of USB-IIC adapter initiates stop signal
0x53: S command of USB-IIC adapter, start signal
0x21: slave address 0x10, read operation; (the high 7 bits represent the address, and the lowest bit represents read / write; the binary of 0x10 represents 00010000, and the high 7 bits are the address, so the first left shift is 00100000, and the lowest bit read is 1, so it is 00100001, that is, 0x21)
0x09: read 9 bytes of data;
0x50: P command of USB-IIC adapter, and start stop signal (see the adapter manual for details).
The return value is still 9 bits, which is explained as follows:
The distance value returned in the example is: 0 + 13 * 16 = 208cm
3. Method of returning to serial port mode
Example of the command to switch the radar with the address of 0x10 from IIC back to TTL serial port mode: 53 20 05 5A 05 0A 00 69 50 switch mode, then input 53 20 04 5A 04 11 6F 50 to save the configuration.
TFmini-Plus
1. IIC mode switching
TFmini-Plus needs to be connected to the PC and send relevant configuration instructions to the product through TF host computer or other serial port debugging software to adjust parameters; customers can also send relevant instructions through their own serial port tools. All instructions are common in UART and IIC mode. Tfmini-Plus communication interface is factory configured as UART.
Input after connection: 5A 05 0A Mode SU
Where mode = 0 (UART) or 1 (IIC), Su is the check sum.
Important: after sending the parameter configuration command, be sure to send the “save configuration (5A 04 11 6F)” command, otherwise the parameters will be reset when connecting the product again.
2. Meaning of data returned in IIC mode
The return value is still 9 bits,which have the same meaning as TFmini-S.
3. Method of returning to serial port mode
The process is the same as TFmini-S.
TF02-Pro
1. IIC mode switching
TF02-Pro needs to be connected to the PC and send relevant configuration instructions to the product through TF host computer or other serial port debugging software to adjust parameters; customers can also send relevant instructions through their own serial port tools. All instructions are common in UART and IIC mode. TF02-Pro communication interface is factory configured as UART.
Note: the following three steps should be followed when configuring parameters.
a) Enter configuration mode, send: AA 55 F0 00 01 00 02
Return value: AA 55 F0 00 01 00 02 indicates successful transmission;
b) Configure product parameters: modify the communication interface to send 5A 050a mode 00, where mode = 0 (UART) or 1 (IIC);
c) Exit configuration mode, send: AA 55 F0 02
Return value: AA 55 F0 02 indicates successful transmission.
2. Meaning of data returned in IIC mode
The return value is still 9 bits,which have the same meaning as TFmini-S.
3. Method of returning to serial port mode
a) Enter configuration mode, send: 53 20 08 AA 55 F0 00 01 00 02 50
Return value: AA 55 F0 00 01 00 02 indicates successful transmission;
b) Configure product parameters: modify communication interface to send 53 20 05 5A 05 0A 00 00 50;
c) Exit configuration mode, send: 53 20 08 AA 55 F0 00 02 50
Return value: AA 55 F0 02 indicates successful transmission.
At this time, the communication mode has been changed to serial mode.