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

Added first step in fan monitoring.

parent 79f8fefe
No related branches found
No related tags found
No related merge requests found
......@@ -24,6 +24,21 @@ LP_IOUT = 0x8C
###################################
EEPROM = 0x50
###################################
# FAN speed
###################################
MAX6620 = 0x52
REG_GLOBAL = 0x00
REG_TACH_1_MSP = 0x10
REG_TACH_1_LSP = 0x11
REG_TACH_2_MSP = 0x12
REG_TACH_2_LSP = 0x13
REG_TACH_3_MSP = 0x14
REG_TACH_3_LSP = 0x15
RUN_MONITOR = 0x80
######################
......@@ -46,4 +61,9 @@ def calc_lin_3bytes(data,mode):
expo = expo - 2**5
output = (data[1]*256 + data[0]) * 2**expo
return output
def tach(tach_msb, tach_lsb):
tach_pulse_per_revolution = 2
tach = (tach_msb*8) + (tach_lsb/32)
rpm = 60/(tach*tach_pulse_per_revolution)
return rpm
......@@ -42,6 +42,8 @@ class ApspuClass:
self.pols.append(PolClass(pol))
self.dev_i2c_eeprom = I2C(EEPROM)
self.dev_i2c_eeprom.bus_nr = I2CBUSNR
self.fanmonitoring = []
self.fanmonitoring.append(FanmonitorClass)
def write_eeprom(self, data=0x01):
#
......@@ -87,6 +89,7 @@ class ApspuClass:
for pol in self.pols:
pol.read_all()
return True
self.fanmonitoring.read_all()
def print_status(self):
#
......@@ -97,6 +100,7 @@ class ApspuClass:
pol.print_status()
self.wr_rd_eeprom()
return True
self.fanmonitoring.print_status()
......@@ -184,6 +188,48 @@ class PolClass:
stri += "temperature :{0: <5.2f} Deg C".format(self.temp)
print(stri)
class FanmonitorClass:
#
# Class to read all monitoring points Point of Load DC/DC converter
#
def __init__(self, name):
#
# All monitoring points Point of Load DC/DC converter
#
self.rpm = -1
self.fanmonitor_dev = I2C(MAX6620)
self.fanmonitor_dev.bus_nr = I2CBUSNR
ret_ack, ret_value = self.fanmonitor_dev.read_bytes(1)
if ret_ack < 1:
stri = " Device {0} at address 0x{1:X} not found".format("max6620", MAX6620)
print(stri)
self.status = False
else:
self.status = True
def set_active(self):
#
# Function to activate monitoring
#
self.fanmonitor_dev.write_bytes(REG_GLOBAL, RUN_MONITOR)
def read_all(self):
#
# Function to read speed
#
ret_ack, tach_msb = self.fanmonitor_dev.read_bytes(REG_TACH_1_MSP, 1)
ret_ack, tach_lsb = self.fanmonitor_dev.read_bytes(REG_TACH_1_LSP, 1)
self.rpm = tach(tach_msb, tach_lsb)
def print_status(self):
#
# Function to dump all monitoring points of the Point of Load DC/DC converter on the screen
#
if self.status:
stri = "FAN "
stri += "Speed :{0: <5.2f} V ".format(self.rpm)
print(stri)
def main():
#
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment