Source form for eCompass software and 4 and 7 element magnetic routines (Yes!)

By Michael Stanley

Originally posted on Freescale’s The Embedded Beat Blog

Last week, Freescale made its eCompass and 4 and 7 element magnetic compensation routines available in (drum roll please!) source form.

Getting access is easy. Let me take you through the steps….

    • Open your web browser to
    • Click on the “ECOMPASS_SW: eCompass Software” link.
    • This will take you to the Freescale web site login page. You must be a registered user to download the software. There is a link right on that page allowing you to register if you haven’t already.
    • Once you’ve entered your ID and password, you will be presented with a copy of the software license agreement. Please review it carefully before clicking the “I Accept” button. The good news is this: Freescale is making this software freely available for use in any product containing an Xtrinsic brand magnetometer. There is no license fee, there are no royalties.
    • Assuming you have accepted, follow the usual procedure to download the software onto your hard drive.The software is in the form of a zip file containing:
      • A single C source file (main.c)
      • Freescale User’s Guide entitled “Implementing a Tilt-Compensated eCompass with Magnetic Calibration”.

The basic dataflow of the algorithm is illustrated in the block diagram below. The software contains source for each of the blocks shown.
eCompass Block Diagram

The main.c file includes the entire application, and is designed to operate as a “console” application which should be compatible with just about any C compiler. The accompanying user guide goes through the source in a detailed fashion, and clearly explains how to adapt the code for your environment. The application is designed to operate out of the box with simulated data. You need to replace the console I/O functions with a call to your I2C driver function to operate with real data.There are options allowing you to build a model for hard iron compensation only (the four element model) or for many cases involving soft iron issues (the 7 element model). The generated soft iron matrix is limited to scale factors distributed along the diagonal of the soft iron matrix (see my earlier posts listed in references below). In general, you want to use the simplest model that works for your product. Should your soft iron problems exceed the capabilities of the 4 and 7 element models, Freescale has a more complicated model which supports off-diagonal elements in the soft iron matrix. Please contact your Freescale representative for details.


Original post:


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s