Module 2/5 · Weeks 4–6 · 27 h

Installing the FC, GNSS and sensors

UAT 302 UAS Installation and System Integration

About 100 minDraft, awaiting reviewLast updated 2 October 2026

Lesson

By the end of this module you will be able to

  1. Estimate magnetic interference from power wires and set the compass mounting distance
  2. Set the board and compass orientation to match the real installation
  3. Compute the effect of the GNSS antenna offset from the IMU and set the compensation
  4. Check flight controller vibration levels against the ArduPilot criteria
  5. Calibrate the accelerometers, level and radio and check the results and the radio failsafe level

Prerequisites: UAT 302 Module 1 · UAT 205 (IMU and magnetometers)

Why this matters

The flight controller knows the aircraft’s attitude and heading from its sensors. If they are mounted in the wrong orientation, in the wrong place or near interference, the drone flies wrongly even though every part is healthy. The classic symptom is a drone circling in a growing spiral in position hold (toilet-bowling) because the compass is disturbed. UAT 205 covered sensor principles and calibration; this module focuses on installation and configuration. The drone knowledge base’s unit on IMUs and magnetometers stresses bias, noise and vibration.

Compass and power wires

Current in a wire creates a magnetic field. A long straight wire carrying current produces at distance (OpenStax University Physics), with N/A² (CODATA 2022). If the go and return wires lie close together at spacing , their fields almost cancel, leaving about when is much larger than . The compass measures the Earth’s horizontal field, which in Bangkok at the start of 2026 is about 41,168 nT (41.2 µT), with an inclination of 16.3° downwards and a declination of 0.68° west, according to WMM2025 through the British Geological Survey service.

Example 1 How far should the compass be from the battery wires?

The battery wires carry 30 A in hover. The team wants the interference to stay below 5% of the Earth’s horizontal field.

import math

MU0 = 1.25663706127e-6                         # N/A² (CODATA 2022)
H_EARTH = 41_168e-9                            # T, horizontal, Bangkok 2026 (WMM2025)
I = 30.0                                       # A

def b_single(i, r):
    return MU0 * i / (2 * math.pi * r)

def b_pair(i, s, r):                           # go-and-return pair s apart, valid for r >> s
    return MU0 * i * s / (2 * math.pi * r ** 2)

print(f"single wire at 5 cm: {b_single(I, 0.05) * 1e6:.1f} uT ({b_single(I, 0.05) / H_EARTH:.1f} x Earth's horizontal field)")
for s in (0.005, 0.02):
    for r in (0.10, 0.20):
        b = b_pair(I, s, r)
        err = math.degrees(math.atan(b / H_EARTH))
        print(f"pair {s * 1000:.0f} mm apart at {r * 100:.0f} cm: {b * 1e6:5.2f} uT = {b / H_EARTH:5.1%} of H, heading error up to {err:.1f} deg")
    r_min = math.sqrt(MU0 * I * s / (2 * math.pi * 0.05 * H_EARTH))
    print(f"  distance for 5% of H with pair {s * 1000:.0f} mm apart: {r_min * 100:.0f} cm")
single wire at 5 cm: 120.0 uT (2.9 x Earth's horizontal field)
pair 5 mm apart at 10 cm:  3.00 uT =  7.3% of H, heading error up to 4.2 deg
pair 5 mm apart at 20 cm:  0.75 uT =  1.8% of H, heading error up to 1.0 deg
  distance for 5% of H with pair 5 mm apart: 12 cm
pair 20 mm apart at 10 cm: 12.00 uT = 29.1% of H, heading error up to 16.3 deg
pair 20 mm apart at 20 cm:  3.00 uT =  7.3% of H, heading error up to 4.2 deg
  distance for 5% of H with pair 20 mm apart: 24 cm

A single wire at 5 cm produces a field almost three times the Earth’s, so the compass is useless. Laying the go and return wires together or twisting them reduces the field greatly, but if the wires are 2 cm apart the compass must be twice as far away. This is why most drones mount the GNSS and compass on a tall mast. ArduPilot’s compassmot test measures interference against real current: below 30% is acceptable, 31–60% is a grey zone, and above 60% means moving the autopilot or using an external compass.

Interference as a percentage of the Earth's horizontal field against distance from 5 to 30 centimetres: a pink line for a pair 20 millimetres apart falls more slowly than a blue line for a pair 5 millimetres apart; a gold dashed line at 5 percent is crossed by the blue line at about 12 centimetres and the pink line at about 24 centimetres
Figure 1 Interference from power wires against distance

Mounting orientation

If the flight controller must be mounted rotated from the nose direction, the software must be told. ArduPilot uses AHRS_ORIENTATION, which rotates the IMU and internal compass readings by the mounting angle; the board must then be re-levelled and rebooted. An external compass is set separately with COMPASS_ORIENT. PX4 uses SENS_BOARD_ROT. An effective check is to tilt the drone by hand and confirm that the attitude on the GCS tilts the same way on every axis, then rotate the drone and confirm that the heading changes in the right direction.

GNSS antenna position

GNSS reports the position of the antenna, not of the IMU. If the antenna is offset from the IMU, the measured position moves when the drone tilts or turns even though the body has not moved. ArduPilot takes this offset in GPS1_POS_X/Y/Z in metres, with X forward, Y right and Z down, measured from the IMU (or from the CG if the IMU position is set). PX4 v1.17 (current stable) uses EKF2_GPS_POS_X/Y/Z, measured from the vehicle’s centre of gravity; the development (main) branch has started replacing them with SENS_GNSS0_OFFX/Y/Z. Always check parameter names against the documentation for the firmware version actually used.

Example 2 The effect of the antenna offset

The antenna is 0.12 m ahead of the IMU and 0.10 m above it (Z points down, so −0.10).

import math

X, Z = 0.12, -0.10                             # m, GPS1_POS_X and GPS1_POS_Z
for roll in (10, 25):
    shift = abs(Z) * math.sin(math.radians(roll))
    print(f"roll {roll} deg: antenna moves sideways {shift * 100:.1f} cm while the IMU stays put")
yaw_rate = math.radians(60)                    # rad/s
print(f"yaw at 60 deg/s: antenna velocity {yaw_rate * X:.3f} m/s from rotation alone")
print(f"set GPS1_POS_X = {X}, GPS1_POS_Y = 0, GPS1_POS_Z = {Z}")
roll 10 deg: antenna moves sideways 1.7 cm while the IMU stays put
roll 25 deg: antenna moves sideways 4.2 cm while the IMU stays put
yaw at 60 deg/s: antenna velocity 0.126 m/s from rotation alone
set GPS1_POS_X = 0.12, GPS1_POS_Y = 0, GPS1_POS_Z = -0.1

Position moves by several centimetres when the drone tilts, and measured velocity is off by almost 0.13 m/s during a fast yaw. With ordinary GNSS errors of metres this may go unnoticed, but with centimetre-level RTK it is clear, so the offset must always be measured and entered.

Checking flight controller vibration

The ArduPilot vibration measurement page states that vibration below 30 m/s² is normally acceptable, 30–60 m/s² may cause problems, and above 60 m/s² nearly always causes position and altitude-hold problems. The clipping counter (accelerometer saturation at 16 g) should be zero or very small. The recommended mounting uses foam or gel at the corners to cut high-frequency vibration while still letting the board follow the frame’s slow motion.

Side view of a drone with the IMU in the middle of the frame and the GNSS antenna on a mast further forward and higher; a blue X arrow points forward and a pink Z arrow points down, showing 0.12 metres forward and 0.10 metres vertically
Figure 2 GNSS antenna offset from the IMU in the body axes

Calibrating the accelerometers, level and radio

Calibration means measuring the errors of a sensor or an input against a known reference and storing corrections for them. Apart from the compass, three calibrations must be done on every newly assembled drone:

  • Accelerometers. ArduPilot treats this calibration as mandatory; it corrects the bias of each axis and small cross-axis errors, and it cannot be done while armed. If the board is not mounted arrow forward, set AHRS_ORIENTATION first. Mission Planner asks for six positions: level, right side, left side, nose down, nose up and on its back. Keeping the drone still at each keypress matters more than exact angles (within about 20°, except the first level position), so rest it on the floor or in a jig instead of holding it by hand.
  • Level. The first position becomes the attitude the controller treats as level. After the board is installed, place the drone in its level flying attitude and use Calibrate Level, which corrects up to 10° of pitch and roll (not yaw). The difference between board and frame is held in AHRS_TRIM_X (roll) and AHRS_TRIM_Y (pitch) in radians, range ±0.1745 rad (about ±10°). If the level position is wrong, the controller holds a tilted attitude as if it were level, and the drone drifts steadily one way in Stabilize mode even without wind.
  • Radio (RC). This records each channel’s minimum, maximum and trim (RCn_MIN, RCn_MAX, RCn_TRIM, in µs) so the flight controller reads the sticks correctly. Remove the propellers and disconnect the battery, because the drone could be armed by accident; power the board by USB and centre the transmitter trims. Copter’s default channels are 1 roll, 2 pitch, 3 throttle, 4 yaw and 5 flight mode. The bars for roll, throttle and yaw move with the sticks, but the pitch bar moves opposite to the stick; reverse a wrong channel in the transmitter first (or with RCn_REVERSED). Move every stick and switch to its limits, then centre the sticks with the throttle down and finish. Typical values are about 1100 µs minimum and 1900 µs maximum.

After radio calibration, check the radio failsafe settings. FS_THR_VALUE (975 µs by default in both Copter 4.6.3 and the current stable 4.7.1) must be at least 10 µs below channel 3 with the throttle down and the transmitter on, at least 10 µs above channel 3 with the transmitter off (for receivers that signal loss by pulling the throttle low), and above 910 µs. ESC calibration comes after radio calibration and is covered with the motors in Module 3.

Example 3 Checking the calibration results

After calibrating, the team reads the values from the full parameter list, then switches the transmitter off and notes channel 3 (the receiver uses the low-throttle method). The team requires every stick to span at least 700 µs and centred sticks to read within 20 µs of the middle of their range (assumed criteria).

import math

cal = {   # channel: (RCn_MIN, RCn_TRIM, RCn_MAX) after radio calibration (assumed values)
    1: (1102, 1501, 1898), 2: (1181, 1499, 1802),
    3: (1101, 1102, 1899), 4: (1099, 1560, 1902),
}
FS_THR_VALUE = 975              # default in Copter 4.6.3 and 4.7.1
THR_TX_OFF = 968                # channel 3 seen with the transmitter off (low-throttle receiver)
TRIM_X, TRIM_Y = 0.012, -0.020  # AHRS_TRIM_X/Y in radians after level calibration

issues = []
for ch, (lo, trim, hi) in cal.items():
    span, mid = hi - lo, (lo + hi) / 2
    if span < 700:
        issues.append(f"RC{ch}: span only {span} us, move the stick to its full travel")
    if ch == 3 and trim - lo > 10:
        issues.append(f"RC3_TRIM {trim} is not at the bottom ({lo}): throttle was not lowered at the last step")
    if ch != 3 and abs(trim - mid) > 20:
        issues.append(f"RC{ch}_TRIM {trim} is {trim - mid:+.0f} us from the centre: centre the transmitter trim and recalibrate")
    print(f"RC{ch}: min {lo} trim {trim} max {hi} span {span}")
thr_min = cal[3][0]
if not THR_TX_OFF <= FS_THR_VALUE - 10:
    issues.append(f"transmitter off gives {THR_TX_OFF}, only {FS_THR_VALUE - THR_TX_OFF} us below FS_THR_VALUE (need 10)")
if not FS_THR_VALUE <= thr_min - 10:
    issues.append(f"FS_THR_VALUE {FS_THR_VALUE} is too close to RC3_MIN {thr_min}")
for name, rad in (("AHRS_TRIM_X", TRIM_X), ("AHRS_TRIM_Y", TRIM_Y)):
    print(f"{name} = {rad} rad = {math.degrees(rad):.2f} deg")
print("issues:", *issues, sep="\n  ")
RC1: min 1102 trim 1501 max 1898 span 796
RC2: min 1181 trim 1499 max 1802 span 621
RC3: min 1101 trim 1102 max 1899 span 798
RC4: min 1099 trim 1560 max 1902 span 803
AHRS_TRIM_X = 0.012 rad = 0.69 deg
AHRS_TRIM_Y = -0.02 rad = -1.15 deg
issues:
  RC2: span only 621 us, move the stick to its full travel
  RC4_TRIM 1560 is +60 us from the centre: centre the transmitter trim and recalibrate
  transmitter off gives 968, only 7 us below FS_THR_VALUE (need 10)

The level trims are about 1° and within the 10° that Calibrate Level can correct, so the board is mounted well. But the radio calibration must be repeated: the pitch stick was not pushed to its limits (or the transmitter’s end points are reduced), and the yaw trim tab was not centred, which would make the drone yaw slowly by itself. Most important, with the transmitter off channel 3 is only 7 µs below the failsafe level, so the radio failsafe might not trigger. The fix is to set the receiver’s failsafe throttle lower, or better, to use the receiver’s no-signal mode, which the ArduPilot documentation prefers, then repeat the test.

Module lab

Lab: install and check the sensors

  1. Measure the distance from the compass to the nearest power wire and estimate interference with Example 1
  2. Mount the flight controller on a damping base, set AHRS_ORIENTATION and COMPASS_ORIENT, and check by tilting and rotating
  3. Measure the GNSS antenna offset and set GPS1_POS_X/Y/Z as in Example 2
  4. Calibrate the accelerometers, level and radio, check the results with Example 3 and set the receiver failsafe correctly
  5. Calibrate the compass, then run compassmot under the instructor’s supervision and record the percentage
  6. Hover, then read vibration and clipping from the log and compare them with the ArduPilot criteria

Common mistakes

Watch out

  • Routing power wires under the compass or separating the go and return wires
  • Mounting the board rotated without setting its orientation
  • Not entering the GNSS antenna offset when using RTK
  • Using parameter names from old articles with new firmware
  • Mounting the board rigidly on a frame that vibrates strongly
  • Calibrating the accelerometers before setting AHRS_ORIENTATION, or while holding the drone by hand

Summary

  • The field from power wires falls with distance and falls sharply when go and return wires are kept together; it should be a small fraction of the Earth’s horizontal field (about 41 µT in Bangkok)
  • Set the mounting orientation with AHRS_ORIENTATION and COMPASS_ORIENT and check by tilting for real
  • The GNSS antenna offset from the IMU goes in GPS1_POS_X/Y/Z and matters greatly with RTK
  • Vibration below 30 m/s² and clipping near zero are the ArduPilot criteria
  • Calibrate the accelerometers (six still positions), the level and the radio, then check FS_THR_VALUE against channel 3 with the transmitter on and off

Check your understanding

  1. What field does a single wire carrying 20 A produce at 10 cm?
  2. An interference field of 4 µT perpendicular to a 41 µT horizontal field can shift the heading by about how many degrees?
  3. What should you do if compassmot gives 45%?
  4. The antenna is 0.1 m above the IMU. Is GPS1_POS_Z positive or negative?
  5. Which ArduPilot range does a vibration level of 45 m/s² fall in?
Answers
  1. µT
  2. It is in the grey zone: move the compass away from the interference or re-route the wires, then test again
  3. Negative, because Z points down
  4. 30–60 m/s², which may cause problems; improve the damping mount or fix the source

Key formulas

Field of a long straight wire
Field of a go-and-return pair (r ≫ s)
Heading error

Key references

  1. Ling, S. J., Sanny, J., & Moebs, W. (2016). University physics volume 2. OpenStax. link
  2. National Institute of Standards and Technology. CODATA value: vacuum magnetic permeability (CODATA 2022). link
  3. British Geological Survey. Geomagnetism web service: World Magnetic Model WMM2025 and IGRF-14. link
  4. ArduPilot Dev Team. Advanced compass setup (CompassMot). ArduPilot Copter documentation. link
  5. ArduPilot Dev Team. Sensor position offset compensation. ArduPilot Copter documentation. link
  6. ArduPilot Dev Team. Parameter list (Copter stable V4.6.3). ArduPilot Copter documentation. link
  7. PX4 Autopilot. Parameter reference. PX4 user guide (main). link
  8. ArduPilot Dev Team. Measuring vibration. ArduPilot Copter documentation. link
  9. ArduPilot Dev Team. Accelerometer calibration. ArduPilot Copter documentation. link
  10. ArduPilot Dev Team. Radio control calibration (transmitter modes). ArduPilot Copter documentation. link
  11. ArduPilot Dev Team. Radio failsafe. ArduPilot Copter documentation. link
  12. ArduPilot Dev Team. Parameter list (Copter stable V4.7.1). ArduPilot Copter documentation. link

Further reading

Study the assigned knowledge units in advance, review media and take the module quiz

In class / field

Lab or field practice from worksheets with a safety checklist

Learning evidence: Checked worksheets and quiz results

Module quiz

This is a formative self-check, not a graded exam

Knowledge domain: Control, autopilot and navigation · Mission planning, flight and simulation · Sensors and embedded systems