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