From 7ca7abef85f95c1de68912720a48e8b8f759a93b Mon Sep 17 00:00:00 2001 From: Gijs Schoonderbeek <schoonderbeek@astron.nl> Date: Thu, 23 Feb 2023 15:08:24 +0100 Subject: [PATCH] Loss of lock circuit is working --- apsct_lib.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/apsct_lib.py b/apsct_lib.py index 47e5d96..f46f995 100644 --- a/apsct_lib.py +++ b/apsct_lib.py @@ -299,8 +299,8 @@ class PllClass: i2_c_io_device.write_bytes(0x06, 0x2C) # '0' is output i2_c_io_device.write_bytes(0x07, 0x00) # '0' is output ack, ret_value = i2_c_io_device.read_bytes(0x00, 1) - status_pll = int(ret_value) & 0x02 - if status_pll == 0x02: + status_pll = int(ret_value, 16) & 0x04 + if status_pll : self.lock = True stri = f"PLL {self.frequency} is in lock" else: @@ -319,13 +319,14 @@ class PllClass: i2_c_io_device_b = I2C(0x21, BUSNR=I2CBUSNR) i2_c_io_device_b.write_bytes(0x06, 0x2C) # '0' is output i2_c_io_device_b.write_bytes(0x07, 0xFF) # '0' is output - ack, ret_value = i2_c_io_device_b.read_bytes(0x01, 1) status_reg = int(ret_value, 16) - if (self.frequency == '200MHz') & ((status_reg & 0x10) > 0): - print("200MHz has lost lock") - if ((status_reg & 0x20) > 0) & (self.frequency == '160MHz'): - print("160MHz has last lock") + if (self.frequency == '200MHz'): + lol = (status_reg & 0x10) + else: + lol = (status_reg & 0x20) + if lol : + print(f"{self.frequency} has lost lock") ack, ret_value = i2_c_io_device_a.read_bytes(0x01, 1) old_reg = int(ret_value, 16) i2_c_io_device_a.write_bytes(0x03, (old_reg | 0x10)) # '0' is output @@ -651,12 +652,14 @@ def main(): if False: apsct.power(False) sleep(1) - apsct.power(True) - sleep(1) +# apsct.power(True) +# sleep(1) if False: apsct.pll_200.write_byte_pll(0x06, 0xA5) apsct.pll_200.write_byte_pll(0x5A, 0x01) apsct.pll_200.setup_pll() + apsct.pll_200.read_lol() + apsct.pll_200.read_lock() # apsct.pll_200.read_all_regs_pll() # apsct.sensors.read_all_voltages() -- GitLab