Configuring TFS20-L with UART Interface on Ardupilot Flight Stack using PixHawk 6C and 6X Flight Controllers

TFS20-L can directly be connected with one of the serial ports of Pixhawk 6C or 6X from Holybro. 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)
  • TELEM3 (USART2) >SERIAL5
  • GPS2 Port (UART8) >SERIAL4

TFS20-L can be  interfaced  with  flight  controller  for  the  purpose  of Altitude  Holding  or  Obstacle Avoidance or Terrain Following. At the time of writing this document the flight controller used was PixHawk 6C from Holybro flashed with ArduCopter V4.3.3. However, this document can also be used with PixHawk 6X and 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, refer to the hardware and software serial port mapping of flight controller. Please note that supported firmware of Ardupilot for PixHawk 6C and 6X is 4.2.3 stable release and later.

 13698896065?profile=RESIZE_180x18013698896079?profile=RESIZE_180x180

Figure-1: Pinout sequence of available ports on PixHawk 6C

NOTE: Pin 1 starts from the flight controllers "right side" like in the diagram shown above

 

13698896086?profile=RESIZE_584x

Figure-2: Pinout description of available serial ports on PixHawk 6C

 

Example for connecting TFS20-L to PixHawk 6C:
13698896273?profile=RESIZE_584x

Figure 3: Schematic Diagram of Connecting TFS20-L with TELEM 2 Interface (Serial Port 2) of PixHawk 6C

The same procedure can be followed for other serial ports like TELEM1/TELEM3/GPS2 by looking at the pin out details given in Figure-2.

Notes:

  1.    Please payattention toconnect right wires to the right pins of flight controller. For pin sequence refer to Figure-2.
  2.    Related  connectors  need  to  be  purchased  by  the  user,  LiDAR  connectoris  SMDHC-0.8-6PWT  (PCB  connector)  and  JST  SUR  0.8mm  Pitch  (mating  connector), while flight controller needs JST-GH with 1.25mm pitch.
  3.    IfLiDARfaces down, please take care of the  distance between lens and ground, it should be larger than LiDAR’sblind zone (20cm).
  4.    Powersourceshould meet the product manual current and voltage requirements: peak current is 115mA @ 3.3V.

a Mission Planner configuration description for TFS20-L used for Altitude Hold

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

PRX1_TYPE = 0 [on equal to 4 also gives the value if RNGFND1_ORIENT = 25] 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 [TFS20-L/TFmini-Plus/TFmini-S 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 =  25  [expressed  in  cm,  depending  upon  mounting  height  of  the  module  and should be greater LiDAR than non-detection zone]

RNGFND1_ORIENT = 25 [facing down]

13698896892?profile=RESIZE_710x

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 have you restarted the controller?

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

13698896873?profile=RESIZE_584x

 

Select optionsonarrange, see following picture:
13698888263?profile=RESIZE_584x

 

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

 

bMission Planner configuration description for TFS20-L used for Obstacle Avoidance

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

AVOID_ENABLE  =  0  [If  0  =  UseFence  and  UseProximitySensor  doesn’t  work  in  IIC  then  choose  1 = UseProximitySensor]

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

PRX1_TYPE = 4 [Rangefinder should be selected for proximity sensor in obstacle avoidance mode] 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 [TFS20-L/TFmini-Plus/TFmini-S 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]

AVOID_BEHAVE = 0 [This parameter will define what drone will do upon the encounter of obstacle (stop or slide to avoid the object) 0: Slide1: Stop]

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 have you restarted the controller.
13698897092?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:
13698897654?profile=RESIZE_710x

 

Click button Proximity, the following window will appear:
13698889493?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.79.

  1. c)  IfTELEM  2 port has been used, TELEM1/TELEM3/GPS2-Port interfaces

can also be used, the other settings 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 TELEM1:

SERIAL1_PROTOCOL = 9 (LiDAR) SERIAL1_BAUD = 115

For TELEM3:

SERIAL5_PROTOCOL = 9 (LiDAR) SERIAL5_BAUD = 115

For GPS2:

SERIAL4_PROTOCOL = 9 (LiDAR) SERIAL4_BAUD = 115

Upon  setting  of these  parameters, the  other parameters  are  same  as  Mission  Planner  configuration description of TFS20-L 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 greater than the number of connected LiDARs then Bad LiDAR Health error will occur.

E-mail me when people leave their comments –

You need to be a member of diydrones to add comments!

Join diydrones