melexis / mlx90632-library

MLX90632 library for the Melexis 90632 Infra Red temperature sensor.
Apache License 2.0
42 stars 15 forks source link

Difference between code and datasheet #29

Open Piero01 opened 3 years ago

Piero01 commented 3 years ago

Hello, It seems there are some differences regarding the datasheet and the example library:

  1. In datasheet p31: in the 3rd iteration the end result is obtained but in the library 5 iterations are made cfr. mlx90632.c lines 403 and 434. How many iterations should be done then? Is there an advantage to make more iterations?
  2. In datasheet p30 and p34, the S_TO value is computed with only 1 value of S = (RAM_4 + RAM_5) / 2 (for cycle_pos = 1), RAM_7 and RAM_8 are not used. In the code function mlx90632_preprocess_temp_object(), line284: return ((((object_new_raw + object_old_raw) / 2) / (MLX90632_REF_12)) / VR_IR) * 524288.0; it is using object_new_raw = (RAM_4 + RAM_5) / 2 and object_old_raw = (RAM_7 + RAM_8) / 2 (for cycle_pos = 1). What should be done finally? Is the code up-to-date with the datasheet? Should I follow the datasheet or the code?

Thanks.

Letme commented 3 years ago

Which eeprom version do you have in chip and which version are you looking at in datasheet?

Piero01 commented 3 years ago

EE_VERSION on chip returns 0x8305. I'm using the datasheet from Melexis website: revision 10 - November 2020.

Letme commented 3 years ago
  1. The iterations usually converge, so from 3 to 5 iterations may be some last digits might change - usually they don't, so for speed-wise 3 iterations are enough. Seems like the datasheet was updated with this in mind. I will check internally about the change.

  2. For the calculations, it indeed seems like we average it once too many. I doubt there is much difference as most values are quite stable - maybe +/- 1 difference, but it indeed seems discrepancy. Will also check about the latest developments in this topic.

Thanks for a detailed review of the implementation.

slavysis commented 3 years ago

Hi,

  1. 3 iterations should be enough as @Letme pointed out, more iterations will change some of the last digits - it should be more apparent for the high temperatures, but the effect is negligible.
  2. Basically, you can use both approaches (as described in the DS and as implemented in the driver). The datasheet gives a more direct calculation whereas the driver implements a simple moving average filter. The difference between the two would be that the driver implementation would have a bit less noise, but in certain cases (sudden changes in the object temperature) it will react a bit slower.

Best regards