4 years, 3 months 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:
3 years, 9 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!
You need to log in to post a question