here is the calibration routing i am using for the mlx90640 sensor
i have already stored values in eeprom, and only need to read ram value of voltage to sensors 1 time per pass. 2 passes to read all sensors. so two voltage values.
this code extracts the kVdd, and the Vdd25 which are stored values, and then applies calculations to get the VDD at time of sensor read. i use a 2 byte word worddata to get data when i need it from sensor. i'm trying to reduce the reads from the chip and use the stored values that are copied to eprom flash of arduino
void ExtractVDDParameters()
{
worddata[0]= pgm_read_word_near(factoryCalData+0x0033);//we can get this value from eeprom, faster and more reliably
kVdd =worddata[0];
kVdd =kVdd & 0xFF00;//we do some required conversion (11.2.2.2 in document)
kVdd =kVdd >>8 ;//we divide by 2^8
if (kVdd >127){kVdd -=256;}//if >127 we subtract 256 as per document
kVdd =kVdd *32 ;//we now multiply by 32
Vdd25=worddata[0];
Vdd25=Vdd25 & 0x00FF;
Vdd25= ((Vdd25 -256)<<5)-8192;
//we need to get this from ram on sensor because it changes all the time!
MLX90640_I2CRead(MLX90640_address, 0x072A, 1, worddata);//we get vdd used real time from senso
Vdd=worddata[0];
if (Vdd>32767 ){Vdd=Vdd-65536;}//we do this to normalize the value
uint16_t storedRes= pgm_read_word_near(factoryCalData+56);//we can get this value from eeprom, faster and more reliably
storedRes= storedRes& 0x3000;
storedRes= storedRes>>12;
//we need analog resolution
MLX90640_I2CRead(MLX90640_address, 0x800D, 1, worddata);//we read register memory
worddata[0]=(worddata[0]& 0x0C00)>>10;//we get ad resolution detail
float resolutionfix;
if (worddata[0]==0){resolutionfix=4.0;}
if (worddata[0]==1){resolutionfix=2.0;}
if (worddata[0]==2){resolutionfix=1.0;}
if (worddata[0]==3){resolutionfix=0.5;}
Vdd= (resolutionfix* Vdd - Vdd25) / kVdd + 3.3;
}
here are the results in terminal. for current troubleshooting i am only using center 8x8 sensors (even though it is capable of 32x24). you can see the extracted vdd25 and kvdd values. also note that for each frame the voltage is different slightly. this will effect gain and proper reading if both values are not used.
the sensor reads currently are raw values and are currently meaningless except to know that they change values.
![](https://cdn.hackaday.io/images/4630741543751546543.png)
here is the calc references from documentation. seems simple but a lot of troubleshooting. also i found a better way to calc the different resolutions. at least one that does not need POW
![](https://cdn.hackaday.io/images/8409361543751752975.png)
now on to the next set of needed calc for getting temp from sensor.
here are the calculations in all that i need to work on getting coded for Arduino to work, now that i know the format and the offsets for eeprom data, and how the register on this product works, hopefully things will go quickly.
![](https://cdn.hackaday.io/images/1539651543751835844.png)
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.