From 824d0c22893f2fb00d4f7ab1cc8db7d1c02bfb1f Mon Sep 17 00:00:00 2001 From: Gijs <schoonderbeek@astron.nl> Date: Thu, 16 May 2024 18:23:20 +0200 Subject: [PATCH] Update APSPU script for production test setup. Tested first 2 PTS boards --- APSPU_I2C.py | 11 +++++++-- apspu_lib.py | 66 +++++++++++++++++++++++++++++++++++++--------------- 2 files changed, 56 insertions(+), 21 deletions(-) diff --git a/APSPU_I2C.py b/APSPU_I2C.py index ca6f97e..2111f92 100644 --- a/APSPU_I2C.py +++ b/APSPU_I2C.py @@ -37,9 +37,15 @@ VOUT_POLS = {"CTR_LBA": 8.0, "CTR_RCU2_A": 5.60009765625, "CTR_RCU2_D": 3.2998046875} -IOUT_POLS = {"CTR_LBA": 0.2, +IOUT_POLS = {"CTR_LBA": 0.48, "CTR_RCU2_A": 0.6, - "CTR_RCU2_D": 0.2} + "CTR_RCU2_D": 0.61} + +STORE_PWD = {"CTR_LBA": 0x61, + "CTR_RCU2_A": 0x4B, + "CTR_RCU2_D": 0x35} + +MAX_TEMP = 110 LP_VIN = 0x88 LP_VOUT_MODE = 0x20 @@ -58,6 +64,7 @@ LP_ON_OFF_CONFIG = 0x02 LP_OPERATION = 0x01 LP_WRITE_PROTECT = 0x10 LP_STORE_DEFAULT_ALL = 0x12 +LP_OT_FAULT_LIMIT = 0x4F # # Central I2C Devices # diff --git a/apspu_lib.py b/apspu_lib.py index 21c4c9d..ce1bfd8 100644 --- a/apspu_lib.py +++ b/apspu_lib.py @@ -87,6 +87,8 @@ class ApspuClass: f"set {1.2*VOUT_POLS[pol.name]} read back {ov_out}") exit() pol.set_on_off_config() + print(f"Set max temp {MAX_TEMP} C") + pol.set_temp_limit_pol(MAX_TEMP) pol.on_off(True) pol.write_to_nvm() print("Done") @@ -98,7 +100,7 @@ class ApspuClass: # #print("--------- \nProgram Pols\n---------") for pol in self.pols: - print(f"Set Pol {pol.name} to {VOUT_POLS[pol.name]:4.2f} V") + print(f"Labview: Set Pol {pol.name} to {VOUT_POLS[pol.name]:4.2f} V") pol.set_vout_pol(VOUT_POLS[pol.name]) vout = pol.read_vout_set() if not (0.9*VOUT_POLS[pol.name] < vout < 1.1*VOUT_POLS[pol.name]): @@ -120,6 +122,8 @@ class ApspuClass: return returnstring exit() pol.set_on_off_config() + print(f"Set max temp {MAX_TEMP} C") + pol.set_temp_limit_pol(MAX_TEMP) pol.on_off(True) pol.write_to_nvm() returnstring = ("Programming OK") @@ -157,7 +161,7 @@ class ApspuClass: for pol in self.pols: check_ok = check_ok & pol.check_pol() check_ok = check_ok & self.fans.check_fans() - check_ok = check_ok & self.eeprom.wr_rd_eeprom(value="PROD_CHECK", address=0x30) + check_ok = check_ok & self.eeprom.wr_rd_eeprom(data="PROD_CHECK", address=0x30) if check_ok: print("APSPU OK") else: @@ -328,7 +332,7 @@ class PolClass: if DEBUG: ret_ack, raw_value = self.pol_dev.read_bytes(LP_ON_OFF_CONFIG, 1) print(f"Current setting ON/OFF register 0x{int(raw_value, 16):02x}") - on_off_bit = not 1 << 0 + on_off_bit = 0 << 0 polarity_pin = 1 << 1 use_external = 0 << 2 use_soft = 1 << 3 @@ -394,6 +398,24 @@ class PolClass: ret_ack = self.pol_dev.write_bytes(LP_VOUT_OV_LIMIT, wr_data) return ret_ack + def set_temp_limit_pol(self, value): + # + # Function to set the temperature limit of the DC/DC converter + # + # value is the max temperature + # return I2C ack + # + ret_ack = False + if self.status: + wr_value = f"{value:02x}" + if DEBUG: + print(f"Calculated wr_value is 0x{wr_value}") + wr_data = [] + wr_data.append(value) + wr_data.append(0) + ret_ack = self.pol_dev.write_bytes(LP_OT_FAULT_LIMIT, wr_data) + return ret_ack + def write_to_nvm(self): # # Function to write the POL's registers to NVM memory @@ -401,15 +423,17 @@ class PolClass: # return is always True # print(f"Store to NVM for POL {self.name}") +# self.on_off(on=False) if True: - ret_ack = self.pol_dev.write_pointer(0x15) - sleep(1) - else: + ret_ack = self.pol_dev.write_bytes(0x10, 0x00) + sleep(2) + ret_ack = self.pol_dev.write_bytes(0x15, STORE_PWD[self.name]) + sleep(2) + else: #Pi only self.pol_dev.close() - command = f"i2cset -y 1 0x{CTR_POLS[self.name]:02X} 0x15 cp" + command = f"i2ctransfer -y 1 w1@{CTR_POLS[self.name]:02X} 0x15" os.system(command) - os.system(command) - self.pol_dev.open() + self.pol_dev.open_i2c() return True def read_vin(self): @@ -744,7 +768,7 @@ def reset_dc_dc_converters(): def read_qr(): apspu = EepromClass() print("Read QR code from EEPROM") - return apspu.read_eeprom_lv(address=0x20, nof_bytes=17) + return apspu.read_eeprom_lv(address=0x20, nof_bytes=18) def read_version(): apspu = EepromClass() @@ -779,18 +803,22 @@ def main(): # # Function to test the class, read all info and dump on the screen # - user = "Henri" + user = "LabView" +# user = "Gijs" apspu = ApspuClass() if user == "Gijs": - apspu.apspu_on_off(False) - sleep(5) - apspu.set_pols() apspu.apspu_on_off(True) - sleep(10) + sleep(2) +# apspu.set_pols_lv() +# temp = input("Switch dip's and press enter") +# apspu.apspu_on_off(True) +# sleep(10) +# apspu.eeprom.wr_rd_eeprom(data="APSPU-rev3.0", address=0) + apspu.eeprom.wr_rd_eeprom(data="APSPU-202419-00002", address=0x20) apspu.read_all() apspu.print_status() - apspu.check_apspu() - apspu.eeprom.wr_rd_eeprom(value="APSPU-2", address=0) + apspu.apspu_on_off(False) +# apspu.check_apspu() elif user == "Henri": apspu_off() program_dc_dc_converters() @@ -801,10 +829,10 @@ def main(): current(pol_cnt) for fan_cnt in range(3): fan_speed(fan_cnt) - print (write_qr("APSPU-22091-00100")) + print (write_qr("APSPU-202419-0001")) qr = read_qr() print (qr) - print (write_qr("APSPU-rev2.0")) + print (write_qr("APSPU-rev3.0")) print(read_version()) print(read_id()) apspu_off() -- GitLab