Guest Blog: Xtrinsic sensor fusion library for Kinetis MCUs

by Michael E Stanley 

First Appeared in The Embedded Beat on Feb 24, 2014

30615-IND-FRDM-Duo2_angle_LR.jpgIn my December post, New sensor expansion boards for Freescale Freedom development platform, I introduced you to the FRDM-FXS sensor shields for the platform.  From the “Downloads” tab on the FRDM-FXS-MULTI-B web page, you can now download demo executables for the FRDM-KL25Z and FRDM-K20D50M boards that are compatible with Xtrinsic Sensor Fusion Toolbox for Android. (You can read more about this app here: Free Android App Teaches Sensor Fusion Basics.)  The links for the two executable are labeled FRDM-K20D50M_MQXL (compiled for ARM® Cortex-M4) and FRDM-KL25Z-MQXL (compiled for ARM Cortex-M0+).  You will need to log into the Freescale Community and accept a click-through license/disclaimer to gain access to the files.

One of the things I like most about the Freescale Freedom development platform is its ease of use.  It can be programmed with a bootloader that allows you to plug the board into your PC via USB, and install software (such as these files) with a simple drag and drop.  If you haven’t done this before, let me recommend a couple of resources for you:

Last June, I posted a number of videos to the Freescale website which show you how to run the Sensor Fusion Toolbox.  Although we’ve added a number of features to the toolbox since then, the basic principles described in the videos still apply.  Using the combination of hardware (shown at left), embedded code from the links above, and the Sensor Fusion Toolbox, you can experiment with different combinations of MCUs, sensors and algorithms, in real time, on your own phone or tablet.

Now here is the really cool part, the embedded fusion library at the heart of this functionality is now available in via the “Xtrinsic Sensor Fusion Library for Kinetis MCUs – Evaluation Version and documentation” link, available from the same Downloads tab listed above.  The download package includes a datasheet describing Freescale’s Xtrinsic Sensor Fusion capabilities, a user’s guide that will show you how to get up and running, and a zip file containing a CodeWarrior project.  The evaluation version runs only on the KL25Z board. Everything in the project, with the exception of one .c file, is precompiled.  Filename user_tasks.c is reserved for your use, and allows you to insert code at 5 specific entry points in the project.  You have visibility to all fusion outputs, and can modify the Bluetooth output stream to suite your own needs.  This is the same project used to create the executables mentioned earlier.  The evaluation version is fully compatible with the Xtrinsic Sensor Fusion Toolbox.

The evaluation version of the kit is intended to give developers everything they need to evaluate the quality and scope of Freescale’s sensor fusion libraries.  Once a decision is made to incorporate the library into a product, you will want to upgrade to the “product development” version of the library.  This version, which will soon be available from the same download page, provides many more bells and whistles with regard to fusion options and underlying project structure.  Differences in the three versions of the library are summarized below:

 

Feature

Demo Version

Evaluation Version

Development Version

License

Free click-through

Free click-through

Contact Freescale for Pricing

CPU selection

MKL25Z128VLK4

MK20DX128VLH5

MKL25Z128VLK4

MKL25Z128VLK4

MK20DX128VLH5

others upon request

Board customizable

No – FRDM_KL25Z & FRDM_K20D50M only

No – FRDM_KL25Z only

Yes

Sensor sample rate

Fixed

Fixed

Programmable

Fusion rate

Fixed

Fixed

Programmable

Frame of Reference

Android

Android

Programmable

Algorithms Executing

accel only, accel + gyro, accel + mag, accel + mag + gyro

Programmable

Sleep mode enabled between samples/calculations

No

No

Programmable

RTOS

MQX-Lite

MQX-Lite

MQX-Lite

Code flexibility

NONE – Executable only

customer code limited to 5 specific entry points

only Kalman and MagCal libraries are precompiled.  Everything else is supplied in source form, and can be modified.

Access to Processor Expert™ configuration

No

No

Yes

Collateral Materials

 

datasheet

zip file containing the appropriate CodeWarrior project

user manual

 

The next table shows sensor fusion features versus sensor complement used for the application.  See the sensor fusion datasheet for additional restrictions/details.

Feature

Accel only

Accel + gyro

Accel + mag

Accel + mag + gyro

Filter Type

Butterworth

Indirect Kalman

Butterworth

Indirect Kalman

Roll / Pitch / Tilt in degrees

Yes

Yes

Yes

Yes

Yaw in degrees

No

No

Yes

Yes

Angular Rate in degrees/second

virtual 2 axis

Yes

virtual 3 axis

Yes

Compass heading (magnetic north) in degrees

No

Yes

Yes

Yes

quaternion and rotation vector

Yes

Yes

Yes

Yes

rotation matrix

Yes

Yes

Yes

Yes

linear acceleration separate from gravity

No

Yes

No

Yes

NED (North-East-Down Frame of Reference

Yes

Yes

Yes

Yes

ENU (Windows 8 variant) Frame of Reference

Yes

Yes

Yes

Yes

ENU (Android variant) Frame of Reference

Yes

Yes

Yes

Yes

Magnetic calibration included

No

No

Yes

Yes

Gyro offset calibration included

N/A

Yes

N/A

Yes

FRDM-KL25Z_MQXL board support

Yes

Yes

Yes

Yes

FRDM-K20D50M_MQXL board support

Yes

Yes

Yes

Yes

I will be teaching two different classes dealing with the Xtrinsic Sensor Fusion Library for Kinetis™ MCUs at the upcoming Freescale Technology Forum in Dallas.  The first will be a one-hour “lunch and learn” session (FTF-SDS-F0176) on Wednesday, April 9.  A three-hour hands on session (FTF-CON-F0178) is planned for Thursday afternoon.  This session was previously targeted specifically at our eCompass software (and may still be shown as such on the FTF agenda), and is being repurposed so that we can provide additional, in depth, training on the fusion library.  I hope to see you there!

 

Michael Stanley is a systems engineer at Freescale.

 

Uncategorized

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s