adafruit / Adafruit_MLX90393_Library

MIT License
14 stars 18 forks source link

Incorrect gain coefficients #7

Closed emilenovv closed 3 years ago

emilenovv commented 3 years ago

According to MLX90939 Datasheet REVISION 006 - JANUARY 8, 2020 the values set for HALLCONF = 0x0 in Adafruit_MLX90393.h are in fact the ones for HALLCONF = 0xC but at 35°C. Again in the same datasheet "For HALLCONF = 0x0, the sensitivity scales with a factor 98/75." https://github.com/adafruit/Adafruit_MLX90393_Library/blob/f4687abe4c43cc372d5b96dee9faac46485d9b8a/Adafruit_MLX90393.h#L95-L112

ladyada commented 3 years ago

ooh can you send a PR?

caternuson commented 3 years ago

@emilenovv The datasheet has a confusing typo (maybe copy pasta?). How did you verify what values go with what HALLCONF?

image

emilenovv commented 3 years ago

@caternuson I also noticed that typo in the datasheet. I am not able to verify empirically what values go with what HALLCONF since I don't have the required equipment right now. However, I deduced that the "Table 17." in the datasheet is for HALLCONF=0xC and not for HALLCONF=0x0 because of the footnote on the same page.

image

caternuson commented 3 years ago

Thanks. Still not following. That also seems confusing. It is footnoted from both tables. And 0.150 * 98/75 = 0.196, so not sure where the factor of 10 is coming from. But the note in general seems to imply that the coefficients for HALLCONF=0x0 should be larger than the coefficients for HALLCONF=0xC. Which would indicate the lower table is for HALLCONF=0x0.

[EDIT] I've emailed Melexis to see if they will respond and clarify.

emilenovv commented 3 years ago

There is one ancient revision of the document (REVISION 003 - SEPTEMBER 14, 2017) where the two tables are given (without obvious typos :) ). There the coefficient of 98/75 matches. E.g., 0.751*(98/75) = 0,981. You are correct that this factor 10 is confusing. Anyway, you have done the best thing by asking Melexis. Let's see their answer.

image

caternuson commented 3 years ago

Melexis responded saying they were aware of the typo and provided the following clarification:

the first table is for HallConf = 0xC and the second table is for HallConf = 0x0.

So I think mlx90393_lsb_lookup is defined correctly.

What we don't have is the ability to actually change HALLCONF. It is hardwired to 0xC. Closing this issue and if there is a desire to add setting HALLCONF, then let's start a new issue for that.