From c598bda22ab7d931d6081c03984e4532d1da9df3 Mon Sep 17 00:00:00 2001 From: Gijs Schoonderbeek <schoonderbeek@astron.nl> Date: Wed, 7 Dec 2022 15:14:36 +0100 Subject: [PATCH] Double check on hardware --- apspu_lib.py | 38 +++++++++++++++++++++++++++++++------- production_apspu.py | 12 +++++------- 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/apspu_lib.py b/apspu_lib.py index 39a47f5..4cb45a8 100644 --- a/apspu_lib.py +++ b/apspu_lib.py @@ -72,12 +72,18 @@ class ApspuClass: print("--------- \nProgram Pols\n---------") for pol in self.pols: 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]): + print(f"POL {pol.name:10} Error setting Vout, " + f"set to {VOUT_POLS[pol.name]} read back {vout}") + exit() pol.set_vout_ov_limit_pol(1.2*VOUT_POLS[pol.name]) + ov_out = pol.read_ov_limit() + if not (1.1*VOUT_POLS[pol.name] < ov_out < 1.3*VOUT_POLS[pol.name]): + print(f"POL {pol.name:10} Error setting output overvoltage" + f"set {1.2*VOUT_POLS[pol.name]} read back {ov_out}") + exit() pol.set_on_off_config() - if DEBUG: - pol.read_vout_set() - pol.read_ov_limit() - pol.read_uv_limit() pol.write_to_nvm() print("Done") @@ -92,6 +98,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) if check_ok: print("APSPU OK") else: @@ -173,7 +180,10 @@ class EepromClass: ret_value = self.read_eeprom(address=0, nof_bytes=len(value)) stri = "Wrote to EEPROM register 0x{2:x} : {0}, Read from EEPROM: {1}".format(value, ret_value, address) print(stri) - return True + if ret_value == value: + return True + else: + return False class PolClass: @@ -305,6 +315,9 @@ class PolClass: # if self.status: ret_ack, raw_value = self.pol_dev.read_bytes(LP_VIN, 2) + if not ret_ack: + self.iout=999 + return False if len(raw_value) < 4: raw_value = '0' + raw_value ret_value = [] @@ -312,6 +325,7 @@ class PolClass: ret_value.append(int(raw_value[2:], 16)) output_value = calc_lin_2bytes(ret_value) self.vin = output_value + return True def read_vout(self): # @@ -319,7 +333,13 @@ class PolClass: # if self.status: ret_ack, vout_mod = self.pol_dev.read_bytes(LP_VOUT_MODE, 1) + if not ret_ack: + self.vout=999 + return False ret_ack, raw_value = self.pol_dev.read_bytes(LP_VOUT, 2) + if not ret_ack: + self.vout=999 + return False vout_mod = int(vout_mod, 16) ret_value = [] ret_value.append(int(raw_value[:2], 16)) @@ -328,8 +348,10 @@ class PolClass: except: ret_value.append(0) self.vout = calc_lin_3bytes(ret_value, [vout_mod]) + return True else: self.vout = 999 + return False def read_ov_limit(self): # @@ -346,7 +368,8 @@ class PolClass: ret_value = int(raw_value[2:], 16) * 2**8 ret_value += int(raw_value[:2], 16) output_value = ret_value * 2**-11 - print(f"Output OV limit is set to: = {output_value:5.2f} V using hex value {raw_value}") + if DEBUG: + print(f"Output OV limit is set to: = {output_value:5.2f} V using hex value {raw_value}") return output_value def read_uv_limit(self): @@ -363,7 +386,8 @@ class PolClass: ret_value = int(raw_value[2:], 16) * 2**8 ret_value += int(raw_value[:2], 16) output_value = ret_value * 2**-11 - print(f"Output UV limit is set to: = {output_value:5.2f} V using hex value {raw_value}") + if DEBUG: + print(f"Output UV limit is set to: = {output_value:5.2f} V using hex value {raw_value}") return output_value else: return False diff --git a/production_apspu.py b/production_apspu.py index 824cf3d..6e4431c 100644 --- a/production_apspu.py +++ b/production_apspu.py @@ -38,12 +38,10 @@ sleep(5) # Wait for outputs to be stable on apspu.read_all() apspu.print_status() if apspu.check_apspu(): - apspu.apspu_on_off(False) - sleep(10) - apspu.read_all() - apspu.print_status() - apspu.apspu_on_off(True) apspu_id = "APSPU-" + sys.argv[1] serial = sys.argv[2] - apspu.eeprom.wr_rd_eeprom(apspu_id, address=0) - apspu.eeprom.wr_rd_eeprom(serial, address=0x20) + rw_ok = apspu.eeprom.wr_rd_eeprom(apspu_id, address=0) + if rw_ok: + rw_ok = apspu.eeprom.wr_rd_eeprom(serial, address=0x20) + if not rw_ok: + print("EEPROM Error") -- GitLab