Skip to content
Snippets Groups Projects
Commit f90fe7e6 authored by Gijs Schoonderbeek's avatar Gijs Schoonderbeek
Browse files

Fan monitor tested, working for EBM- 3218 J/2H3

parent b39362d9
Branches
No related tags found
No related merge requests found
......@@ -32,9 +32,9 @@ MAX6620 = 0x29
REG_GLOBAL = 0x00
REG_TACH_MSP_REGS = [ 0x10, 0x12, 0x14]
REG_TACH_LSP_REGS = [ 0x11, 0x13, 0x15]
TACH_PERIODS = 32
TACH_PERIODS = 16
TACH_COUNT_FREQ = 8192
FAN_TACHS = 2
FAN_TACHS = 1
RUN_MONITOR = 0x02
......
......@@ -30,7 +30,7 @@ else:
I2CBUSNR = 3
DEBUG = False
DEBUG = True #False
class ApspuClass:
#
......@@ -219,21 +219,27 @@ class FanmonitorClass:
if DEBUG:
stri = "Reg at address 0x{0} before : {1} and after write action {2}".format(REG_GLOBAL, reg_before, reg_after)
print(stri)
fan_config_reg = math.log2(TACH_PERIODS) << 5
for fan_cnt in range(NOF_APS_FANS)
fan_config_reg = int((math.log(TACH_PERIODS) / math.log(2))) << 5
for fan_cnt in range(NOF_APS_FANS):
self.fanmonitor_dev.write_bytes(0x02 + fan_cnt, 0x88)
self.fanmonitor_dev.write_bytes(0x06 + fan_cnt, fan_config_reg)
def read_(self, fan_nr):
def read_fan(self, fan_nr):
#
# Function to a single fan
#
ret_ack, tach_msb = self.fanmonitor_dev.read_bytes(REG_TACH_MSP_REGS[fan_nr], 1)
tach_msb = int(tach_msb, 16) & 0xFF
if tach_msb > 254:
if DEBUG :
tach_lsb = 255
tach = 99999
rpm = 0
else:
ret_ack, tach_lsb = self.fanmonitor_dev.read_bytes(REG_TACH_LSP_REGS[fan_nr], 1)
tach_lsb = int(tach_lsb, 16) & 0xE0
tach = tach_msb*16 + tach_lsb*8
rpm = (TACH_COUNT_FREQ*TACH_PERIODS*60)/(FAN_TACHS*tach)
tach = tach_msb*16 + tach_lsb/8
rpm = float((TACH_COUNT_FREQ*TACH_PERIODS*60))/(FAN_TACHS*tach)
if DEBUG:
stri = "MSP: {0}, LSB: {1}, TACH : {2}".format(tach_msb, tach_lsb, tach)
print(stri)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment