Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
5 years ago.
Dividing by 15 bug
A very helpful library, thank you for creating it.
One thing that confused me was the division by 15. It's not immediately obvious, but the data by default is in the highest 12 bits of a 16bit number spread across two registers. The sensitivity is expressed as X mg per digit, but this is per digit of the 12bit representation. Consequently, you need to right shift the 16bit representation by 4 (aka divide by 16, not 15).
I think this is a more obvious way of showing this in the code (from read_mg_data):
dt_usr = float(short((data << 8) | data) >> 4) * fs_factor; dt_usr = float(short((data << 8) | data) >> 4) * fs_factor; dt_usr = float(short((data << 8) | data) >> 4) * fs_factor;
Please correct me if I have made a mistake.
Question relating to:
4 years, 5 months ago.
Thanks your comments and I agreed your explanation. I fixed those bugs and updated it. I'm sorry not to answer until today. I haven't come to mbed web page due to my busy business condition. I made a check program as follows. /users/kenjiArai/code/Check_new_LIS3DH_lib/
Thanks your suggestion!