Application of TF03 CAN in PixHawk (ArduPilot Firmware)

TF03 standard version comes with CAN interface and can be interfaced with PixHawk1 CAN port or any flight controller which has Ardupilot firmware flashed and having CAN interface. Support for CAN protocol has been added to Ardupilot firmwares, starting from Copter 4.2.0 for the purpose of obstacle avoidance and Altitude Hold.

  1. TF03-CAN Settings :

It should be noted that TF03 has two different hardware versions for 485/RS232 and UART/CAN. So when buying LiDAR, please pay attention to buy LiDAR with CAN interface (standard version). Multiple LiDARs can be interfaced to a single CAN bus. We need to assign different CAN IDs to each LiDAR just like we do for IIC communication. The baud-rate of each LiDAR needs to be set to the same value. On LiDAR side we have two types of CAN IDs:

![|5x7](file:///C:\Users\wyt99\AppData\Local\Temp\ksohtml15704\wps4.jpg) Send ID ( Transmit CAN ID ) : it becomes Receive ID on CAN bus side (we need to set this ID

to a new value ifwe are connecting multiple LiDARs.)

![|5x7](file:///C:\Users\wyt99\AppData\Local\Temp\ksohtml15704\wps5.jpg) Receive ID : it becomes Send ID on CAN bus side

I will consider three LiDARs example but Ardupilot supports up to 10 sensors. The commands are mentioned in details in the manual of LiDAR but I will add them here for convenience. It is still advised to read the manual of LiDAR carefully there are important points.

5A 08 50 04 00 00 00 B6 [CHANGE SEND ID TO 04 ]

5A 08 50 05 00 00 00 B7 [CHANGE SEND ID TO 05 ]

5A 08 50 06 00 00 00 B8 [CHANGE SEND ID TO 06 ]

5A 05 45 02 A6 [CHANGE INTERFACE TO CAN ]

5A 04 11 6F [SAVE SETTINGS ]

5A 08 50 03 00 00 00 B5 [CHANGE RECEIVING ID BACK TO 03 ]

Some details about terminating resistor on LiDAR : Terminating resistor on LiDAR is connected by default, utilizing this resistor helps in reducing equivalent resistance of transmission wires, because adding more resistors in parallel will reduce the equivalent resistance. I have tested with total five LiDARs with all LiDARs having resistors enabled.

For sending the above commands , in case you don t have CAN analyzer and only have TTL - USB adapter , it is suggested that first configure the IDs and then switch the interface from UART to CAN because if you first switch interface then you can t use UART interface of LiDAR . In that case you have to use CAN analyzer to set different IDs .

Once you are done with above settings then it’s time to move to physical connection and Ardupilot firmware settings.

We take three TF03-CAN as an example in this passage and set the addresses to 0x03 and 0x04 and 0x05 separately. The default sending ID of LiDAR is 0x03 so leave it for one LiDAR and configure for other two LiDARs to 0x04 and 0x05.

2 . PixHawk Connection :

The following diagram shows how to interface TF03-CAN with PixHawk flight controller.

图片 7

Figure 1: Schematic Diagram of Connecting TF03 to CAN Interface ofPixHawk1

Note

  1. Please pay attention to connect correct wire to correct pin of flight controller. Look at the pinout of controller, pin configurations are starting from left to right :

图片 9

Figure 2: Pin details of CAN Interface ofPixHawk1

  1. Related connectors need to be purchased by user, LiDAR connector is 7-pin JST with 1.25mm pitch.

  2. If LiDAR faces down, please take care the distance between lens and ground, it should be larger than LiDAR’s blind zone ( 10cm).

  3. If more LiDARs need to be connected ( 10 LiDARs can be connected), the method is same.

  4. Power source should meet the product manual current and voltage requirement: 5V to 24V, larger than 150mA*number of LiDAR. I used 12V supply just for reference.

  5. Parameters settings :

Common settings for obstacle avoidance :

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

UseProximitySensor ]

AVOID_MARGIN = 4

PRX_TYPE = 4

Settings for CAN -1 port :

CAN_P1_DRIVER = 1

CAN_D1_PROTOCOL = 11

CAN_P1_BITRATE = [Baud-rate: For TF03 the baud-rate needs to be set to 1000000.]

In case of pixhawk1 we only have one CAN interface but if there are more than one interfaces then configure the parameters for CAN-2 interface.

Settings for CAN -2 port :

CAN_P2_DRIVER = 1

CAN_D2_PROTOCOL = 11

CAN_P2_BITRATE = [Baud-rate: For TF03 the baud-rate needs to be set to 1000000.]

Settings for first TF 03 :

RNGFND1_RECV_ID = 3 [CAN Transmit ID of #1 TF03 in decimal]

RNGFND1_GNDCLEAR=15 [Unit: cm, depending upon mounting height of the module and should be larger LiDAR than non-detection zone. This parameter is required to be configured for altitude hold, it is the installation height of LiDAR from ground.]

RNGFND1_MAX_CM = 400 [It could be changed according to real demands but should be smaller than effective measure range of LiDAR, unit is cm]

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

RNGFND1_ORIENT=0 [#1 TF03 real orientation]

RNGFND1_TYPE = 34 [TF03 same as TF02-i and TFmini-i CAN]

Settings for second TF 03:

RNGFND2_RECV_ID = 4 [CAN Transmit ID of #2 TF03 in decimal]

RNGFND2_MAX_CM=400

RNGFND2_MIN_CM=30

RNGFND2_ORIENT = 6 [#2 TF03 real orientation]

RNGFND2_TYPE = 34 [TF03 same as TF02-i and TFmini-i CAN]

Settings for third TF 03:

RNGFND3_RECV_ID = 5 [CAN Transmit ID of #3 TF03 in decimal]

RNGFND3_MAX_CM=400

RNGFND3_MIN_CM=30

RNGFND3_ORIENT = 4 [#3 TF03 real orientation]

RNGFND3_TYPE = 34 [TF03 same as TF02-i and TFmini-i CAN]

Upon setting of these parameters, click [Write Params] on the right of the software to finish.

If the error message “Bad LiDAR Health” appears, please check if the connection is correct and the power supply is normal. Please turn-off completely the flight controller after configuring the parameters, otherwise changes will not take place. If your battery is connected to your flight controller, please disconnect it as well.

How to see the target distance from the LiDAR: press Ctrl+F button in keyboard, the following window will pop out:

图片 12

Click button Proximity , the following window will appear:

The number in green color means the distance from LiDAR in obstacle avoidance mode the number refreshes when the distance changes or window opens, closes, zooms in or zooms out, and this distance will not be influenced in Mission Planner, the version used at the time writing this tutorial is v1.3.72.

Altitude Hold using CAN Interface :

Let say we use fourth LiDAR for the purpose of 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:

PRX_TYPE = 0 [on equal to 4 also gives the value if RNGFND4_ORIENT = 25]

RNGFND4_RECV_ID = 6 [CAN Transmit ID of #4 TF03 in decimal]

RNGFND4_GNDCLEAR = 15 [Unit: cm, depending upon mounting height of the module and should be larger LiDAR than non-detection zone. This parameter is required for Altitude Hold.]

RNGFND4_MAX_CM = 400 [It could be changed according to real demands but should be smaller than effective measure range of LiDAR, unit is cm]

RNGFND4_MIN_CM = 30 [It could be changed according to real scenario and should be larger than LiDAR non-detection zone, unit is cm]

RNGFND4_ORIENT = 25 [#4 TF03 real orientation]

RNGFND4_TYPE = 34 [TF03 same as TF02-i and TFmini-i CAN]

Upon setting of these parameters, click [Write Params] on the right of the software to finish.

If the error message “Bad LiDAR Health ” appears, please check if the connection is correct and the power supply is normal.

Select option sonarrange, see following picture:

图片 16

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

picture:

图片 17

2 Likes