melexis / mlx90640-library

MLX90640 library functions
Apache License 2.0
241 stars 192 forks source link

Possible error at vdd_25 extraction #113

Open yagui opened 12 months ago

yagui commented 12 months ago

The datasheet says vdd_25 is a 8 bit integer with sign. This means that it could go from -128 to 127. image But in this code, when it is masked with 0x00ff, and then stored in a int16_t it will always store a positive value https://github.com/melexis/mlx90640-library/blob/f6be7ca1d4a55146b705f3d347f84b773b29cc86/functions/MLX90640_API.c#L766 https://github.com/melexis/mlx90640-library/blob/f6be7ca1d4a55146b705f3d347f84b773b29cc86/functions/MLX90640_API.c#L770-L771

This is easy to fix, but I'm not sure this is a bug or I'm not understanding the code correctly

yagui commented 12 months ago

After doing some test, when the data stored at the lower byte in EE[0x2433] is above 128, the value should be considered positive in the line 770. Otherwise the calculation will result in incorrect vdd values. So I assume that vdd_25 has to be considered always as positive, and maybe the datasheet should be fixed.

slavysis commented 11 months ago

Indeed this value is always negative. Thus the driver always substracts 256 (two's complement). The driver works properly and the datasheet needs some modification in order to make this clear and avoid confusion.