{"id":346,"date":"2021-07-08T10:32:00","date_gmt":"2021-07-08T09:32:00","guid":{"rendered":"https:\/\/avionicsduino.com\/?page_id=346"},"modified":"2025-07-06T15:58:10","modified_gmt":"2025-07-06T14:58:10","slug":"the-ahrs","status":"publish","type":"page","link":"https:\/\/avionicsduino.com\/index.php\/en\/the-ahrs\/","title":{"rendered":"AHRS : the heart of an EFIS"},"content":{"rendered":"\n<p style=\"font-size:10px\"> <em> (AHRS: Last updated by Benjamin on March 23, 2024)<\/em> <\/p>\n\n\n\n<p>The AHRS, for Attitude and Heading Reference System, is the most complex part of the EFIS. Not so much because of the components (particularly the IMU, see below), because they are ubiquitous, easy to find on breakout boards, and inexpensive. This complexity is actually due to the sensor fusion software, which fuses the raw data of all the sensors, computes the aircraft orientation in three-dimensional space, and outputs angles that characterize the aircraft position: heading, pitch, and roll. This software uses complex mathematical concepts rarely mastered by an amateur, even a seasoned one.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">The components of the AHRS<\/h3>\n\n\n\n<p>Therefore, the hardware is very accessible. This is why there are many achievements on the web that may seem successful for some. Without taking much risk of being wrong, we can say that they have never been successfully tested in flight.<\/p>\n\n\n\n<p>The heart of an AHRS consists of an inertial unit (gyrometer and accelerometer, each on three axes) generally coupled to a triaxial magnetometer.<\/p>\n\n\n\n<p>Current technologies are not based on mechanical gyroscopes but on miniaturized semiconductor components, without rotating parts, the so-called MEMS, for Micro Electro Mechanical Systems. It is easy to find on the market, for a few euros, inertial units (or IMU, for Inertial Measurement Unit) based on MEMS, combining a triaxial accelerometer, a triaxial gyrometer, a triaxial magnetometer, and sometimes a 32-bit microcontroller ensuring the fusion of the data from these nine sensors to provide the user with clear absolute orientation in the form of the three angles well known to all pilots: heading, pitch, and roll.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">The problem of the flight mechanics of fixed-wing airplanes<\/h3>\n\n\n\n<p>Among the most well-known IMUs of this type are the BNO055 from Bosch and the MPU9250 from InvenSense. There are many others that are newer and more efficient. These 9 degrees of freedom IMUs are used extensively as orientation sensors in flight controllers for multirotor drones, in smartphones, in the automotive industry, in robotics \u2026 etc. But when looking to use them in a fixed-wing aircraft, they all pose the same crippling problem. This problem is intimately linked to the flight mechanics of fixed-wing aircraft, which has nothing to do with multi-rotor drones or ground vehicles and applications for which these IMUs might have been designed.<\/p>\n\n\n\n<p>Let&rsquo;s take, for example, a BNO055, the best-known and most widespread in the Arduino community, and use it as AHRS for an artificial horizon. Comfortably seated in front of a desktop, everything is going as expected. In static mode, the attitude indicated on the screen is strictly identical to that imposed manually on this \u00ab\u00a0AHRS.\u00a0\u00bb Now, let&rsquo;s take this same system in a fixed-wing aircraft.<\/p>\n\n\n\n<p>During straight-and-level, coordinated flight, the horizon bar remains strictly horizontal. Small movements of the flight controls, with rapid return to straight and level flight, are perfectly reproduced on the screen. Let&rsquo;s quickly get the plane into a level turn stabilized at a 30 \u00b0 bank. As the turn begins, the horizon shows it for a brief moment. But after a second or two, it starts to level out, and progressively, after two or three additional seconds, the display shows straight and level flight again while the aircraft is still in a 30\u00b0 turn! Such an AHRS is useless!<\/p>\n\n\n\n<p>This phenomenon is explained by the fact that the BNO055, like all other IMUs with 6 or 9 degrees of freedom, cannot distinguish the acceleration due to the earth&rsquo;s gravity from the centrifugal one due to the turn.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"885\" height=\"496\" src=\"https:\/\/avionicsduino.com\/wp-content\/uploads\/2021\/07\/3_axesXYZ.jpg\" alt=\"AHRS\" class=\"wp-image-629\" srcset=\"https:\/\/avionicsduino.com\/wp-content\/uploads\/2021\/07\/3_axesXYZ.jpg 885w, https:\/\/avionicsduino.com\/wp-content\/uploads\/2021\/07\/3_axesXYZ-300x168.jpg 300w, https:\/\/avionicsduino.com\/wp-content\/uploads\/2021\/07\/3_axesXYZ-768x430.jpg 768w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><figcaption class=\"wp-element-caption\">Figure 1: X, Y, and Z axis of a plane<\/figcaption><\/figure>\n\n\n\n<p>If there is an acceleration only on the Z axis and none on the X and Y axes (see Figure 1), and this is the case during a coordinated turn, the BNO055 and other IMUs in this category wrongly deduce that the airplane is horizontal in the earth reference frame. The acceleration resulting from the sum of gravity and centrifugal acceleration vectors is misinterpreted as being related to gravity alone. In IMC, our inner ear is deceived in the same way.<\/p>\n\n\n\n<p>Therefore, these IMUs lack the means to isolate the inertial vector from the non-inertial vector for calculating the aircraft&rsquo;s attitude relative to the Galilean (or inertial) earth frame of reference.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How do we solve the problem?<\/h3>\n\n\n\n<p>Those interested in the flight mechanics of fixed-wing aircraft will remember that the bank of a turning plane can be determined by knowing the radius of the turn and the speed on the path. In flight, the radius of the turn is not easy to measure, but it can be deduced from the aircraft&rsquo;s speed and yaw rate (or angular speed).<\/p>\n\n\n\n<p>These additional data are, therefore, essential for calculating the roll angle. Commercial EFIS have two solutions to recover this data: either they use, in addition to the gyrometers (which are always affected by a more or less rapid drift), an integrated magnetometer to help calculate the angular speed and are connected to the circuits of static AND dynamic pressures to calculate the speed of the airplane, or they use the data of a GPS\/GNSS which provides the ground speed, the true course (track), and much other helpful information. Most often, both solutions are used to be able to rely on at least one data source in the event of failure of the other.<\/p>\n\n\n\n<p>The math necessary for this data fusion calls for<a href=\"https:\/\/www.pittnerovi.com\/jiri\/hobby\/electronics\/avionics\/ahrs_notes.pdf\" target=\"_blank\" rel=\"noreferrer noopener\" title=\"maths fusion\"> particularly complex notions<\/a> beyond the capabilities of a non-specialist. Lacking the required skills in this area, we had initially to find a professional solution for our EFIS. The Naveol Company initially provided us with an AHRS prototype integrating a Ublox GNSS, an STMicroelectronics 6 DOF inertial unit (triaxial accelerometer and triaxial gyrometer), and a microcontroller ensuring data fusion. This module communicated with the Teensy board  (see <a href=\"https:\/\/avionicsduino.com\/index.php\/fr\/les-cartes-microcontroleur-utilisees\/\" target=\"_blank\" rel=\"noreferrer noopener\">here<\/a>) used in the EFIS over a UART serial line at a 115200 baud rate. In flight, it provided perfectly accurate and precise pitch and roll angles, angular speeds on the three axes, accelerations on the three axes, the GPS course, and the vertical velocity (variometer).<\/p>\n\n\n\n<p>Unfortunately, this module was neither open source nor open hardware. Moreover, the commercial version was never developed, perhaps due to the uncertainty about the return on investment and possible liability issues. As NAVEOL pointed out: \u201cThis AHRS is neither certified nor designed to assist pilots. No guarantee is given on the accuracy and reliability of the data. This product is derived from material for scale models \u201d. This suits the world of non-certified aviation well. To respect our specifications concerning cost control, these characteristics are precisely the ones we were looking for. Amateur aircraft builders are used to this kind of restriction.<\/p>\n\n\n\n<p>So we had to find another solution. It came from an Extended Kalman Filter (or EKF) data fusion algorithm developed by Adhika Lie at the University of Minnesota. This algorithm is available for download in the public domain via <a href=\"https:\/\/github.com\/FlyTheThings\/uNavINS\" target=\"_blank\" rel=\"noreferrer noopener\" title=\"UNav INS\">this link<\/a>. This software (UNav INS) was modified and adapted to the Arduino\/Teensy world by <a href=\"https:\/\/bolderflight.com\/team.html\" target=\"_blank\" rel=\"noreferrer noopener\" title=\"Bolder Flight Systems\">Brian R. Taylor<\/a> at Bolder Flight Systems (BDS). It has been the subject of an extended technical discussion on the <a href=\"https:\/\/forum.pjrc.com\/threads\/48856-uNav-INS\" target=\"_blank\" rel=\"noreferrer noopener\" title=\"PJRC Forum\">PJRC forum<\/a>. Many improvements have been gradually made; the most recent version, the one used in our AHRS, is downloadable <a href=\"https:\/\/forum.pjrc.com\/threads\/48856-uNav-INS\/page31\/post#759\" target=\"_blank\" rel=\"noreferrer noopener\" title=\"Download UNav INS\">here<\/a> (post #759).<\/p>\n\n\n\n<p>The TheInvenSensee 9DOF MPU9250 inertial unit used in the examples provided with the UNav INS library is obsolete and increasingly difficult to find. In addition, online sales sites are full of clones of dubious provenance that do not work. Therefore, we have adapted the software to use more modern and efficient STMicroelectronics sensors that are very easy to find on the market: the LSM6DSOX (triaxial accelerometer and triaxial gyrometer) and the LIS3MDL (triaxial magnetometer). Both of these sensors are implemented on the <a href=\"https:\/\/www.adafruit.com\/product\/4517\" target=\"_blank\" rel=\"noreferrer noopener\" title=\"Adafruit 4517 breakout board\">Adafruit 4517 breakout board<\/a>.<\/p>\n\n\n\n<p>Our AHRS (fig. 2) is built around these sensors, and a U-Blox NEOM9N GNSS mounted on a SparkFun breakout board. The data fusion software runs on a Teensy 4.0 board. To test it quickly with the EFIS already installed in our aircraft, which was designed and programmed for the Naveol AHRS, the output connector is based on the Naveol one with UART serial Rx and Tx pins. A CAN Bus interface (CAN H and CAN L pins) is also provided and can be used with the appropriate software version. See the readme file on GitHub. There is a major advantage of this new AvionicsDuino AHRS compared to the Naveol one: it is an open-source software and hardware system, and everything can be customized.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"589\" src=\"https:\/\/avionicsduino.com\/wp-content\/uploads\/2022\/09\/AHRSV2-1024x589.jpg\" alt=\"\" class=\"wp-image-1868\" srcset=\"https:\/\/avionicsduino.com\/wp-content\/uploads\/2022\/09\/AHRSV2-1024x589.jpg 1024w, https:\/\/avionicsduino.com\/wp-content\/uploads\/2022\/09\/AHRSV2-300x173.jpg 300w, https:\/\/avionicsduino.com\/wp-content\/uploads\/2022\/09\/AHRSV2-768x442.jpg 768w, https:\/\/avionicsduino.com\/wp-content\/uploads\/2022\/09\/AHRSV2-1536x884.jpg 1536w, https:\/\/avionicsduino.com\/wp-content\/uploads\/2022\/09\/AHRSV2-1200x691.jpg 1200w, https:\/\/avionicsduino.com\/wp-content\/uploads\/2022\/09\/AHRSV2.jpg 1800w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><figcaption class=\"wp-element-caption\">Figure 2: the AvionicsDuino AHRS, which replaced the Naveol AHRS<\/figcaption><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Installing the AHRS in an airplane<\/h3>\n\n\n\n<p>The AHRS must be perfectly aligned with the airplane&rsquo;s longitudinal and lateral axes during straight and level flight.<\/p>\n\n\n\n<p>The orientation is as follows: Teensy and IMU are on top, GNSS is on the bottom, and the output connector is at the rear.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Results<\/h3>\n\n\n\n<p>The first flight tests were particularly satisfactory. The horizon of the AvionicsDuino EFIS  with this AHRS follows very closely that of the Dynon EFIS D10A (video 1), as well as the natural horizon (video 2). <\/p>\n\n\n\n<p>It should be noted that the software (EFIS and EMS) used in the videos below are old versions. Many improvements and corrections have been achieved since these videos were made. All the parameters displayed by the EFIS have now been rigorously validated during many other flight tests.<\/p>\n\n\n\n<figure class=\"wp-block-video\"><video height=\"1088\" style=\"aspect-ratio: 1920 \/ 1088;\" width=\"1920\" controls src=\"https:\/\/avionicsduino.com\/wp-content\/uploads\/2022\/09\/AHRSV2_01bis.mp4\"><\/video><figcaption class=\"wp-element-caption\">Video 1: Comparison between AvionicsDuino EFIS and Dynon D10A<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-video\"><video height=\"1920\" style=\"aspect-ratio: 1080 \/ 1920;\" width=\"1080\" controls src=\"https:\/\/avionicsduino.com\/wp-content\/uploads\/2025\/07\/AHRSV2_03.mp4\"><\/video><figcaption class=\"wp-element-caption\">Video 2: Comparison between AvionicsDuino EFIS and natural horizon<\/figcaption><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Practical realization<\/strong><\/h3>\n\n\n\n<p>Download the appropriate <a href=\"https:\/\/github.com\/bfrmd\/EFIS-AHRS-AvionicsDuino\" target=\"_blank\" rel=\"noreferrer noopener\" title=\"AvionicsDuino AHRS GitHub repository\">AHRS software from GitHub<\/a>.<\/p>\n\n\n\n<p>Version 2.0 or later of this software should only be used with the EFIS_remote_ module software version 2.0 or later and the EFIS software version 3.0 or later. This is due to major modifications to the CAN bus configuration required when removing the UART serial communication line that connected the EFIS to the AHRS and hooking the AHRS up to the CAN bus.<\/p>\n\n\n\n<p>Version 1.3 should be used with EFIS_Remote_Module software V 1.0, EFIS software V 2.5, and a UART serial communication line between AHRS and EFIS. These legacy versions will no longer be updated.<\/p>\n\n\n\n<p>Extract the 3rd party libraries (Bolder Flight Systems) to your Arduino libraries folder. <\/p>\n\n\n\n<p>Download (<a href=\"https:\/\/github.com\/adafruit\/Adafruit_LSM6DS\" target=\"_blank\" rel=\"noreferrer noopener\">here <\/a>and <a href=\"https:\/\/github.com\/adafruit\/Adafruit_LIS3MDL\" target=\"_blank\" rel=\"noreferrer noopener\">here<\/a>) and install the Adafruit libraries with the Library Manager of the Arduino IDE.<\/p>\n\n\n\n<p>The U-Blox NEO M9N GNSS receiver needs to be <a href=\"https:\/\/avionicsduino.com\/index.php\/en\/u-blox-neo-m9n-gnss-configuration\/\" title=\"GNSS receiver configuration\">configured with the U-Blox u-center software<\/a>. <\/p>\n\n\n\n<p>This configuration can be made manually by activating the necessary messages one after the other on the UART1 output. This output must also be correctly configured. This manual setup is an excellent exercise to fully understand how the GNSS works and the u-Blox general \u201cphilosophy\u201d.<\/p>\n\n\n\n<p>You can also do this configuration more simply using the downloadable configuration file below. Please note that you must use a configuration file corresponding to the firmware version of your NEO-M9N. See the <a href=\"https:\/\/avionicsduino.com\/index.php\/en\/u-blox-neo-m9n-gnss-configuration\/\" title=\"GNSS configuration page\">GNSS Configuration page<\/a> for instructions on performing automated setup using this file.<\/p>\n\n\n\n<div class=\"wp-block-file\"><a id=\"wp-block-file--media-0987bfca-9135-4462-90ca-c808fc1216c1\" href=\"https:\/\/avionicsduino.com\/wp-content\/uploads\/2024\/02\/Configuration_NEOM9N_Avionicsduino_AHRS.txt\">Configuration file firmware v 4.00<\/a><a href=\"https:\/\/avionicsduino.com\/wp-content\/uploads\/2024\/02\/Configuration_NEOM9N_Avionicsduino_AHRS.txt\" class=\"wp-block-file__button wp-element-button\" download aria-describedby=\"wp-block-file--media-0987bfca-9135-4462-90ca-c808fc1216c1\">Download<\/a><\/div>\n\n\n\n<div class=\"wp-block-file\"><a id=\"wp-block-file--media-f30f75d5-f2de-4954-bb48-4b18b23058cb\" href=\"https:\/\/avionicsduino.com\/wp-content\/uploads\/2024\/02\/Configuration_NEOM9N_Avionicsduino_AHRS_firmware404.txt\">Configuration file firmware v 4.04<\/a><a href=\"https:\/\/avionicsduino.com\/wp-content\/uploads\/2024\/02\/Configuration_NEOM9N_Avionicsduino_AHRS_firmware404.txt\" class=\"wp-block-file__button wp-element-button\" download aria-describedby=\"wp-block-file--media-f30f75d5-f2de-4954-bb48-4b18b23058cb\">DOWNLOAD<\/a><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>The Bolder Flight Systems UBX library parses data from the following messages:<br>&#8211; UBX-NAV-DOP<br>&#8211; UBX-NAV-EOE<br>&#8211; UBX-NAV-POSECEF<br>&#8211; UBX-NAV-PVT<br>&#8211; UBX-NAV-VELECEF<br>&#8211; UBX-NAV-TIMEGPS<br><br>All these messages should be enabled on the UART1 output of the GNSS receiver using the u-center software. Baud-rate 921600. The CFG-RATE-MEAS parameter must be set to 50 ms to obtain a message output rate of 20 Hz.<\/p>\n\n\n\n<div class=\"wp-block-file\"><a id=\"wp-block-file--media-f9841eb5-e5c7-46e9-9206-4b1f9979506a\" href=\"https:\/\/avionicsduino.com\/wp-content\/uploads\/2022\/10\/AHRS_AvionicsDuino_V1_Kicad6_Files.zip\">Download the AHRS AvionicsDuino V1 Kicad 6 Files<\/a><\/div>\n\n\n\n<div class=\"wp-block-file\"><a id=\"wp-block-file--media-478d4e21-2f99-4eab-b6a7-863b85370b81\" href=\"https:\/\/avionicsduino.com\/wp-content\/uploads\/2023\/05\/AHRS_Gerber_and_drill_files.zip\">Download the AHRS Gerber and drill files.<\/a><\/div>\n\n\n\n<div class=\"wp-block-file\"><a id=\"wp-block-file--media-1fdc470f-8097-47dd-816e-ecd10217fb51\" href=\"https:\/\/avionicsduino.com\/wp-content\/uploads\/2023\/11\/AHRS_01_BOM.zip\">Download the AHRS BOM<\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>(AHRS: Last updated by Benjamin on March 23, 2024) The AHRS, for Attitude and Heading Reference System, is the most complex part of the EFIS. Not so much because of the components (particularly the IMU, see below), because they are ubiquitous, easy to find on breakout boards, and inexpensive. This complexity is actually due to &hellip; <a href=\"https:\/\/avionicsduino.com\/index.php\/en\/the-ahrs\/\" class=\"more-link\">Continuer la lecture<span class=\"screen-reader-text\"> de &laquo;&nbsp;AHRS : the heart of an EFIS&nbsp;&raquo;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"class_list":["post-346","page","type-page","status-publish","hentry"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/avionicsduino.com\/index.php\/wp-json\/wp\/v2\/pages\/346","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/avionicsduino.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/avionicsduino.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/avionicsduino.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/avionicsduino.com\/index.php\/wp-json\/wp\/v2\/comments?post=346"}],"version-history":[{"count":76,"href":"https:\/\/avionicsduino.com\/index.php\/wp-json\/wp\/v2\/pages\/346\/revisions"}],"predecessor-version":[{"id":4903,"href":"https:\/\/avionicsduino.com\/index.php\/wp-json\/wp\/v2\/pages\/346\/revisions\/4903"}],"wp:attachment":[{"href":"https:\/\/avionicsduino.com\/index.php\/wp-json\/wp\/v2\/media?parent=346"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}