Skip to content

Commit

Permalink
added emissivity
Browse files Browse the repository at this point in the history
  • Loading branch information
mlx-kva committed Sep 9, 2020
1 parent 6068392 commit f443fb9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
25 changes: 21 additions & 4 deletions mlx90632/mlx90632.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -51,15 +52,29 @@ 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()
self.read_status()
self.read_control()
self.read_calibration_data()


def read_calibration_data(self):

trim_version = 0
dsp_version = 0
cal_Ea = 74.0
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit f443fb9

Please sign in to comment.