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

start classification rd_unb2.py

parent deb7e310
No related branches found
No related tags found
1 merge request!2Modified the scripts to run on Raspberry Pi.
...@@ -13,6 +13,13 @@ LOC_POWER_TR_T = 0x0F ...@@ -13,6 +13,13 @@ LOC_POWER_TR_T = 0x0F
LOC_POWER_BAT = 0x10 LOC_POWER_BAT = 0x10
LOC_POWER_IO = 0x11 LOC_POWER_IO = 0x11
LOC_POLS = {"LOC_POWER_CORE" : 0x01,
"LOC_POWER_ERAM" : 0x0D,
"LOC_POWER_TR_R" : 0x0E,
"LOC_POWER_TR_T" : 0x0F,
"LOC_POWER_BAT" : 0x10,
"LOC_POWER_IO" : 0x11}
CTR_POWER_S_1V0 = 0x0E CTR_POWER_S_1V0 = 0x0E
CTR_POWER_S_1V2 = 0x0F CTR_POWER_S_1V2 = 0x0F
CTR_POWER_CLK = 0x0D CTR_POWER_CLK = 0x0D
...@@ -46,7 +53,14 @@ CTRL_POWER = 0x10 ...@@ -46,7 +53,14 @@ CTRL_POWER = 0x10
# Front panel LED # Front panel LED
################ ################
LED_DRIVER = 0x41 LED_DRIVER = 0x41
LED_COLORS = {"red": 0x06, "blue": 0x05, "green" : 0x03, "magenta": 0x04, "yellow": 0x02, "cyaan": 0x01, "white": 0x00, "black" :0x07} LED_COLORS = {"red": 0x06,
"blue": 0x05,
"green" : 0x03,
"magenta": 0x04,
"yellow": 0x02,
"cyaan": 0x01,
"white": 0x00,
"black" :0x07}
################ ################
# Node I2C switch # Node I2C switch
......
...@@ -15,6 +15,59 @@ else: ...@@ -15,6 +15,59 @@ else:
from UniBoard2_I2C import * from UniBoard2_I2C import *
I2CBUSNR=3 I2CBUSNR=3
class c_pol:
def __init__(self, name):
self.name = name
self.vout
self.iout
self.temp
self.pol_dev = I2C(LOC_POLS[name])
self.pol_dev.bus = I2CBUSNR
ret_ack, ret_value = self.pol_dev.read_bytes(0)
if ret_ack < 1:
print("no device found")
else:
def read_vout(self):
sleep(0.1)
ret_ack, vout_mod = self.pol_dev.read_bytes(LP_VOUT_MODE, 1)
sleep(0.1)
ret_ack, raw_value = self.pol_dev.read_bytes(LP_VOUT, 2)
vout_mod = int(vout_mod,16)
ret_value = []
ret_value.append(int(raw_value[:2], 16))
ret_value.append(int(raw_value[2:], 16))
self.vout = calc_lin_3bytes(ret_value, [vout_mod])
def read_iout(self):
sleep(0.1)
ret_ack, raw_value = self.pol_dev.read_bytes(LP_IOUT, 2)
ret_value=[]
ret_value.append(int(raw_value[:2],16))
ret_value.append(int(raw_value[2:],16))
self.iout = calc_lin_2bytes(ret_value)
def read_temp(self):
sleep(0.1)
ret_ack,raw_value = self.pol_dev.read_bytes(LP_temp, 2)
ret_value=[]
ret_value.append(int(raw_value[:2],16))
ret_value.append(int(raw_value[2:],16))
self.temp = calc_lin_2bytes(ret_value)
def read_all(self):
self.read_vout()
self.read_iout()
self.read_temp()
def print_status(self):
self.read_all()
stri = "POL: " + self.name + " "
stri += "Output voltage :{0: <5.2f} V ".format(self.vout)
stri += "Output Current :{0: <5.2f} A ".format(self.iout)
stri += "temperature :{0: <5.2f} Deg C".format(self.temp)
print(stri)
def rw_eeprom(value=0xAB): def rw_eeprom(value=0xAB):
I2C_eeprom = I2C(EEPROM) I2C_eeprom = I2C(EEPROM)
...@@ -179,3 +232,6 @@ else: ...@@ -179,3 +232,6 @@ else:
for node_cnt in range(4): for node_cnt in range(4):
read_pol(node_cnt, LOC_POWER_CORE) read_pol(node_cnt, LOC_POWER_CORE)
read_pol(-1,0x01) read_pol(-1,0x01)
polletje = c_pol(LOC_POWER_CORE)
polletje.print_status()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment