Part 3: Software Setup And Tuning
We will use Ardupilot as a guide, to get us started: ardupilot.org/copter/docs/initial-setup.html.
INSTALL THE GROUND STATION SOFTWARE
For this guide, we’ll be using Mission Planner, which is only available for Windows. Mac and Linux users can use APM Planner, which is almost the same. You can download the latest Mission Planner version at firmware.ardupilot.org/Tools/MissionPlanner/MissionPlanner-latest.msi
Follow the installation instructions to complete the setup process. Install any third party drivers that the guide suggests to install, then launch Mission Planner.
CONNECT FLIGHT CONTROLLER TO COMPUTER
Connect a micro USB cable to the USB port of the flight board. Windows should automatically detect and install the relevant driver software.
CONNECT TO MISSION PLANNER
Launch Mission Planner and in the top right corner select the flight board in the COM port drop-down. You can select either auto or the specific port that your board is connected to. Set the Baud rate to “115200”. Do not press connect just yet.
Click the “Initial Setup” button and click “Install Firmware” in the left hand side bar. Select Quad. It will ask if you are sure, answer “Yes”.
Mission Planner will detect the board you are using and then ask you to unplug and plug the board back in and press “OK”.
If it runs correctly you should see the status text on the bottom right. Once you see “UPLOAD DONE”, the firmware has been successfully written.
To confirm it works, switch to the Flight Data screen and press connect. The HUD should update when you tilt the board.
CONFIGURING THE HARDWARE
I recommend connecting via telemetry when configuring hardware, as it gives you flexibility in movement when you calibrate things like the accelerometer and compass. If you are using the Telemetry module, you will need to power your quadcopter with the LiPo battery.
To connect via telemetry, plug in the USB transceiver, Windows will automatically install the required driver (a USB driver is usually included with APM Planner). Then in Mission Planner, select the module in the COM dropdown and select 57600 as the baud rate, and press connect.
Once connected, go to the “Initial Setup” screen and select “Mandatory Hardware”.
First up, let’s select our frame type so our flight board knows what sort of multirotor it is.
Select “Frame Type”. Select the “Class” of airframe, in our case it’s a “Quad”, and then select the “Type”, which is the “X”.
Select “Accel Calibration” from the left side menu. Click “Calibrate Accel” to start the calibration. Mission Planner will tell you the direction to hold the quad in each calibration position. Press any key to proceed to the next orientation once it’s in place.
The positions are shown below:
Note: Make sure the quad is kept still when you press any key for each step.
Once completed, Mission Planner will let you know if the calibration was successful.
Next, put the quadcopter on a level surface and click “Calibrate Level”. This levels the HUD horizon.
Select “Compass”, then select Pixhawk/PX4 as your flight controller. You shouldn’t need to change any of the “General Compass” settings as they are set by default. However, confirm that the “Enable Compasses” and “Obtain Declination Automatically” boxes are checked.
PERFORMING ONBOARD CALIBRATION
Here’s where we do the iconic compass dance!
Click “Start” in the “Onboard Mag Calibration” section.
Hold the quad in the air and rotate it so that each side (front, back, left, right, top and bottom) faces the floor for five seconds.
Notice as the quad is rotated, how the green bars will progress until the calibration completes.
When the calibration completes successfully, a “Please reboot the autopilot” window will appear. Reboot the flight controller by disconnecting and reconnecting the battery.
Note: To reduce the compass variance error and improve your chances of a successful compass calibration, conduct the compass calibration outdoors in a clear area. Metal sheds or structural members can influence the gathered calibration data.
RADIO CONTROL CALIBRATION
Calibrating the transmitter controls and channels allows us to record the minimum and maximum positions of the gimbals and switches.
TRANSMITTER CONFIGURATION: Most remotes use Mode 2 and it’s the most commonly accepted mode for transmitters that will be used for a multirotor.
The default channel mappings are as follows:
- Channel 1: Roll
- Channel 2: Pitch
- Channel 3: Throttle
- Channel 4: Yaw
- Channel 5: Flight Modes
Here is what these channels correspond to on a Mode 2 transmitter.
Before continuing make sure your propellers are off.
Select “Radio Calibration”.
Move your gimbals and switch to ensure they are mapped to the right channels and are in the correct direction (for pitch, the bars will move in the opposite direction). If not, recheck the mapping on your remote.
Centre the transmitter trims.
Start the calibration process by clicking the “Calibrate Radio” button.
Move the gimbals and toggle the switches (that are mapped to a channel) to their limits of travel and watch the results on the green bars. You should see red lines appear on the bars to indicate the maximum and minimum values.
Once you have collected the maximum and minimum values for each position, select “Click When Done”.
RC TRANSMITTER MODE SETUP
Here we will set up the autopilot control and flight modes that will be selected. The switch is set to channel 5 on your transmitter.
Select “Flight Modes”.
Flick the switch and see what drop down menus are highlighted. The highlighted menu will be the mode set to each switch position.
For our first flight we want:
- Position 1: Stabilise
- Position 2: Althold
- Position 3: Loiter
Most ESCs need to be calibrated so that they record the maximum and minimum PWM values that the flight controller will send.
WARNING: Before calibrating your ESC make sure that you have NO Propellers attached, you have disconnected the flight controller from Mission Planner, and the battery is disconnected.
Do an “all at once calibration” as it’s the quickest calibration method and works on most ESCs.
Turn on the transmitter and set the throttle at maximum.
Connect the LiPo Battery. The flight controller’s red, blue and yellow LEDs will light up in a cyclical pattern. This means that its ready to go into ESC calibration mode.
While keeping the throttle at max, disconnect and reconnect the battery. Press and hold the safety button until the LED goes a solid red.
The flight controller is in ESC calibration mode. Wait for the ESCs to produce the musical tone. Usually the number of beeps reflects the battery cell count (i.e., 3 for 3s, 4 for 4s, etc.) and 2 beeps indicate that the maximum throttle value has been recorded.
Pull the throttle stick to its minimum position. The ESCs will then produce a long tone indicating that the minimum value has been captured and that the calibration is complete.
After the tone, the ESCs will be live. To test the motors, increase the throttle slowly and the motors should spin.
Set the throttle to the minimum and disconnect the battery.
Setting up the fail safe is not something you want to forget to do on your new build. Fly away drones are not safe for anyone in the area, and it’s also very expensive because you can potentially damage someone’s property and you’ll lose your new build!
There are two places where you need to set up the radio fail safe; on the transmitter and receiver, and on the Arducopter.
By default, the transmitter and receiver are set up so that the receiver will hold the last known position if they lose contact. This is a bad idea as you won’t know if you have lost control. Therefore, the preferred fail safe method is the “No Signal” method. This is where the receiver stops sending signals to the flight controller, which allows the flight controller to handle the rest of the fail safe procedure. For setting up the fail safe on your transmitter and receiver, refer to the manufacturer’s instructions, as they differ from brand to brand.
Set-Up For No Signal Method
Connect to mission planner and select Setup -> Mandatory Hardware -> Fail safe
Select a fail safe option:
- “Enabled Always RTL” to force the aircraft to always return to the location even if its flying an auto mission.
- “Enabled Continue With Mission in AUTO” to allow the aircraft to continue with missions even if it goes out of RC range. This mode is NOT recommended for most users.
- “Enable Always LAND” to force the aircraft to land immediately if RC contact is lost.
To make sure your fail safe works, follow the testing guide from Ardupilot: ardupilot.org/copter/docs/radio-fail safe.html#testing
THE MAIDEN VOYAGE
Hooray! It’s finally time to get your build into the air! But don’t rush. The first flight is the most important as it gives you the opportunity to see what PID adjustments you need to make, and to confirm if your setup has been done correctly (see section on “Tuning” for more info on PIDs).
Before your first flight, its best to let your quadcopter sit outside for 30 minutes to gather GPS locks. You only have to do this once for new GPS modules.
Find a clear area for the quadcopter to take off from. Place the copter on level ground, turn on the transmitter, and plug in the battery. Do not move the quadcopter until the gyroscope calibration has been completed. The LEDs will be flashing red and blue.
Make sure your flight mode is in “stabilised” mode, and hold the safety switch until it goes a solid red. Arm the aircraft by holding the throttle stick to the bottom right-hand corner for a few seconds, until you hear a beep. Next, slowly raise the throttle until it lifts off the ground.
If you cannot arm your aircraft, it’s most likely failing a pre-arm safety check. Check the flight data HUD and see what error is causing issues. To troubleshoot the pre-arming error, read the pre-arm safety check document: at ardupilot.org/copter/docs/prearm_safety_check.html
If your quadcopter seems like it’s going to flip or isn’t lifting straight up, there’s a possibility that you have set the wrong orientation, the motors are wired in the wrong order, or the propeller direction is incorrect. Use a servo tester or Mission Planners Motor Test to confirm the issue.
If any of the controls are reversed (i.e., the quadcopter moves in the opposite direction of your inputs), reverse the affected channel(s) on the transmitter. It’s good practice to redo the transmitter calibration in Mission Planner after making any changes.
If the copter takes off smoothly, you may see some yaw movement. Usually this should not be more than 30 degrees, and the aircraft will correct itself with more flying time. If you see that there are pronounced wobbles, the propellers or motors may be unbalanced.
For any other issues, refer to the Arducopter trouble shooting guide at ardupilot.org/copter/docs/troubleshooting.html
During your first flight, keep these questions in mind as it will help you when you begin tuning your PIDs:
- How does the quadcopter respond to pitch and roll? Is the response more sluggish or twitchy than what you like?
- When hovering, what level is the throttle set at? Is it centred or is it slightly above or below?
- What’s the rate of acceleration when you increase the throttle? Does it gain altitude faster or slower than what you would like?
- Make sure that you are flying on a calm day. Wind can affect the way the quadcopter feels on the first flight.
- Do not set the trims on the transmitter. Let the flight controller handle the trims.
- Be aware of ground effect. Most new pilots are afraid to leave the ground proximity when learning to fly. Ground effect occurs when you are too close to the ground, and there’s a decrease in drag and an increase in lift efficiency. It may seem like a good thing, but it has a harmful effect on stability and controllability. To avoid ground effect it's recommended to fly above 1m to 1.5m - a suitable height for most sized multirotors.
- The flight board sets its home location at the coordinates it was armed at. Make sure you arm the copter in a location where you are happy for the copter to return home to, in the event of an emergency.
Your flight controller makes calculations on how to move and stabilise your aircraft using a PID controller. Most of the time you do not need to adjust the PID values as the default values tend to be work well, but if you feel that the quadcopter is not flying to your liking, then by all means adjust them.
“PID” stands for “Proportional Integral Derivative” controller; basically it’s a control feedback loop that takes in data and calculates a result. In the case for multirotors, it takes in data from sensors and calculates the error between a measured value and corrects it by adjusting the motor speed.
The 3 PID Values
P – PROPORTIONAL: Looks at the current errors, and fixes the difference between the desired and actual position. You can think of it as the sensitivity and responsiveness setting.
I – INTEGRAL: Deals with past errors, and fixes uncorrected errors in past cycles. You can think of it as the stiffness setting while holding its altitude.
D – DERIVATIVE: Predicts future errors, and accounts for the error that may result from the operation using the current rate of change. This can be seen as the setting to soften and counteract the oscillations caused by an excessive P gain.
Mission Planner simplifies the tuning process into three sliders. To adjust the basic PID settings, connect to the flight board via the telemetry radio and select Config/Tuning -> Basic tuning.
Start with the roll/pitch slider, using the questions you asked yourself during the first flight.
If you observed that the quadcopter was too twitchy in response in the roll and pitch controls, move the slider one mark to the left; or if you found it too sluggish, move it one mark to the right. Save the settings and fly again to see if the change is more to your preference. Repeat the process until you are happy with the response when pitching and rolling.
The “Throttle Hover and Climb” sensitivity sliders relate to the throttle control. Adjust the throttle hover slider until your quadcopter hovers when your throttle stick is in the middle position. If it’s above the middle mark, move the slider one mark to the left; or if its below, move the slider one mark to the right. Repeat the process until the aircraft can hover when the throttle is set in the middle.
Adjust the “Climb” sensitivity slider to the right to make your aircraft gain altitude more aggressively, or to the left to have it gain altitude more gently.
These adjustments should make the quadcopter almost perfect to fly. If you want to adjust your PID values in more depth, Mission Planner gives you the opportunity to do so, under “Extended Tuning”.
If you are a confident pilot, Arducopter has an “Autotune” mode, which allows the aircraft to set its own values for Stabilised P, Rate P and D, as well as the maximum rotational accelerations. For more information about how to set this up, go to ardupilot.org/copter/docs/autotune.html
WHAT TO DO NOW?
The next best thing to do for your quadcopter is to either 3D print an action camera mount or install a camera gimbal so you can capture awesome footage.
Running Arducopter on your flight controller opens up a number of options for you. To run your own autonomous missions, I highly recommend reading the Ardupilot documents for mission planning: ardupilot.org/copter/docs/common-planning-a-mission-with-waypoints-and-events.html
With mission planning, not only can you make your drone go from point-to-point autonomously, you can also set up cinematic shots so you can create awesome footage.
Another cool flight mode you can set up is the “Follow Me” mode, which enables you to use your telemetry radio and a laptop to make your drone follow you as you move.
To do this, you simply need:
- Your quadcopter with telemetry module connected
- A laptop (your ground station)
- A GPS USB dongle
Set one of the flight modes on your switch to “Loiter” and connect to the quadcopter via telemetry. Plug in the GPS USB dongle to your laptop. Use the software provided by the GPS manufacturer, making sure it has a GPS lock. Take off, and once in the air, switch to Loiter mode. Make sure the height is higher than you, to prevent the quadcopter hitting you on approach.
In the “Flight Data” screen, right-click on a nearby spot and select “Fly to Here”. If this works, then you are ready to proceed with the “Follow Me” mode.
In Mission Planner, press 'Control-F' keys to bring up the following window:
Click “Follow Me”. This will bring up another window. Select the COM port that your GPS module is using and set the baud rate it is using.
Once you click “Connect”, Mission Planner will read the GPS data from the GPS module and relay it to the quadcopter as “Fly to Here” commands every two seconds.
Move your ground station around and your quadcopter should follow.
You can take this further by installing APM Planner on a small Linux device or use DroidPlanner for Android devices.
There is still a lot to learn about multirotors and what you can do with Ardupilot. I highly recommend reading lots so you can keep learning and stay up-to-date with new developments.
Of course, try and fly as often as you can to improve your piloting skills and don’t be afraid to break things! Have fun!