uart (1)

31110809890?profile=RESIZE_710x

TFmini-Plus can directly be connected with the one of the serial ports of CUAV V5. There are four serial ports which can be used to interface LiDAR. The following port mapping shows hardware (left) and software (right) serial port mapping:  

  • TELEM1 > SERIAL1
  • TELEM2 > SERIAL2 (used in this tutorial)
  • GPS Port > SERIAL3
  • UART4 > SERIAL4

TFmini-Plus can be interfaced with flight controller for the purpose of Altitude Holding or Obstacle Avoidance. At the time of writing this document the controller used was CUAV V5 flashed with ArduCopter V4.0.7. But this document can be used with other flight controllers running with different ArduCopter firmware versions with slight modification in parameter names and choosing the right port on flight controller. For choosing right port, please refer to the hardware and software serial port mapping of flight controller.

Example for connecting mini-Plus to CUAV V5:

31110861671?profile=RESIZE_710x

Figure 1 Schematic Diagram of Connecting TFmini-Plus with TELEM 2 Interface (Serial Port 2) of CUAV V5

The same procedure can be followed for other serial ports like TELEM1/GPS/UART4 by looking at the pin out details given below:

31110886452?profile=RESIZE_710x

Figure 2 Pinout description of available serial ports on CUAV V5

Note: Standard output mode of LiDAR should be used instead of PIX mode in the latest firmwares. PIX mode was only required for the firmware versions older than Arducopter V3.6.2.

a) Mission Planner configuration description of TFmini-Plus for the purpose of altitude hold

Connect the flight control board to Mission Planar. Attention: the installation height should be larger than non-detection/blind zone of LiDAR. 

31040485701?profile=RESIZE_710x

Select [CONFIG/TUNING] and then click on [Full Parameter List] in the left from the below bar. Find and modify the following parameters:

SERIAL2_PROTOCOL = 9  [Rangefinder option]

SERIAL2_BAUD = 115  [Choose the current LiDAR baud rate, if haven’t been changed, the default baud rate 115200 should be selected, that is 115]

RNGFND1_TYPE = 20 [TFmini-Plus UART option]

RNGFND1_MIN_CM = 30 [It could be changed according to real application requirement and should be greater LiDAR than non-detection zone, unit is cm]

RNGFND1_MAX_CM = 300   [It could be changed according to real application requirement and should be smaller than effective measure range of LiDAR, unit is cm]

RNGFND1_GNDCLEAR = 15 [expressed in cm, depending upon mounting height of the module and should be greater LiDAR than non-detection zone]

RNGFND1_ORIENT=25 [facing down]

PRX_TYPE=0

Upon setting of these parameters, click [Write Params] on the right of mission planner to finish. After writing the parameters you need to power off the controller and then turn it on to apply the setting changes.

If the error message “Bad LiDAR Health” appears, please check if the connection is correct, the power supply is normal and you have restarted the controller. Also check it whether you have changed the mode from Standard mode to Pix mode while the firmware is 3.6.2 or higher. If yes, then the same error will encounter.

How to see the altitude value from LiDAR sensor: double click the area of the Mission Planner, look at the following picture:

31040486491?profile=RESIZE_710x

Select option sonarrange, see following picture:

31040486294?profile=RESIZE_710x

The altitude distance from the LiDAR will be displayed in Sonar Range (meters), see the following picture:

31040486874?profile=RESIZE_710x

B)Mission Planner configuration description of TFmini-Plus for the purpose of Obstacle Avoidance

Connect the flight control board to MP. Attention: distance between UAV margin and LiDAR should be larger than LiDAR non-detection zone. Select [Full Parameter List] in the left from the below bar- [CONFIG/TUNING]. Find and modify the following parameters:

AVOID_MARGIN=2 [Unit: m, set obstacle avoidance distance as required]

SERIAL2_PROTOCOL = 9 [Rangefinder option]

SERIAL2_BAUD = 115 [Choose the current LiDAR baud rate, if haven’t been changed, the default baud rate 115200 should be selected, that is 115]

RNGFND1_TYPE = 20 [TFmini-Plus UART option]

RNGFND1_MIN_CM = 30   [It could be changed according to real application requirement and should be greater LiDAR than non-detection zone, unit is cm]

RNGFND1_MAX_CM = 300 [It could be changed according to real application requirement and should be smaller than effective measure range of LiDAR, unit is cm]

RNGFND1_ORIENT = 0   [It depends on the LiDAR’s real installation direction, 0~7, 24=Up and 25=Down (total ten) are supported up till now, see details in MP]

PRX_TYPE=4    [Rangefinder should be selected for proximity sensor in obstacle avoidance mode]

AVOID_ENABLE= 3 [if 3 = UseFence and UseProximitySensor doesn’t work in IIC then choose 2 = UseProximitySensor]

Upon setting of these parameters, click [Write Params] on the right of the software to finish. After writing the parameters you need to power off the controller and then turn it on to apply the settings.

If the error message “PreArm: check the proximity sensor” appears, please check if the connection is correct, the power supply is normal and you have restarted the controller. Also check it whether you have changed the mode from Standard mode to Pix mode while the firmware is 3.6.2 or higher if yes then the same error will encounter.

31040486890?profile=RESIZE_584x

 

How to see the target distance measured by the LiDAR: (distance from LiDAR in obstacle avoidance can’t be displayed in sonarrange option) press Ctrl+F button in keyboard, the following window will pop out:

31040486695?profile=RESIZE_710x

Click button Proximity, the following window will appear:

31040487455?profile=RESIZE_710x

The number in green color means the distance from LiDAR in obstacle avoidance mode(it doesn’t mean the real time distance from LiDAR and will not be influenced in Mission Planner. The mission planner version at the time of writing this tutorial was v1.3.69.

Attach: If TELEM 2 port has been used, UART4/GPS Port/TELEM1 interfaces can also be used, the other setting are same

Configuration Descriptions on Mission Planner:

Connect flight control board to MP, Select [Full Parameter List] in the left from the below bar [CONFIG/TUNING]. Find and modify following parameters:

For UART4:

SERIAL4_PROTOCOL = 9 (LiDAR)

SERIAL4_BAUD = 115

For GPS Port:

SERIAL3_PROTOCOL = 9 (LiDAR)

SERIAL3_BAUD = 115

For TELEM1:

SERIAL1_PROTOCOL = 9 (LiDAR)

SERIAL1_BAUD = 115

Upon setting of these parameters, the other parameters are same as Mission Planner configuration description of TFmini-Plus for the purpose of Obstacle Avoidance or Altitude Holding, then click [Write Params] on the right of the software to finish.

Important Note: If you have configured protocol type (SERIALX_PROTCOL: X can be 1, 2, 3, 4 etc.) for more than one UART ports as 9: Rangefinder but you have connected LiDAR to only single UART port, then it will give Bad LiDAR Health error. So you need to configure only those UART ports as 9: Rangefinder to which you will connect LiDAR. In other words we can say that if the number of serial ports configured as 9: Rangefinder is less than the number of connected LiDARs then Bad LiDAR Health will occur.

To learn more about Benewake TFmini-Plus, see: https://benewake.short.gy/tfmini-plus-lidar.

Read more…