MMA8451 on kl25z baremetal code angle calculation

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MMA8451 on kl25z baremetal code angle calculation

2,860 Views
asdasdaram
Contributor III

Hello, did someone write some baremetal code for reading the mma8451 accelerometer data and also calculate the angles. Is there a tutorial anywhere?

Thanks

Labels (2)
6 Replies

1,552 Views
TomasVaverka
NXP TechSupport
NXP TechSupport

Hi,

You might also find useful my baremetal example code for the MMA8451Q accelerometer and FRDM-KL25Z platform. I will try to add a few lines of  code to calculate an angle of inclination using atan2 function and then I will post it here.

Regards,

Tomas

0 Kudos

1,552 Views
TomasVaverka
NXP TechSupport
NXP TechSupport

Hi,

Attached you can find the complete example code that computes both pitch and roll angles according to equations 37 and 38 in the AN3461.

I hope it helps.

Regards,

Tomas

1,552 Views
polashmisra
Contributor I

Just in case you wanted a  convenient breakout board to interface and probe the data here is one: Accelerometer(MMA8451) 3-AXIS Digital Module - DoProto Electronics

Regards,

Polash

0 Kudos

1,552 Views
bryancole-b4682
NXP Employee
NXP Employee

Hi,

The FRDM-KL25ZDemo, which can be found in the KL25z sample code, contains baremetal code for angle calculation which can be found in the "angle_calculation" directory in the project folder. The KL25z sample code can be found here FRDM-KL25Z: Freescale Freedom Development Platform for Kinetis KL14/15/24/25 MCUs under Downloads >> Software Development Tools >> Lab and Test software. Hope this helps.

Bryan

1,552 Views
asdasdaram
Contributor III

Hi, thanks for the answer. I looked at this already but its hard to understand why he do so. Maybe a closer look will help i try my best.

0 Kudos

1,552 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello:

You can give a look to the step by step tutorial in the next link. It does not mention the angle calculation, but you can develop your own algorithm with the basics explained:

Tutorial: Accelerating the KL25Z Freedom Board | MCU on Eclipse

Hope this helps!

/Jorge Gonzalez