From f443fb94664895f1948ff3c61c1641adb20168b2 Mon Sep 17 00:00:00 2001 From: kva Date: Wed, 9 Sep 2020 14:12:47 -0700 Subject: [PATCH] added emissivity --- README.md | 3 --- mlx90632/mlx90632.py | 25 +++++++++++++++++++++---- setup.py | 2 +- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 7828182..48d3f5c 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,6 @@ | FTDI(FT2232H) | 1.1.0 | 1.1.0 | 1.1.0 | 1.1.0 | | I2C-bus(40pin) | N/A | N/A | 1.1.0 | 1.1.0 | - -# mlx90632-driver - ## Intro This python driver for MLX90632 aims to facilitate the interfacing on a PC. diff --git a/mlx90632/mlx90632.py b/mlx90632/mlx90632.py index ff4264e..aa052c5 100644 --- a/mlx90632/mlx90632.py +++ b/mlx90632/mlx90632.py @@ -22,6 +22,7 @@ def __init__(self, hw, i2c_addr=0x3A): self.reload_calibration_data_on_brownout = True self.wait_new_data_until_end_of_full_cycle = False self.hw = None + self.emissivity = 1.0 if hw is None or hw == 'auto': hw = "mlx://evb:90632/1" if isinstance(hw, str): @@ -51,6 +52,20 @@ def __init__(self, hw, i2c_addr=0x3A): atexit.register(self.disconnect) + @property + def emissivity(self): + return self._emissivity + + + @emissivity.setter + def emissivity(self, emissivity): + if emissivity < 0: + raise ValueError("emssivity range is 0..1; {} given".format (emissivity)) + if emissivity > 1: + raise ValueError("emssivity range is 0..1; {} given".format (emissivity)) + self._emissivity = emissivity + + def init(self): self.read_status() self.clear_new_data() @@ -58,8 +73,8 @@ def init(self): self.read_control() self.read_calibration_data() + def read_calibration_data(self): - trim_version = 0 dsp_version = 0 cal_Ea = 74.0 @@ -138,7 +153,6 @@ def read_calibration_data(self): EE_cal_VddMonOffset -= 2**16 cal_VddMonOffset = EE_cal_VddMonOffset - self.calib_data = { 'cal_Ea' : cal_Ea, 'cal_Eb' : cal_Eb, @@ -166,26 +180,29 @@ def read_calibration_data(self): self.set_brownout(use_cache=False) return self.calib_data + def set_vdd(self, vdd): """Set Vdd of the sensor""" # if supported... if callable(getattr(self.hw, 'set_vdd', None)): self.hw.set_vdd(vdd) + def get_refresh_rate(self): return self.frame_rate + def clear_error(self): if callable(getattr(self.hw, 'clear_error', None)): self.hw.clear_error(self.i2c_addr) + def write_ee_refresh_rate(self, refresh_rate, unit='Hz'): """ Write the refresh rate to EEPROM :param frame_rate: the new frame rate for the sensor :param unit: 'Hz' or 'code'. """ - refresh_rate_code = refresh_rate if unit == 'Hz': refresh_rate_code = 2 @@ -426,7 +443,7 @@ def do_compensation(self, raw_data): # iterate 3 times: for i in range (3): - Za = Ha * Fa * (1 + Ga * (TO_computed - 25) + Fb * (TA_computed - 25)) + Za = self.emissivity * Ha * Fa * (1 + Ga * (TO_computed - 25) + Fb * (TA_computed - 25)) TO_computed = (Yb/Za + (TA_computed+273.15)**4)**0.25 - 273.15 - Hb return (TA_computed, TO_computed) diff --git a/setup.py b/setup.py index ff330a1..7461ce6 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ import sys import platform -version='1.1.1' +version='1.2.0' requires = ['bincopy>=17.8.0', 'pyftdi>=0.51.2',