Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible error at vdd_25 extraction #113

Open
yagui opened this issue Nov 29, 2023 · 2 comments
Open

Possible error at vdd_25 extraction #113

yagui opened this issue Nov 29, 2023 · 2 comments

Comments

@yagui
Copy link

yagui commented Nov 29, 2023

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

@yagui
Copy link
Author

yagui commented Dec 2, 2023

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
Copy link
Collaborator

slavysis commented Dec 4, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants