Different pre-built firmware lead to different installation ways.
It is suggested to ask the manufacturer about the pre-built firmware and its version.
Our Kakute H7 v1.3 has a pre-built firmware of BetaFlight. Then the version can be found with the help of BetaFlight Configurator that can auto detect the pre-built board and firmware.
Run BetaFlight Configurator, in Disconnected status, we click Firmware Flasher on the left sidebar, then it will auto detect the board and the firmware version
Also, we can switch to Connected status by clicking connect on the top right. Click CLI on the left side bar, typing dump on the terminal on the right will give more information
Tutorials are given by Ardupilot at Loading Firmware onto boards without existing ArduPilot firmware¶. Read this before going further.
Since Kakuteh7's prebuilt firmware is not Ardupilot, installation files should include bootloaders.
Following steps shown in Loading Firmware onto boards without existing ArduPilot firmware:
-
Go to webpage https://firmware.ardupilot.org/Copter/stable-4.4.0/KakuteH7/
-
Download arducopter_with_bl.hex.
Or, we can build an Ardupilot firmware ourself.
-
use Waf to build an Ardupilot firmware for the chosen board. Tutorials to use Waf https://github.com/ArduPilot/ardupilot/blob/master/BUILD.md.
- clean previous built firmware
cd ardupliot ./waf distclean
- The available list can be found by
cd ardupliot ./waf list_boards
- video tutorial for next two steps https://youtu.be/lNSvAPZOM_o.
- choose firmware - it is Pixhawk5X for us
cd ardupliot ./waf configure --board Pixhawk5X
- build it
cd ardupliot ./waf copter
- find the built ardupliot file at /ardupliot/build/board_name/bin, like
There are two ways to write Ardupilot firmware into Kakuteh7: STM32CubeProgrammer or BetaFlight Configurator.
Connect FC in DFU mode
Kakute must be connected in DFU mode. To do that, press the button of Kakute, and then connect it to the work station through a USB port.
Check if Kakute is in DFU mode, we type
sudo dfu-util --list
if we can see something like Internal Flash, shown below, it means Kakute is in DFU mode.
Use STM32CubeProgrammer
- Download STM32CubeProgrammer software for Linux from its official site
- Install and run STM32CubeProgrammer
- Choose USB as connection way and choose USB1, according to your station, as Port. Click flash button next port if nothing shows there.
- Click Open file and choose downloaded arducopter_with_bl.hex.
- Click button Download and it begins wiring Ardupilot into Kakuteh7.
- Click button Disconnect and unplug the USB cable.
Use BetaFlight Configurator (To check)
Please read Mandatory Hardware Configuration first.
Connecting the autopilot with a working station through a USB port. Run Mission Planner.
Go to Setup-->Mandatory Hardware-->Frame Type.
- Since our chassis and ESC are for BetaFlight type, we need to go to Configuration->Full parameter list, and set FRAME_TYPE to be 12.All supported types are available here
-
Bind receiver and transmitter Please see Transmitter searching for RadioLink AT9S Pro and RadioLink R12DSM.
For the receiver's protocol, it is suggested to use SBUS. It can be done by pressed the button for 2s and we should see the LED flashes blue.
-
Configure Ardupilot to use transmitter Ardupilot will automatically detect Radio inputs. There is nothing to be configured.
When calibrate the transmitter, it is important to set two switches: one to kill, i.e. stop motors, and the other is to change flight modes. They must be on different sides to be user friendly.
Connect a battery to the drone and also connect the drone to the work station running Mission Planner through a USB port.
- Test motor order This is to check if the motors are connected to the ESC board correctly, motor 1 is corrected to the ESC's pin for motor 1.
We can see from Connect ESCs and Motors that the motors' ordering and direction for BetaFlightX.
Then, open Initial Setup->Optional Hardware->Motor Test.
Control motors in sequence to see if the correct motors spin:
- motor A - motor 2 in the front right,
- motor B - motor 1 on the back right,
- motor C - motor 3 on the back left,
- motor D - motor 4 on the front left spin.
It is essential to notice that ArduPilot keeps this tradition naming motor A, B, C, D in a different way than 1, 2, 3, 4 in Motor Test.
If one motors responds in a wrong way, we need to check if it is connected to ESC at the correct pins.
- Test motor direction
Motors directions also must be checked tests. As we can see from the image above that
- motor A, or motor 2, must spin in CCW,
- motor B, or motor 1, must spin in CW,
- motor C, or motor 3, must spin in CCW,
- motor D, or motor 4, must spin in CW.
Dont worry if they are not in the correct direction. There are two ways to to inverse the direction of a motor.
Image motor 3 is connected to the ESC with 3 wires. We find its direction needs to be inverted.
We can inverse the direction by switching any two of the three wires. One example is shown below.
Since our ESC is BLHeli32, we can use BLHeLiSuite32 to decide motors' direction.
Config Ardupilot to enable using to change the motors' directions following the steps in Pass-Through Support.
Adjust the motors' directions following the Youtube video How To Update BLHeli 32 & Change Motor Directions.
It is suggested to update BLHeli32 firmware first and then begin modify parameters.
Steps:
-
Connect a battery to the drone and a USB cable to a computer.
-
We click connect and check buttons. Then, we can find the versions of BLHeili that are 32.8 as shown below
-
We update the BLHeili versions. Lets click Flash BLHeili and we can see that it is possible to update to 32.9. Click OK.
-
Wait for 4 ESCs to be updated
-
Click Disconnect button. Disconnect the battery and the USB cable.
-
Reconnect the battery and the USB cable. Click Connect and Check button to see if all ESCs are updated.
-
However spinning motors to check their directions does not work. More investigation is needed here. We need to go back to MissionPlanner to use Motor Tests to spin motors.
-
For instance, motor 1 needs to reverse its direction. We can modify Section Motor Direction from Normal to Reversed, then we click button Write Setup.
-
Click Disconnect button. Disconnect the battery and the USB cable. Reconnect the battery and the USB cable. Use MissionPlanner's Motor Test to check if their directions are correct now.
After that, disconnect the battery.
-
we need to choose protocols for our ESC by setting parameter MOT_PWM_TYPE. More details can be found at Electronic Speed Controller (ESC) Calibration.
-
As our ESCs supports multiple protocols, we can choose DShot600 as it suits most UAVs. How to choose protocols can be found at DShot ESCs.
-
Therefore, we set MOT_PWM_TYPE as 6 that is for DShot600.
- Whether ESCs need calibration depends on what protocols are. Check Section About ESC Calibration at Electronic Speed Controller (ESC) Calibration.
Since our ESCs use DShot600, there is no need to calibrate them. We can skip this step.
For others, there are several ways for ESC calibration at Electronic Speed Controller (ESC) Calibration. But Semi Automatic ESC-by-ESC Calibration is suggested, as it easier and time-efficient.
Source:
- Ardupilot wiki: BLHeli32 and BLHeli_S ESCs
- Ardupilot community: My Method for Iteratively Configuring Motor Ordering and Direction
- Youtube: How To Update BLHeli 32 & Change Motor Directions
##TODO
If you prefer using QGroundControl, you can read Sensor Setup using QGroundControl for Ardupilot.
If you prefer Mission Planner, you can watch this video ArduPilot FPV Drone Setup (MICRO FPV ARDUCOPTER!).
Note that there is no compass for Kakute Note that Kakute does not have an internal compass. We can see from Kakute' introduction at Holybro that
IMU is MPU6000 and we can look for MPU6000 information from its datasheet at MPU6000 at TDK.
Therefore, we need to set COMPASS_ENABLE
to be 0 which means the compass is disabled.
Go to SETUP->Mandatory Hardware->Accelerometer Calibration
Click button Calibrate Accel, then we place the drone into different pose: flat, left, right etc. We need to first place the drone to the requested pose, and click button Next.
Then, it is also suggested to Calibrate Level. We put the drone on a flat surface, then click that button.
However, it seems MissionPlanner does not offer a gyroscope calibration and it is no necessary? Double check is needed here.
Now the solution is to run QGroundControl. Go to Vehicle Setup->Sensors->Gyroscope.
Place the vehicle on a surface and leave it still and click OK to begin.
Two things are to be done before arming the drone for the first time.
First, insert a SD card to the Kakute to record logs. Then in Mission Planner, we need to set parameters such that flight logs are recorded during tasks.
Second, check failure safe and kill switch:
- check the flight mode is STABILIZE
- turn off kill switch
- place the left stick on right-down position for 5 seconds and we should see propellers spin.
If arming failed, please check the following resources:
- PreArm: Logging not started , PreArm: Logging Failed , Bad Logging : copter 3.6.9
- Prearm: Logging Failed error
- Prearm logging failed and no logs with the version 4.0.3
- Logging failed, preventing arming
- “Compass not healthy” preventing arming even though compasses are disabled (using SLAM instead)
Read Analytical Multicopter Flight Controller PID Optimization first.
Guides can be found at ArduCopter, Tuning.
Parameters for motors, battery, and PID gains are needed to be tuned roughly before the first flight. Details can be found at Setting the Aircraft Up for Tuning.
To avoid complex tuning, MissionPlanner gives a tool to set parameters based on the drone. We ca find a tool at SETUP->Mandatory Hardware->Initial Parameter Setup, we can automatically obtain the needed parameters after inputting the size of propellers, the number of cells, and voltages of battery.
If the quadrotor can takeoff, not perfectly, then we can continue tuning.
There is a cascade control in Ardupilot framework. During manual flights, usually STABILIZE mode, we input target attitudes to the attitude controller. It computes the target bodyrates, then the motor torques are computed and sent to motors.
The schematic view is given as below.
source = Copter Attitude Control, https://ardupilot.org/dev/docs/apmcopter-programming-attitude-control-2.html.For a cascade controller, we begin with the gains of inner loop. In other words, we first tune the PID gains for bodyrates, which are
- ATC_RAT_PIT_P
- ATC_RAT_PIT_I
- ATC_RAT_PIT_D
- ATC_RAT_RLL_P
- ATC_RAT_RLL_I
- ATC_RAT_RLL_D
Then, we tune gains for attitude
- ATC_ANG_PIT_P
- ATC_ANG_RLL_P
- ATC_ANG_YAW_P
PID parameters are in Tab Extended Tuning
CUAV provides an explanation of this interface in Chinese.
source: CUAV, 扩展调参(pid)
Use the parameters in the table given by TMac
source: Arducopter Tuning (AUTOTUNE, PIDs & FILTERS, FLIGHT TESTS!), https://youtu.be/AF6aA2z6rhw?si=U-aBvI92rl0DwJIR.
Logs are essential for us to monitor a drone's status and to tune gains and parameters.
It is Dataflash, or we call log, that can record flight information. It can be saved on a SD card and downloaded using Mavlink.
Read Downloading and Analyzing Data Logs in Mission Planner to undestand how to setup logs.
Two important parameters are
- LOG_BACKEND_TYPE that decides saving logs on a SD card or into board dataflash memory.
- LOG_BITMASK chooses what flight data to be recorded, like IMU, GPS, etc.
The table 1 and table 2 of Analytical Multicopter Flight Controller PID Optimization explain Log message and LOG_BITMASK value.
We can use Mission planner to download a log and see Downloading logs via MAVLink of Downloading and Analyzing Data Logs in Mission Planner.
Flight data are saved in the form of messages in logs, please refer to Onboard Message Log Messages to find which message is for which data. For instance, message ACC records IMU accelerometer data.
UAV log viewer is a tool for Ardupilot to analyse its logs, which allows us to find ref and actual values of attitude and bodyrates.
In Plot Individual Field, we choose ATT to plot reference and actual values of roll, pitch and yaw angles. RATE allows us to checking bodyrate tracking.
One example of checking roll tracking is given here.
Fly drones and record their data into logs, then tune attitude and rate controllers based on logs.
Here is one example of tuning just for 2 times