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

Register changes

parent 09609583
No related branches found
No related tags found
No related merge requests found
......@@ -122,7 +122,7 @@ def setup_pll() :
I2C_device.write_bytes(0x07, 0x00)
Write_byte_PLL(0x03, 0x08, PLL_addr)
Write_byte_PLL(0x04, 0xFF, PLL_addr) # CF disable not used outputs, 00 enable all
Write_byte_PLL(0x05, 0x97, PLL_addr)
Write_byte_PLL(0x05, 0xD7, PLL_addr)
Write_byte_PLL(0x06, 0xE0, PLL_addr) # cp inv = 0xF4 other 0xE4
Write_byte_PLL(0x07, 0x04, PLL_addr) # Divider R = 1 dec
Write_byte_PLL(0x08, 0x01, PLL_addr)
......@@ -251,6 +251,53 @@ def read_temp():
else:
print("Error reading tempeature")
def read_tacho():
MAX6620 = 0x52
REG_GLOBAL = 0x00
REG_TACH_MSP_REGS = [ 0x10, 0x12, 0x14]
REG_TACH_LSP_REGS = [ 0x11, 0x13, 0x15]
TACH_PERIODS = 16
TACH_COUNT_FREQ = 8192
FAN_TACHS = 1
RUN_MONITOR = 0x02
NOF_APS_FANS = 3
DEBUG=1
fanmonitor_dev = I2C(MAX6620)
fanmonitor_dev.bus_nr = I2CBUSNR
ret_ack, ret_value = fanmonitor_dev.read_bytes(1)
if ret_ack < 1:
stri = " Device {0} at address 0x{1:X} not found".format("MAX6620", MAX6620)
print(stri)
status = False
else:
if DEBUG:
stri = "Device {0} at address 0x{1:X} is found ".format("MAX6620", MAX6620)
print(stri)
ret_ack, reg_before = fanmonitor_dev.read_bytes(REG_GLOBAL, 1)
fanmonitor_dev.write_bytes(REG_GLOBAL, RUN_MONITOR)
ret_ack, reg_after = fanmonitor_dev.read_bytes(REG_GLOBAL, 1)
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 = int((math.log(TACH_PERIODS) / math.log(2))) << 5
for fan_cnt in range(NOF_APS_FANS):
fanmonitor_dev.write_bytes(0x02 + fan_cnt, 0x88)
fanmonitor_dev.write_bytes(0x06 + fan_cnt, fan_config_reg)
ret_ack, tach_msb = 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 = 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 = 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)
if CHECK_EEPROM :
wr_rd_eeprom()
......@@ -273,5 +320,7 @@ if READ_LOCK:
else:
print("Not locked --> PLL Error")
read_tacho()
if READ_SENSOR:
ccd_sensors()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment