INAV Advanced Accelerometer Calibration: why and how

One of the most often forgotten tasks required to bring the most of INAV, is good accelerometer calibration. Why? While flight controller software like Cleanfligth and Betaflight use accelerometer only to compute UAV’s body inclination (Angle and Horizon modes as well as artificial horizon), INAV uses it also for position estimation.

Cleanfligt has to only know where “down” is. For this, simple accelerometer calibration is fully enough: place UAV on a level surface and hit “Calibrate accelerometer” button. Few seconds and done.

INAV not only has to know where bottom is. It also has to know where all other directions are, and how fast UAV is accelerating in those directions to be able to estimate its position. For this, advanced, or 6 point accelerometer calibration is required.

How to perform Advanced Accelerometer Calibration [AAC]

During AAC, each side of flight controller has to be positioned “down” during calibration. Order is not important with one exception: during first step, top of flight controller has to positioned up. This is impotrant: we are calibrating accelerometer, not whole UAV. Even is FC is mounted upside-down, during first step, FC has to to positioned upwards.

  1. Prepare stable surface that will allow to keep FC stable in all required positions. Angles does not have to be super precise, even few degrees should be enough, but flight controller has to be motionless during calibration
  2. Plug-in USB and connect to INAV Configurator
  3. Position flight controller facing up and hit “Calibrate acccelerometer” button. Wait for success message
  4. Rotate FC 180 degrees so it is bottoms-up and hit “Calibrate acccelerometer” button. Wait for success message
  5. Rotate FC so its rear edge is facing down and hit “Calibrate acccelerometer” button. Wait for success message
  6. Rotate FC so its right edge is facing down and hit “Calibrate acccelerometer” button. Wait for success message
  7. Rotate FC so its front edge is facing down and hit “Calibrate acccelerometer” button. Wait for success message
  8. Rotate FC so its left edge is facing down and hit “Calibrate acccelerometer” button. Wait for success message
  9. Disconnet and power down
  10. Advanced accelerometer calibration is done. If is succeeded, acczero_x, acczero_y and acczero_z should different than 0, while accgain_x, accgain_y and accgain_z should be different than 4096

Advanced accelerometer calibration

Worth remembering: calibration values can be restored via CLI when flight controller firmware is updated. It is hardware, not software dependent. Calibration should be executed when new hardware is used.

Read More

What’s new in INAV 1.4

Although INAV 1.4 was not released yet, it’s going to happen very soon. When? Probably in the beginning of a next week. Release Candidate is already available and until now, there are no major bugs discovered.

So, what’s new in INAV 1.4? Quite a few…

  • IMPORTANT: by default, motor output is disabled after flashing. This is to prevent servos from being damaged with too fast PWM rate. User has to enable motor output using Configurator (version 1.4 or newer) or with CLI command feature PWM_OUTPUT_ENABLE
  • Asynchronous gyroscope processing. I’ve described some time ago why this is good idea to have something like this. With 1.4, asynchronous gyroscope is available, but not enabled by default yet. I will try to write a longer article how to set it up later (I hope at least I will find time for it). Until then, this entry in INAV docs is all that has been written on the topic
  • Airplane launch assistant. Launching an airplane with INAV is almost as easy as it can be! You can read documentation on this feature on INAV Wiki
  • Improved throttle PID attenuation (or rather PID scaling) for airplanes. Read documentation on the topic
  • Emergency landing for airplanes
  • Experimental Pitot tube support (logging only) compatible with Pixhawk PX4 Airspeed Sensor
  • Improved handling for GPS+MAG and GPS+BARO configurations. With INAV 1.4 it should be not required to disable MAG and BARO when GPS is used
  • Improved failsafe
  • New targets: Airbot F4 / Flip32 F4, Omnibus F4 and YuPiF4
  • Multiple bugs fixed

Additionally, new version of INAV Configurator has been already released. All users are advised to update! With Configurator 1.4.1 and firmware 1.4 following new features will be available:

  • Possibility to enable motor output
  • Gyroscope hardware filtering (gyro_lpf) and syncing PID loop with gyroscope (gyro_sync) setup
  • Advanced PID tuning now allows to set:
    • Gyroscope software LPF cutoff frequency
    • Accelerometer software LPF cutoff frequency
    • D-term cutoff frequency
    • Yaw P-term cutoff frequency
    • MAG_HOLD yaw rate limit
    • Axis acceleration limits
    • Yaw P limit and yaw jump prevention limit
    • I-term ignore rates

Read More

INAV for Airbot F4 / Flip32 F4 flight controller

INAV 1.3 has been released few hours ago, now I would like to do unofficial release of Flip32 F4 / Airbot F4 target of INAV 1.3. Target was flight tested last weekend.

Airbot F4 / Flip32 F4 reporting for navigational duty, sir!

What is inside:

  • Full 6 motors support
  • 2 motors / 4 servos support, so it can be used on airplanes
  • RSSI ADC on dedicated pin
  • Current meter ADC on dedicated pin
  • S.Bus and PPM working
  • I2C bus works, it is possible to attach external barometer and magnetometer. Tested hardware:
    • Barometeres: BMP085, BMP280 and MS5611
    • Magnetometers: HMC5883l
  • I2C is not initialized when UART3 is configured
  • GPS over UART. Supported protocols: UBLOX, NMEA and NAZA

The only think that is not working, is LED strip support. Looks like there is generic STM32F4 LED strip issue in INAV and we will be able to fix it in reasonable future.

HEX file of INAV for Airbot F4 / Flip32 F4 can be downloaded here.

Read More

INAV 1.3 has been released

I'm happy to announce new version of INAV ready do download from official repository.

What is new in INAV 1.3? Quite a few thinks. No "revolutions", more like steady progress. From most important things:

  • INAV now supports PWM, OneShot124, OneShot42 and Multishot ESC protocols and asynchronous motors and servos updates
  • Something for airplanes with a lot of servos: INAV can now supports PCA9685 PWM drivers and drive up to 16 servos plus motors! Although mixer can not yet support as many servos, this will change in future releases. I will try to write few words on this topic in a near future
  • FlySky I-Bus telemetry
  • Airplane auto arming with throttle option
  • In case of airplanes (again airplane improvement!), I-term of PID controller is constrained to about 30% of max servo throw. This prevents from servo saturation that can happen in some cases before take off
  • I2C improvements for STM32F1 and STM32F4 targets. This solves the problem of undetected BMP085, BMP180 and HMC5883L on Naze32, Flip32, OpenPilot Revolution and other boards
  • Code cleanups, including removal of unused or very rarely used flight modes like SERVO1-3, GOVERNOR, LEDMAX and CAMTRIG

All users are advised to use latest INAV Configurator and reconfigure flight modes is configuration is to be restored from files! Owners or STM32F1 boards should consult hardware support map if features they are using are still supported.

Read More

INAV is learning to do mini-quad racing too

Let's be honest: in terms of mini-quad racing there is Betaflight (probably also Raceflight but I've never flew it yet, so will not comment on its flight performance), long long gap, and then it's everything else including Cleanflight, LibrePilot, INAV etc.

Originally INAV concentrated on "big" UAVs with GPS capabilities. After all NAV in name stands for Navigation. Mini-quads and acro performance were left alone, and once again, let's be honest: comparing to Betaflight, it sucked. It was possible, I've even written a short tutorial how to set it up, but it sucked.

Luckily, it is changing. INAV 1.2 had brought some improvements like Iterm limiting and acceleration limiting, and Acro flying in INAV became very nice. Small revolution, or maybe bigger catch up, is planned for INAV 1.3: asynchronous gyroscope, accelerometer and attitude processing. I've been working on it for last few months and results are very promising: INAV can drive a mini-quad with Betaflight comparable performance. Like this (please remember I'm not the best pilot!)


  • PID task frequency: 1kHz
  • Gyro task frequency: 2kHz
  • Accelerometer task frequency: 120Hz
  • Attitude task frequency: 100Hz
  • Frame: Reptile X4R 220
  • Motors: EMAX RS2205 2300KV
  • Propellers: DALprop TJ5045
  • Flight controller: SPracingF3
  • Firmware: INAV 1.2 with custom changes

Read More

Marabou Stork: FPV airplane maiden flight

For the last few week I’ve been little busy building my next fixed wing UAV: “Marabou Stork” Depron/Carbon/3D Printed airplane with pusher prop build for FPV. It’s improved version of “Red Cruiser” model from last year.

marabou stork depron airplane

marabou stork depron airplane 2

It’s equipped with KFm-2 wing, Turnigy D2826-6 2200KV motor, APC-E 7×4″ propeller, 2700mAh Lipo battery, FPV setup with MinimOSD and RunCam PZ0420H camera. And Flip32 running INAV for stabilization and navigation (no GPS yet).

As you can see on a video above, it flies. Even pretty well. It needs some tuning, but have big potential. Unfortunately elevator malfunction grounded it after few minutes in the air.

Read More

How to measure gyro noise frequency with Blackbox

Cleanflight / Betaflight / INAV lowpass filter tuning can be a hard thing to do if you have not idea what is noise frequency you want to cancel. Sure, you can blind test or read tutorials. But what if I tell you, you can measure it quite precisely using only Blackbox logs? Or measure rotation speed of motors? That would be nice, isn’t it? The only requirement are few seconds of Blackbox log with visible gyro (it can be also motor output or Pterm or even ACC reading) noise.

blackbox measure frequency 1

Continue reading “How to measure gyro noise frequency with Blackbox” »

Read More

INAV 1.2 RC1 has been released

After 3 month from previous release, INAV is preparing for a new version. INAV 1.2 will be quite massive, with a lot of new features and improvements. Full change list is available here. I will only describe the most important and “visible” changes.

  • Rates are no longer stored in arbitrary units like 0.4. Who knows what 0.4 means? How fast UAV should rotate when this rate is set? Is 0.8 twice as fast as 0.4? (The answer to that question is “No”) To solve this problem, INAV uses degrees per second [dps] to define maximum rotation speeds. INAV Configurator provides nice and simple user interface for that. The ones who uses CLI has to remember, that INAV stores rates in dps divided by 10. So, set roll_rate=72 means that roll rate equals 720dps. GitHub INAV Wiki has a page that describes how to convert INAV 1.1 rates to new system. Also, RC Rate setting, as obsolete, has been removed.
  • FP-PID has been rescaled to match LuxFloat and MWRewrite PID controllers. That means, if you have tuned drone in either Cleanflight or Betaflight, you can just use the same PID settings in INAV now, without a need to retune. That also means, that tunes from INAV 1.1 will not work in 1.2. This page or this Google Docs Spreadsheet can be used to convert INAV 1.1 PID to INAV 1.2
  • Just like latest Betaflight 3.0, INAV 1.2 has a feature that allows to limit angular acceleration. This might be very useful when tuning big and heavy frames with a lot of inertia. They are just not capable of angular acceleration that operator might require from them even with stick movements. If frame oscillates/shakes during stops, that means that it is unable to satisfy required acceleration/deceleration, Iterm winds up and as a result, frame overshoots target only to try to correct that fractions of a second later. To get rid of that effect rate_accel_limit_roll_pitch and rate_accel_limit_yaw CLI variables can be used. They represent maximum angular acceleration/deceleration in degress-per-second^2 [dps2] UAV operator can request. By default it is disabled for roll and pitch and set to 10000dps2 for yaw.
  • Improved MAGHOLD controller that results in much smoother yaw movements in RTH and WAYPOINT flight modes. New mag_hold_rate_limit setting limits yaw rotation rate MAGHOLD controller can request. Default of 90dps is enough for agile UAVs. For slow, cinematic, turns, value of 25dps generates good results. I already described this improvement here
  • Flaperon flight mode. Available only on fixed wing (not on flying wing) platforms. When enabled, both ailerons will be deployed down to act as flaps. Flaperon behavior is driven by 2 CLI variables:
    • flaperon_throw_offset determines how far ailerons will be deployed
    • flaperon_throw_inverted allows to invert aileron throw in Flaperon mode. Can be used to create spoilerons instead of flaperons
  • Greatly improved GPS performance
  • Maximum climb/descend rate in WAYPOINT mission flight mode is now limited by nav_max_climb_rate setting (in centimeters per second)
  • More precise expo curve resulting in smoother UAV behavior near sticks center positions
  • Greatly improved landing detection mechanism that can effectiveness detect landing and disarm motors in RTH mode
  • Just like Betaflight, INAV saves configuration (PIDs, rates, etc.) with Blackbox logs. Both Betaflight and INAV blackbox viewers can be used to get config from logs. Great for tuning, since log contains both flight data and configuration used to obtain this data
  • Turn assistant flight mode – when enabled, yaw movement will be done in parallel to ground plane, not UAV plane
  • Full stick range is now used in ANGLE and HORIZON flight modes
  • More data reported via LTM protocol
  • Initial MAVLink support. It is far from completed, but MAVLink enabled ground stations should be able to receive telemetry from INAV.
  • Support for nRF24L01 transceivers. Fly Naze32 with Syma radio? Now it will be doable
  • Multiple bugfixes and other improvements

Read More

INAV 1.1 for Naze32 with working telemetry

As long as Naze32 / Flip32 are decent flight controllers for those who does not demand too much, they share very big flaw: low flash memory size. While even a year ago 128kB of flash was enough, times changed, and limited flash makes a problem for advanced flight controller software like INAV. Starting from INAV 1.1, STM32F1 flight controllers started to pay a penalty of disabled features. That time it was "only" telemetry providers other than LTM. Next time it might / will be more.

During last few weeks I've received few request to compile INAV 1.1 with enabled FrSky and/or SmartPort telemetry on Naze32 target. While I have nothing against doing that on request, I've decided it would be better to just prepare special version of INAV 1.1 for Naze32 users with all telemetry providers enabled. Link to ZIP file is at the bottom of this post.

  • This version has LTM, FrSky, SmartPort and HOTT telemetry enabled
  • To fit telemetry in limited flash memory, following features has been disabled:
    • OLED display support
    • DJI NAZA GPS module support

INAV 1.1 for Naze32 with telemetry enabed

Read More

INAV: unsynced gyro updates

Until recently, INAV concentrated on GPS and navigation support. Comparing to Betaflight, or even Cleanflight, its acro capabilities were rather limited. Flyable, but limited. Now we are trying to catch up. While upcoming INAV 1.2 will rather not change much in this topic, there are few experimental code versions that might greatly improve INAV acro capabilities. One of them is separation of gyroscope readouts from PID loop.

INAV and FP-PID with extensive floating point logic are rather slow. Looptime 2000us (500Hz update rate) is a limit for F1 targets and 1000us (1kHz mode) is barely reachable by most F3 targets. Version from mentioned above pull request separates gyroscope readouts and filtering from main PID loop. Thanks to that, gyro is updated much faster (up to 2.6kHz in case of F3 with I2C gyro). Faster gyro update means better signal signal quality, lower delay, better filtering and less aliasing. One the other hand, motors does not have to be updated that often. Not only they are unable to change rotation speed as fast as we can drive them, they are unable to notably change thrust as fast as we would like them to.
Let's do some math: what will the distance that tip of a 5" propeller running 12,000PRM will travel during 500us (2kHz update frequency)? About 40mm. More less 10% of a circuit. Not much distance to change generated thrust…

This might sound strange, but looks like it is working. Below is a short video of my 3S 250 quad running gyro loop at 2kHz and PID loop at 666Hz. Honestly? This quad never flew better! Please ignore my lame flying skills 🙂

If anybody would like to try asynchronous gyroscope on INAV, please drop me a message, I will compile and share this special version.

Read More