melexis / mlx90640-library

MLX90640 library functions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Possible error at vdd_25 extraction

yagui opened this issue · comments

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


vdd25 = MLX90640_LS_BYTE(eeData[51]);
vdd25 = ((vdd25 - 256) << 5) - 8192;

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

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.

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.