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

small modification to get is working on HW

parent 8ecf836e
No related branches found
No related tags found
1 merge request!3Apsct production
...@@ -26,7 +26,7 @@ else: ...@@ -26,7 +26,7 @@ else:
I2CBUSNR = 5 I2CBUSNR = 5
sleep_time = 0.15 sleep_time = 0.15
DEBUG = False
class ApsctClass: class ApsctClass:
# #
...@@ -96,6 +96,9 @@ class ApsctClass: ...@@ -96,6 +96,9 @@ class ApsctClass:
self.power(False) self.power(False)
def check_apsct(self): def check_apsct(self):
#
# Check voltages, temp and lock on APSCT
#
result = self.sensors.check_values() result = self.sensors.check_values()
if self.frequency == "200MHz": if self.frequency == "200MHz":
self.pll_200.read_lock() self.pll_200.read_lock()
...@@ -129,11 +132,12 @@ class PllClass: ...@@ -129,11 +132,12 @@ class PllClass:
# Write Byte to the PLL # Write Byte to the PLL
# #
pll_rw = 0x00 # 0 for write, 1 for read pll_rw = 0x00 # 0 for write, 1 for read
if DEBUG:
stri = "Write to address : 0x{1:{fill}2x} value 0x{0:{fill}2x}".format(wr_data, reg_address, fill='0') stri = "Write to address : 0x{1:{fill}2x} value 0x{0:{fill}2x}".format(wr_data, reg_address, fill='0')
print(stri) print(stri)
self.dev_i2c_pll.write_bytes(0x06, 0x2C) self.dev_i2c_pll.write_bytes(0x06, 0x2C)
if DEBUG:
rd_bytes = self.dev_i2c_pll.read_bytes(0x06, 1) rd_bytes = self.dev_i2c_pll.read_bytes(0x06, 1)
if DEBUG:
stri = "IO expander wrote 0x{0:x}, read 0x{1}".format(0x2C, rd_bytes[1]) stri = "IO expander wrote 0x{0:x}, read 0x{1}".format(0x2C, rd_bytes[1])
print(stri) print(stri)
data = (reg_address << 9) + (pll_rw << 8) + wr_data data = (reg_address << 9) + (pll_rw << 8) + wr_data
...@@ -188,6 +192,7 @@ class PllClass: ...@@ -188,6 +192,7 @@ class PllClass:
# #
# Set registers on the PLL # Set registers on the PLL
# #
print(f"Setup PPL {self.frequency}")
self.dev_i2c_pll.write_bytes(0x07, 0x00) self.dev_i2c_pll.write_bytes(0x07, 0x00)
if self.frequency == '160MHz': if self.frequency == '160MHz':
self.dev_i2c_pll.write_bytes(0x03, 0x08) self.dev_i2c_pll.write_bytes(0x03, 0x08)
...@@ -367,17 +372,18 @@ class ApsctSensors: ...@@ -367,17 +372,18 @@ class ApsctSensors:
# #
# return result, True when OK, False in case of error # return result, True when OK, False in case of error
# #
print("Check power sensor values")
result = True result = True
self.read_all_voltages() self.read_all_voltages()
self.read_temp() self.read_temp()
for pwr in self.power_supplies: for pwr in self.power_supplies:
expected = APSCT_I2C.PWR_VOUT[pwr] expected = APSCT_I2C.PWR_VOUT[pwr]
if 0.9*expected > self.voltages[pwr] > 1.1*expected: if not (0.9*expected < self.voltages[pwr] < 1.1*expected):
result = False result = False
print(f"Error {pwr} expected {expected} V read {self.voltages[pwr]} V") print(f"Error: {pwr: <9} expected: {expected} V read: {self.voltages[pwr]:4.2f} V")
if 15 > self.temperature > 50: if not (15 < self.temperature < 50):
result = False result = False
print(f"Error temperature read {self.temperature} °C") print(f"Error temperature read {self.temperature:4.2f} °C")
return result return result
def read_voltage(self, input_channel=0): def read_voltage(self, input_channel=0):
...@@ -394,7 +400,7 @@ class ApsctSensors: ...@@ -394,7 +400,7 @@ class ApsctSensors:
if DEBUG: if DEBUG:
stri = "Word to select sens input is 0x{0:x}".format(channel_select_word) stri = "Word to select sens input is 0x{0:x}".format(channel_select_word)
print(stri) print(stri)
sleep(0.1) sleep(0.2)
self.dev_i2c_sensor.write_bytes(channel_select_word, 0xB8) self.dev_i2c_sensor.write_bytes(channel_select_word, 0xB8)
sleep(0.5) sleep(0.5)
ret_ack, ret_value = self.dev_i2c_sensor.read_last_reg(3) ret_ack, ret_value = self.dev_i2c_sensor.read_last_reg(3)
...@@ -407,6 +413,7 @@ class ApsctSensors: ...@@ -407,6 +413,7 @@ class ApsctSensors:
steps = (int(ret_value, 16) & 0x1FFFFF) >> 6 steps = (int(ret_value, 16) & 0x1FFFFF) >> 6
voltage = one_step * steps voltage = one_step * steps
voltage = ((4.7+2.2)/2.2)*2*voltage voltage = ((4.7+2.2)/2.2)*2*voltage
if DEBUG:
string = "Voltage sens line {1} is {0:.4f} V".format(voltage, input_channel) string = "Voltage sens line {1} is {0:.4f} V".format(voltage, input_channel)
print(string) print(string)
return voltage return voltage
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment