MMA8451Q Tilt

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

MMA8451Q Tilt

Jump to solution
2,408 Views
gaétanphilbiche
Contributor I

Hello,

I use a MMA8451Q to monitor a device that does not have to bend over x degrees to the vertical axis. Before I used a tilt switch CM1320-0 from Assemtech and wish to obtain the same result.

To do this , I thought used to detect portrait/landscape integrated. But I realize doing my tests that this mode is not the same if you turn around the Z axis or if the Z axis is tilted up or down.

Operation when turning around Z is perfect for my application, ideally I would have the same mode of operation on the other axis . But when I switch to the front ( Z down) , I have no hysteresis and backward (Z up) I hysteresis is too important! I tried to cheat the offset of the Z axis, but this is not enough.

I wonder if there is another solution that regularly read the MMA8451Q and make the angle calculation from the XYZ readings ? If there is no alternative , is there a sample source code?

Thank you

Best regards,

Gaétan

Labels (1)
0 Kudos
1 Solution
2,216 Views
gaétanphilbiche
Contributor I

Hi,

I finally meets self!

I chose to integrate the method provided in this datasheet: http://www.analog.com/static/imported-files/application_notes/AN-1057.pdf

On a PIC18 clocked at 8MHz, the computation time is 1.5ms, which is still reasonable.

Too bad, I have not found a solution to use the MMA8451Q with a interrupt, which would have saved me energy.

Rgards,

Gaétan

View solution in original post

0 Kudos
1 Reply
2,217 Views
gaétanphilbiche
Contributor I

Hi,

I finally meets self!

I chose to integrate the method provided in this datasheet: http://www.analog.com/static/imported-files/application_notes/AN-1057.pdf

On a PIC18 clocked at 8MHz, the computation time is 1.5ms, which is still reasonable.

Too bad, I have not found a solution to use the MMA8451Q with a interrupt, which would have saved me energy.

Rgards,

Gaétan

0 Kudos
%3CLINGO-SUB%20id%3D%22lingo-sub-296700%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EMMA8451Q%20Tilt%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-296700%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%2C%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EI%20use%20a%20MMA8451Q%20to%20monitor%20a%20device%20that%20does%20not%20have%20to%20bend%20over%20x%20degrees%20to%20the%20vertical%20axis.%20Before%20I%20used%20a%20tilt%20switch%20CM1320-0%20from%20Assemtech%20and%20wish%20to%20obtain%20the%20same%20result.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3ETo%20do%20this%20%2C%20I%20thought%20used%20to%20detect%20portrait%2Flandscape%20integrated.%20But%20I%20realize%20doing%20my%20tests%20that%20this%20mode%20is%20not%20the%20same%20if%20you%20turn%20around%20the%20Z%20axis%20or%20if%20the%20Z%20axis%20is%20tilted%20up%20or%20down.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EOperation%20when%20turning%20around%20Z%20is%20perfect%20for%20my%20application%2C%20ideally%20I%20would%20have%20the%20same%20mode%20of%20operation%20on%20the%20other%20axis%20.%20But%20when%20I%20switch%20to%20the%20front%20(%20Z%20down)%20%2C%20I%20have%20no%20hysteresis%20and%20backward%20(Z%20up)%20I%20hysteresis%20is%20too%20important!%20I%20tried%20to%20cheat%20the%20offset%20of%20the%20Z%20axis%2C%20but%20this%20is%20not%20enough.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EI%20wonder%20if%20there%20is%20another%20solution%20that%20regularly%20read%20the%20MMA8451Q%20and%20make%20the%20angle%20calculation%20from%20the%20XYZ%20readings%20%3F%20If%20there%20is%20no%20alternative%20%2C%20is%20there%20a%20sample%20source%20code%3F%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EThank%20you%3C%2FP%3E%3CP%3EBest%20regards%2C%3C%2FP%3E%3CP%3EGa%C3%A9tan%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-296700%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CLINGO-LABEL%3EAccelerometers%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-296701%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20MMA8451Q%20Tilt%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-296701%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EI%20finally%20meets%20self!%20%3C%2FP%3E%3CP%3E%3CSPAN%3EI%20chose%20to%20integrate%20the%20method%20provided%20in%20this%20datasheet%3A%20%3C%2FSPAN%3E%3CA%20class%3D%22jive-link-external-small%22%20href%3D%22http%3A%2F%2Fwww.analog.com%2Fstatic%2Fimported-files%2Fapplication_notes%2FAN-1057.pdf%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%20target%3D%22_blank%22%3Ehttp%3A%2F%2Fwww.analog.com%2Fstatic%2Fimported-files%2Fapplication_notes%2FAN-1057.pdf%3C%2FA%3E%3CSPAN%3E%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EOn%20a%20PIC18%20clocked%20at%208MHz%2C%20the%20computation%20time%20is%201.5ms%2C%20which%20is%20still%20reasonable.%20%3C%2FP%3E%3CP%3EToo%20bad%2C%20I%20have%20not%20found%20a%20solution%20to%20use%20the%20MMA8451Q%20with%20a%20interrupt%2C%20which%20would%20have%20saved%20me%20energy.%20%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3ERgards%2C%3C%2FP%3E%3CP%3EGa%C3%A9tan%3C%2FP%3E%3C%2FLINGO-BODY%3E