LSM303DLHC-6DOF Sensor

Hi,

I have got a LSM303DLHC sensor, it's giving out very accurate reading in term of heading, pitch and roll when sitting horizontally on the table. however, in the final product, the sensor needs to be mounted vertically onto a pole or somewhere else.

so here are my problems:

  1. in terms of calculating the roll and pitch angle, what components should I be substituting into the formula in this scenario .

  2. in term of calculating the heading angle, I have tried to used the formula of (atan2(megZ,megX)* 180/pi), it ended up giving out some wired reading .

Thanks

See this application note for how to create a tilt compensated compass with the LSM303DLH. There will be a few minor changes for the LSM303DLHC.

That method uses a lot of trigonometry. There is a much simpler vector approach to make a tilt compensated compass, presented in this example code (zip file).

Hi,

Thanks for the reply !

My development is actually based on this Application Note, however all the calculations in this application note are done with the assumption that the sensor chip sitting horizontally.

but in my application, the sensor would be mounted vertically onto the wall.

Thanks .

Then use the same equations, but change the axes appropriately. It does not matter what you call X, Y or Z as long as the right hand rule is obeyed.