MLX90632 Driver Library  a258525c
Universal MCU library for the 90632
Introduction and Example

Introduction

This is 90632 example driver with virtual i2c read/write functions. There will be some mapping needed with MCU's own i2c read/write procedures, but the core calculations should remain the same. Functions that need to be implemented for each individual MCU are listed in mlx90632_depends.h file.

Since there is one source and two header files they can be built also just as normal source files. They are dependent on mathlib and errno so appropriate flags are required. For ease of development and unit-testing Makefile was added with following targets:

1 # All targets can take `CC=clang` variable, otherwise default compiler is GCC. If
2 # you need to cross-compile just feed `CROSS_COMPILE` variable to Makefile
3 
4 make libs # builds library with single file. Include inc/ for header definitions
5 make doxy # builds doxygen documentation in build/html/
6 make utest # builds and runs unit test program mlx90632 (dependent on ceedling)
7 make all # builds unit tests, doxygen documentation, coverage information and library
8 make coverage # builds coverage information
9 make clean # cleans the crap make has made
10 make uncrustify # style fixup of the source, header and test files

Datasheet is available in Melexis documentation.

Example program flow

You can either include library directly or object file. Definitions are found in library inc/ folder and you need to point your compiler -I flag there.

After you have your environment set you need to enter below flow to your program.

/* Before include, make sure you have BITS_PER_LONG defined. This is a CPU
* specific value which is used to generate bit masks. You can also use -D
* to input definition to compiler via command line
*/
#include "mlx90632.h"
/* Declare and implement here functions you find in mlx90632_depends.h */
/* You can use global or local storage for EEPROM register values so declare
* them whereever you want. Do not forget to declare ambient_new_raw,
* ambient_old_raw, object_new_raw, object_old_raw
*/
int main(void)
{
int32_t ret = 0;
double ambient;
double object;
/* Read sensor EEPROM registers needed for calcualtions */
/* Now we read current ambient and object temperature */
ret = mlx90632_read_temp_raw(&ambient_new_raw, &ambient_old_raw,
&object_new_raw, &object_old_raw);
if(ret < 0)
/* Something went wrong - abort */
return ret;
/* Now start calculations (no more i2c accesses) */
/* Calculate ambient temperature */
ambient = mlx90632_calc_temp_ambient(ambient_new_raw, ambient_old_raw,
P_T, P_R, P_G, P_O, Gb);
/* Get preprocessed temperatures needed for object temperature calculation */
double pre_ambient = mlx90632_preprocess_temp_ambient(ambient_new_raw,
ambient_old_raw, Gb);
double pre_object = mlx90632_preprocess_temp_object(object_new_raw, object_old_raw,
ambient_new_raw, ambient_old_raw,
Ka);
/* Calculate object temperature */
object = mlx90632_calc_temp_object(object, ambient, Ea, Eb, Ga, Fa, Fb, Ha, Hb);
}