Kevin Braun / MLX9062x

Dependents:   KL25Z_MLX90620

Embed: (wiki syntax)

« Back to documentation index

MLX9062x Class Reference

Software routines to access the Melexis MLX90620 and MLX90621 64 pixel (4 X 16) infrared sensor array The MLX9062x's internal RAM has different i2c behavior than it's internal EEPROM As a result, the MLX9062x's RAM uses more primitive mbed i2c commands than does the EEPROM. More...

#include <MLX90620.h>

Data Structures

struct  mlx_struct
 Public data structure for MLX9062x data values. More...

Public Types

enum  MLXdevice
 

Select device MLX90620 or MLX90621.

More...

Public Member Functions

 MLX9062x (PinName sda, PinName scl, const char *name)
 Create a MLX90620 object using the specified I2C object.
 MLX9062x (PinName sda, PinName scl, MLXdevice MLXtype, const char *name)
 Create a MLX9062x object using the specified I2C object.
int LoadEEPROM (mlx_struct &Pntr)
 Copy the contents of the MLX9062x EEPROM into local buffer.
int SetOscTrimReg (mlx_struct &Pntr)
 Initialize the MLX9062x's Oscillator Trim Register.
uint16_t GetOscTrimReg (mlx_struct &Pntr)
 Get the MLX9062x's Oscillator Trim Register.
int SetConfigReg (mlx_struct &Pntr)
 Set the MLX9062x's Configuration Register.
uint16_t GetConfigReg (mlx_struct &Pntr)
 Get the MLX9062x's Configuration Register.
uint16_t GetPTATReg (mlx_struct &Pntr)
 Get the MLX9062x's PTAT register.
int16_t GetTGCReg (mlx_struct &Pntr)
 Get the MLX9062x's TGC register.
void LoadMLXRam (mlx_struct &Pntr)
 Get the MLX9062x's IR pixel array and dump into local buffer.
int StartMeasurement (mlx_struct &Pntr)
 Start a Ta and IR array conversion update cycle.
double GetDieTemp (mlx_struct &Pntr)
 Get the MLX9062x's die temperature in degC.
void CalcTa_To (mlx_struct &Pntr)
 Calculate initial MLX9062x offsets.
double CalcPixel (mlx_struct &Pntr, int Pixel)
 Calculate temperature of any pixel within the array (0 - 63)

Detailed Description

Software routines to access the Melexis MLX90620 and MLX90621 64 pixel (4 X 16) infrared sensor array The MLX9062x's internal RAM has different i2c behavior than it's internal EEPROM As a result, the MLX9062x's RAM uses more primitive mbed i2c commands than does the EEPROM.

Definition at line 132 of file MLX90620.h.


Member Enumeration Documentation

enum MLXdevice

Select device MLX90620 or MLX90621.

Definition at line 140 of file MLX90620.h.


Constructor & Destructor Documentation

MLX9062x ( PinName  sda,
PinName  scl,
const char *  name 
)

Create a MLX90620 object using the specified I2C object.

Original Constructor

Parameters:
sdapin for I2C object
sclpin for I2C object
nameof MLX90620 object

Definition at line 13 of file MLX90620.cpp.

MLX9062x ( PinName  sda,
PinName  scl,
MLXdevice  MLXtype,
const char *  name 
)

Create a MLX9062x object using the specified I2C object.

New Constructor with ability to select between a MLX90620 and MLX90621

Parameters:
sdapin for I2C object
sclpin for I2C object
MLXdeviceselect between mlx90620 and mlx90621 device
nameof MLX9062x object

Definition at line 22 of file MLX90620.cpp.


Member Function Documentation

double CalcPixel ( mlx_struct Pntr,
int  Pixel 
)

Calculate temperature of any pixel within the array (0 - 63)

After an IR array dump into local buffer

Parameters:
setint(0-63) of pixel to convert,
pointerto struct mlx_struct
Returns:
pixel temperature of selected pixel in degC
void CalcTa_To ( mlx_struct Pntr )

Calculate initial MLX9062x offsets.

Performed only at initialization

Sets the MLX9062x with die correcting factors at initialization

Parameters:
pointerto struct mlx_struct
Returns:
NONE
uint16_t GetConfigReg ( mlx_struct Pntr )

Get the MLX9062x's Configuration Register.

16 bit value, Read from MLX RAM

Periodic check for Ta ready, IR Array ready and brownout conditions

Parameters:
pointerto struct mlx_struct
Returns:
CR - Configuration Register value
double GetDieTemp ( mlx_struct Pntr )

Get the MLX9062x's die temperature in degC.

Returns MLX9062x die temperature

Needs to be performed before every array update calculation

Parameters:
pointerto struct mlx_struct
Returns:
die temperature of MLX9062x in degC
uint16_t GetOscTrimReg ( mlx_struct Pntr )

Get the MLX9062x's Oscillator Trim Register.

7 lsb bits from 16 bit value, Read from MLX RAM

Parameters:
pointerto struct mlx_struct
Returns:
OTR - Oscillator Trim Register value
uint16_t GetPTATReg ( mlx_struct Pntr )

Get the MLX9062x's PTAT register.

Register read at every Ta cycle

16 bit value, PTAT sensor, Read from MLX RAM

Returns the Proportional To Ambient Temperature Register value

Parameters:
pointerto struct mlx_struct
Returns:
PTAT Register value
int16_t GetTGCReg ( mlx_struct Pntr )

Get the MLX9062x's TGC register.

16 bit value, TGC, Read from MLX RAM

Returns the Temperature Gradient Coefficient Register value

Parameters:
pointerto struct mlx_struct
Returns:
TGC - Temperature Gradient Coefficient Register value
int LoadEEPROM ( mlx_struct Pntr )

Copy the contents of the MLX9062x EEPROM into local buffer.

Loads all 256 bytes from EEPROM into local buffer inside mlx_struct

Note: Only done at initialization. MUST be the first thing you do in MAIN.

Parameters:
pointerto struct mlx_struct
Returns:
'1' if i2c error, '0' if ok.

Definition at line 33 of file MLX90620.cpp.

void LoadMLXRam ( mlx_struct Pntr )

Get the MLX9062x's IR pixel array and dump into local buffer.

Loads IR Pixel array into buffer (0x7F bytes, 0x3f Pixels), Read from MLX RAM

Parameters:
pointerto struct mlx_struct
Returns:
NONE
int SetConfigReg ( mlx_struct Pntr )

Set the MLX9062x's Configuration Register.

16 bit value set by code at initialization

Register is set only during initialization. Inital setup:

1. ADC low reference

2. Ta Ref Rate 8Hz

3. I2C FM+ mode enabled

4. MD / Brownout bit set

5. Normal Operation (non-Sleep) mode

6. Step(Melexis reserved) mode. (removed from later datasheets, but used in this code)

7. IR refresh rate 4Hz

Parameters:
pointerto struct mlx_struct
Returns:
'1' if i2c error, '0' if ok.
int SetOscTrimReg ( mlx_struct Pntr )

Initialize the MLX9062x's Oscillator Trim Register.

7 lsb bits from 16 bit value,

Data is derived from values received from the EEPROM

Register is only set once during initialization

Parameters:
pointerto struct mlx_struct
Returns:
'1' if i2c error, '0' if ok.
int StartMeasurement ( mlx_struct Pntr )

Start a Ta and IR array conversion update cycle.

MLX9062x starts aquiring data, takes about 250mS /w 4Hz refresh rate

Also calls GetPTATReg() and GetTGCReg()

Parameters:
pointerto struct mlx_struct
Returns:
'1' if i2c error, '0' if ok.