a lot faster in image mode, but it only works if you normalize it

A project log for mlx90640 sensor works w 800 bytes

Everywhere i read people are excited to get mlx90640 working. here are examples using arduino w 800bytes ram, and 1k with calibrated DEG C

jamesdanielvjamesdanielv 09/12/2019 at 02:240 Comments

ill release code that does normalizing of image data  9/13

image mode is a lot faster, but you need to adjust the sensitivity and figure out how the range should apply. in my case i want it to work in a similar range as the deg C. it will have some cells still out of reasonable range, but this is ok for image data.

here is a nano, using a 328p, the same chip class as the uno running image mode

with normalizing. at first few frames it is saturated, but it self adjusts. then i do the hand count in front of sensor.  then i give the sensor a high five pose.

here is how to normalize the sensor automatically.

//this is code that adjusts the sensitivity. it has 10 in between values so it does not oscillate back and forth.
void Normalize(){
  if (autoNormalizeAdjust>50){ autoNormalizeAdjust=50;} //this is the max level
  if (autoNormalizeAdjust>255){ autoNormalizeAdjust=0;}// was backed up to far and rolled around
if (autoNormalizeAdjust==0){RamstoreNormalizeImageValue=(float)1/8;}
if (autoNormalizeAdjust==10){RamstoreNormalizeImageValue=(float)1/16;}
if (autoNormalizeAdjust==20){RamstoreNormalizeImageValue=(float)1/32;}
if (autoNormalizeAdjust==30){RamstoreNormalizeImageValue=(float)1/64;} 
if (autoNormalizeAdjust==40){RamstoreNormalizeImageValue=(float)1/128;} 
if (autoNormalizeAdjust==50){RamstoreNormalizeImageValue=(float)1/256;} 

uint8_t shownormilzeMode(){
return  autoNormalizeAdjust;

to determine if image is over exposed, or needs to be normalized, i check 5 pixels.

     *                *   it samples 5 cells. the total count needs to be odd, and still it could cause

             *           oscillation, this is why i have 10 numbers between changing sensativity.

    *                *  it does take a few seconds for sensor to find its range however only during startup

            if (pixelNumber == 32*12+16 ||pixelNumber ==0 ||pixelNumber ==31 || pixelNumber ==767 ||pixelNumber ==767-32){//we only do this on center pixel and top and bottom

here is how it knows it is saturated. image is the float value that holds the calculated value for return from get_image routine

            #if autoNormalizeImageMode == true

            if (Analog_resolution== 16){image=image*0.00003051757*RamstoreNormalizeImageValue;}
            if (Analog_resolution== 17){image=image*0.00001525878*RamstoreNormalizeImageValue;}
            if (Analog_resolution== 18){image=image*0.00000762939*RamstoreNormalizeImageValue;}
            if (Analog_resolution== 19){image=image*0.00000381469*RamstoreNormalizeImageValue;}
            if (pixelNumber == 32*12+16 ||pixelNumber ==0 ||pixelNumber ==31 || pixelNumber ==767 ||pixelNumber ==767-32){//we only do this on center pixel and top and bottom
            if (image+25 <24){autoNormalizeAdjust++;Normalize();}
            if (image+25>26){autoNormalizeAdjust--;Normalize();}
            #else //this is if it is not auto and we use value in Z_MemManagement.h
            if (Analog_resolution== 16){image=image*0.00003051757*NormalizeImageValue;}
            if (Analog_resolution== 17){image=image*0.00001525878*NormalizeImageValue;}
            if (Analog_resolution== 18){image=image*0.00000762939*NormalizeImageValue;}
            if (Analog_resolution== 19){image=image*0.00000381469*NormalizeImageValue;}
            return image+25;