From fc63aa0d93ff257bfc66fd5d3bd289d375cda8d3 Mon Sep 17 00:00:00 2001 From: Gijs <Schoonderbeek> Date: Tue, 27 Jun 2023 19:38:24 +0200 Subject: [PATCH] PLL lock working but need more work --- ccd_lib.py | 36 ++++++++++++++++++++---------------- set_ccd.py | 4 +++- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/ccd_lib.py b/ccd_lib.py index 5de8317..5cfdb90 100644 --- a/ccd_lib.py +++ b/ccd_lib.py @@ -41,7 +41,7 @@ class CcdClass: self.frequency = "10 MHz" self.eeprom = EepromClass() self.pll = PllClass() - self.sensors = ApsctSensors() + self.sensors = CcdSensors() self.ccd_id = CcdId() def power(self, state): @@ -188,13 +188,19 @@ class PllClass: if DEBUG: print(f"Divider P : {divider_p}, Divider A : {divider_a}, Divider B : {divider_b}") charge_pump_current = 3 # 0 is low (0.6 mA), 7 is high (4.8 mA) - self.write_byte_pll(0x04, (divider_a & 0x3F)) - self.write_byte_pll(0x05, (divider_b & 0x1F00) >> 8) - self.write_byte_pll(0x06, (divider_b & 0x00FF)) +# self.write_byte_pll(0x04, (divider_a & 0x3F)) + self.write_byte_pll(0x04, 0x00) # (divider_a & 0x3F)) +# self.write_byte_pll(0x05, (divider_b & 0x1F00) >> 8) + self.write_byte_pll(0x05, 0x00) # (divider_b & 0x1F00) >> 8) +# self.write_byte_pll(0x06, (divider_b & 0x00FF)) + self.write_byte_pll(0x06, 0x01) # (divider_b & 0x00FF)) self.write_byte_pll(0x07, 0x00) # No LOR - self.write_byte_pll(0x08, 0x3B) # Charge pump normal + Status bit - self.write_byte_pll(0x09, (charge_pump_current & 0x7) << 4) - self.write_byte_pll(0x0A, 0x00) # Fixed Divide 1 +# self.write_byte_pll(0x08, 0x3B) # Charge pump normal + Status bit + self.write_byte_pll(0x08, 0x43) # Charge pump normal + Status bit +# self.write_byte_pll(0x09, (charge_pump_current & 0x7) << 4) + self.write_byte_pll(0x09, 0x50) # (charge_pump_current & 0x7) << 4) +# self.write_byte_pll(0x0A, 0x00) # Fixed Divide 1 + self.write_byte_pll(0x0A, 0x40) # Fixed Divide 1 self.write_byte_pll(0x0B, 0x00) self.write_byte_pll(0x0C, 0x01) self.write_byte_pll(0x45, 0x00) # CLK2 as feedback clock input @@ -226,7 +232,7 @@ class PllClass: # i2_c_io_device = I2C(0x20, BUSNR=I2CBUSNR) i2_c_io_device.write_bytes(0x06, 0x2C) # '0' is output - i2_c_io_device.write_bytes(0x07, 0x00) # '0' is output + i2_c_io_device.write_bytes(0x07, 0x0F) # '0' is output ack, ret_value = i2_c_io_device.read_bytes(0x00, 1) status_pll = int(ret_value, 16) & 0x04 if status_pll: @@ -244,7 +250,7 @@ class PllClass: # i2_c_io_device_a = I2C(0x20, BUSNR=I2CBUSNR) i2_c_io_device_a.write_bytes(0x06, 0x2C) # '0' is output - i2_c_io_device_a.write_bytes(0x07, 0x00) # '0' is output + i2_c_io_device_a.write_bytes(0x07, 0x0F) # '0' is output 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 @@ -337,7 +343,7 @@ class CcdSensors: self.power_supplies = list(CCD_I2C.PWR_LOCATIONS.keys()) self.voltages = {} self.temperature = 9999 - self.dev_i2c_sensor.write_bytes(0xB0, 0xB8) +# self.dev_i2c_sensor.write_bytes(0xB0, 0xB8) def ccd_sensors(self): # @@ -478,7 +484,7 @@ class CcdSensors: -class CcdtId: +class CcdId: # # Class to check ID pins # @@ -523,15 +529,13 @@ def main(): sleep(1) Ccd.power(True) sleep(1) - if False: - Ccd.pll.write_byte_pll(0x06, 0xA5) - Ccd.pll.write_byte_pll(0x5A, 0x01) Ccd.pll.setup_pll() - Ccd.pll.read_lol() +# Ccd.pll.read_lol() Ccd.pll.read_lock() Ccd.pll.read_all_regs_pll() Ccd.sensors.check_values() - +# Ccd.eeprom.wr_rd_eeprom() + Ccd.ccd_id.check_id() if __name__ == "__main__": main() diff --git a/set_ccd.py b/set_ccd.py index 63fcea7..9809600 100644 --- a/set_ccd.py +++ b/set_ccd.py @@ -145,6 +145,7 @@ if SET_PLL : Write_byte_PLL(0x05, 0xF0) Write_byte_PLL(0x06, 0x40) # cp inv = 0xF4 other 0xE4 Write_byte_PLL(0x07, 0x04) # Divider R = 1 dec + Read_byte_PLL(0x07, 2) Write_byte_PLL(0x08, 0x01) Write_byte_PLL(0x07, 0x00) # Write_byte_PLL(0x09, 0x10) # reset @@ -168,7 +169,8 @@ if READ_LOCK: print("Not locked --> PLL Error") if READ_ALL: - Read_byte_PLL(0x00, nof_bytes = 23) + for cnt in range(32): + Read_byte_PLL(cnt, nof_bytes = 1) if UPDATE_PLL: -- GitLab