# LIS331 Implementation

Question asked by r.gary on Oct 4, 2013
Latest reply on Dec 18, 2014 by joshi.kamal
Hello,

I'm hoping to get a bit of guidance here on this application I'm developing using the LIS331HH device.

I have integrated it into the application PCB, and using SPI to communicate with the device. All is well and I can set and read registers, ODR, filters, range, etc. Also, for actual implementation, I have tied the 2 HW interrupt lines to the microcontroller and will be using that in future. For the time, I just want to understand how to implement the right code to deliver the desired outcome. Using some test code, I can see data coming from xL, XH, yL, yH, zL, ZH but don't fully realize how to apply it for the desired outcome.

The application is very straightforward; to measure forces on the PCB that are primarily in 1 axis. After looking at a handful of code samples (there are few to be found) it's gained some clarity but still not there. Also, I didn't find the app notes helpful in terms of actual code implementation.
I understand that the orientation of the device is quite relevant to the data output. The PCB when installed in the assembly can "roll" (in x-y) about the Z-axis (meaning Z axis is horizontal relative to me)
So exactly what do I need to do with the output data to meaningfully use it? Here are some questions I hope someone can answer for me:

1 - The range of the device is +/-24g. Can I extend this to just +48g? How?
2 - How do I "normalize" the actual position relative to the absolute (calibrated) position and apply this to the data of interest?
3 - I'm primarily interested in the Z force vector. I also understand that there may be relevant applicable forces from x,y contributing to z, as the device rolls about on the z axis. Can I use the simple square root of sum-of-squares to tabulate total force on Z?

I would be mostly appreciative of a code sample, algorithm or clear explanation for this objective.

Thank you, regards,
Gary