34 #define POW10 10000000000LL 37 #define VERSION "test" 62 *ambient_new_raw = (int16_t)read_tmp;
67 *ambient_old_raw = (int16_t)read_tmp;
93 read = (int16_t)read_tmp;
99 read = read - (int16_t)read_tmp;
105 read = read - (int16_t)read_tmp;
111 read = (read + (int16_t)read_tmp) / 2;
117 read = read + (int16_t)read_tmp;
123 read = read + (int16_t)read_tmp;
125 if (read > 32767 || read < -32768)
128 *object_new_raw = (int16_t)read;
135 int32_t ret, start_measurement_ret;
142 if (start_measurement_ret < 0)
143 return start_measurement_ret;
145 if (start_measurement_ret == 19)
168 int32_t ret, start_measurement_ret;
172 if (start_measurement_ret < 0)
173 return start_measurement_ret;
190 kGb = ((double)Gb) / 1024.0;
192 VR_Ta = ambient_old_raw + kGb * (ambient_new_raw / (
MLX90632_REF_3));
197 int16_t ambient_old_raw, int16_t Ka)
201 kKa = ((double)Ka) / 1024.0;
203 VR_IR = ambient_old_raw + kKa * (ambient_new_raw / (
MLX90632_REF_3));
208 int32_t P_R, int32_t P_G, int32_t P_O, int16_t Gb)
210 double Asub, Bsub, Ablock, Bblock, Cblock, AMB;
214 Asub = ((double)P_T) / (double)17592186044416.0;
215 Bsub = AMB - ((double)P_R / (
double)256.0);
216 Ablock = Asub * (Bsub * Bsub);
217 Bblock = (Bsub / (double)P_G) * (double)1048576.0;
218 Cblock = (double)P_O / (
double)256.0;
220 return Bblock + Ablock + Cblock;
245 int32_t Ga, int32_t Fa, int32_t Fb, int16_t Ha, int16_t Hb,
248 double calcedGa, calcedGb, calcedFa, first_sqrt;
250 double KsTAtmp, Alpha_corr;
251 double Ha_customer, Hb_customer;
253 Ha_customer = Ha / ((double)16384.0);
254 Hb_customer = Hb / ((double)1024.0);
255 calcedGa = ((double)Ga * (prev_object_temp - 25)) / ((
double)68719476736.0);
256 KsTAtmp = (double)Fb * (TAdut - 25);
257 calcedGb = KsTAtmp / ((double)68719476736.0);
258 Alpha_corr = (((double)(Fa *
POW10)) * Ha_customer * (
double)(1.0 + calcedGa + calcedGb)) /
259 ((double)70368744177664.0);
260 calcedFa =
object / (emissivity * (Alpha_corr /
POW10));
262 first_sqrt = sqrt(calcedFa + TaTr4);
264 return sqrt(first_sqrt) - 273.15 - Hb_customer;
268 int32_t Ea, int32_t Eb, int32_t Ga, int32_t Fa, int32_t Fb,
269 int16_t Ha, int16_t Hb)
271 double kEa, kEb, TAdut;
278 kEa = ((double)Ea) / ((double)65536.0);
279 kEb = ((double)Eb) / ((double)256.0);
280 TAdut = (((double)ambient) - kEb) / kEa + 25;
282 TaTr4 = reflected + 273.15;
283 TaTr4 = TaTr4 * TaTr4;
284 TaTr4 = TaTr4 * TaTr4;
285 ta4 = TAdut + 273.15;
288 TaTr4 = TaTr4 - (TaTr4 - ta4) / tmp_emi;
291 for (i = 0; i < 5; ++i)
#define MLX90632_RAM_3(meas_num)
#define MLX90632_MEASUREMENT_TYPE_STATUS(mtyp_type)
Extract the measurement type from MTYP.
#define MLX90632_RAM_1(meas_num)
int32_t mlx90632_i2c_read(int16_t register_address, uint16_t *value)
Read the register_address value from the mlx90632.
#define MLX90632_MTYP_MEDICAL_BURST
#define MLX90632_CFG_MTYP_MASK
Meas select Mask.
#define MLX90632_REF_3
ResCtrlRef value of Channel 3.
#define MLX90632_MEASUREMENT_BURST_STATUS(mtyp_type)
Extract the measurement burst/continuous type from MTYP.
#define MLX90632_MTYP(reg_val)
Extract MTYP from Control register.
int32_t mlx90632_start_measurement_burst(void)
Trigger start of burst measurement for mlx90632.
int32_t mlx90632_set_meas_type(uint8_t type)
Switch the measurement type of the MLX90632.
#define MLX90632_RAM_2(meas_num)
#define MLX90632_PWR_STATUS_SLEEP_STEP
Pwrmode sleep step.
#define MLX90632_MTYP_MEDICAL
STATIC int32_t mlx90632_read_temp_object_raw_extended(int16_t *object_new_raw)
Read object raw values for the extended range based on mlx90632_start_measurement return value...
#define MLX90632_MTYP_EXTENDED
#define MLX90632_MTYP_EXTENDED_BURST
int32_t mlx90632_i2c_write(int16_t register_address, uint16_t value)
Write value to register_address of the mlx90632.
int32_t mlx90632_get_meas_type(void)
Get the current measurement type set in the MLX90632.
#define MLX90632_BURST_MEASUREMENT_TYPE(meas_type)
The MSBit is only used in the software to indicate burst type measurement.
static double mlx90632_calc_temp_object_iteration_extended(double prev_object_temp, int32_t object, double TAdut, double TaTr4, int32_t Ga, int32_t Fa, int32_t Fb, int16_t Ha, int16_t Hb, double emissivity)
Iterative calculation of object temperature.
#define MLX90632_PWR_STATUS_HALT
Pwrmode hold.
#define MLX90632_MTYP_STATUS(ctrl_val)
MLX90632 driver with virtual i2c communication.
#define MLX90632_CFG_PWR(ctrl_val)
Extract the PowerMode bits.
STATIC int32_t mlx90632_read_temp_ambient_raw_extended(int16_t *ambient_new_raw, int16_t *ambient_old_raw)
Read ambient raw old and new values for the extended range based on mlx90632_start_measurement return...
MLX90632 driver dependencies.
#define MLX90632_REF_12
ResCtrlRef value of Channel 1 or Channel 2.
double mlx90632_calc_temp_object_extended(int32_t object, int32_t ambient, double reflected, int32_t Ea, int32_t Eb, int32_t Ga, int32_t Fa, int32_t Fb, int16_t Ha, int16_t Hb)
Calculation of object temperature for the extended range.
double mlx90632_preprocess_temp_object_extended(int16_t object_new_raw, int16_t ambient_new_raw, int16_t ambient_old_raw, int16_t Ka)
Calculation of raw object output for the extended range.
int32_t mlx90632_read_temp_raw_extended(int16_t *ambient_new_raw, int16_t *ambient_old_raw, int16_t *object_new_raw)
Read raw ambient and object temperature for extended range.
int32_t mlx90632_addressed_reset(void)
Trigger system reset for mlx90632.
#define MLX90632_PWR_STATUS_CONTINUOUS
Pwrmode continuous.
double mlx90632_get_emissivity(void)
Read value of emissivity.
#define EINVAL
From linux errno.h.
#define MLX90632_CFG_PWR_MASK
PowerMode Mask.
#define MLX90632_REG_CTRL
Control Register address.
int32_t mlx90632_read_temp_raw_extended_burst(int16_t *ambient_new_raw, int16_t *ambient_old_raw, int16_t *object_new_raw)
Read raw ambient and object temperature for extended range sleeping step mode.
double mlx90632_preprocess_temp_ambient_extended(int16_t ambient_new_raw, int16_t ambient_old_raw, int16_t Gb)
Calculation of raw ambient output for the extended range.
double mlx90632_calc_temp_ambient_extended(int16_t ambient_new_raw, int16_t ambient_old_raw, int32_t P_T, int32_t P_R, int32_t P_G, int32_t P_O, int16_t Gb)
Calculation of ambient temperature for the extended range.
#define ETIMEDOUT
From linux errno.h.
int mlx90632_start_measurement(void)
Trigger start measurement for mlx90632.