diff --git a/pypcc/config/APSPUTR.yaml b/pypcc/config/APSPUTR.yaml index c8cbdfc9de0e9869f6f0af3a6d631aa727905783..662ef6449a1a2d043c643a645629d2520e9a5a24 100644 --- a/pypcc/config/APSPUTR.yaml +++ b/pypcc/config/APSPUTR.yaml @@ -3,13 +3,22 @@ description: "1234" drivers: - name: I2C - type: i2c_smbus + type: i2c_switch_smb parameters: [4] #I2C port number + devreg: [0x70] + - name: I2C_PU - type: i2c_dev #I2C devices + type: i2c_array parent: I2C + parameters: [0,1] #lookup table + I2Ccut: 10 status: APSPUTR_I2C_error +# - name: I2C_PU +# type: i2c_dev #I2C devices +# parent: I2C +# status: APSPUTR_I2C_error + #This is the I2C devices in the RCU device_registers: - name: ROM @@ -75,6 +84,7 @@ variables: driver: I2C_PU rw: ro #server RW variable, not linked to IO dtype: uint8 + dim: 2 - name: APSPUTR_monitor_rate description: Monitor rate in seconds @@ -93,6 +103,7 @@ variables: width: 32 rw: ro dtype: uint32 + dim: 2 - name: APSPU_PCB_version description: Version number @@ -101,6 +112,7 @@ variables: width: 0x100 #32 characters rw: ro dtype: string + dim: 2 - name: APSPU_PCB_number description: PCB number @@ -109,6 +121,7 @@ variables: width: 0x100 #32 characters rw: ro dtype: string + dim: 2 - name: [APSPU_LBA_VOUT,APSPU_RCU2A_VOUT,APSPU_RCU2D_VOUT] description: Output voltage (V) @@ -120,6 +133,7 @@ variables: endian: "<" scale: 4.8828e-4 #2^-11 monitor: true + dim: 2 - name: [APSPU_LBA_IOUT,APSPU_RCU2A_IOUT,APSPU_RCU2D_IOUT] description: Output current (A) @@ -130,6 +144,7 @@ variables: dtype: double scale: smbus_2bytes_to_float monitor: true + dim: 2 - name: [APSPU_LBA_TEMP,APSPU_RCU2A_TEMP,APSPU_RCU2D_TEMP] description: DC-DC converter temperature (Celsius) @@ -140,6 +155,7 @@ variables: dtype: double scale: smbus_2bytes_to_float monitor: true + dim: 2 - name: [APSPU_FAN1_RPM,APSPU_FAN2_RPM,APSPU_FAN3_RPM] description: FAN speed in RPM. @@ -153,6 +169,7 @@ variables: scale: 4.7684e-7 #FAN_TACHS/TACH_COUNT_FREQ/TACH_PERIODS = 1/8192/16 /16 (bitoffset=0) convert_unit: period2RPM monitor: true + dim: 2 methods: - name: APSPUTR_Init #Called after startup to load. Should have all stored registers diff --git a/pypcc/config/APSPUTR_1.yaml b/pypcc/config/APSPUTR_1.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c8cbdfc9de0e9869f6f0af3a6d631aa727905783 --- /dev/null +++ b/pypcc/config/APSPUTR_1.yaml @@ -0,0 +1,177 @@ +1version: "1.0" +description: "1234" + +drivers: + - name: I2C + type: i2c_smbus + parameters: [4] #I2C port number + - name: I2C_PU + type: i2c_dev #I2C devices + parent: I2C + status: APSPUTR_I2C_error + +#This is the I2C devices in the RCU +device_registers: + - name: ROM + address: 0x50 + driver: I2C_PU + registers: + - name: ID + description: Random + address: 0xfc + - name: Version + description: Set in production + address: 0 + - name: Serial + address: 0x20 + + - name: POL_LBA + address: 0x3C + driver: i2c_smbus + registers: + - { name: "TEMP", address: 0x8D, crc: True} + - { name: "VIN" , address: 0x88, crc: True} + - { name: "VOUT", address: 0x8B, crc: True} + - { name: "IOUT", address: 0x8C, crc: True} + - name: POL_RCU2A + address: 0x3D + driver: i2c_smbus + registers: + - { name: "TEMP", address: 0x8D, crc: True} + - { name: "VIN" , address: 0x88, crc: True} + - { name: "VOUT", address: 0x8B, crc: True} + - { name: "IOUT", address: 0x8C, crc: True} + - name: POL_RCU2D + address: 0x3E + driver: i2c_smbus + registers: + - { name: "TEMP", address: 0x8D, crc: True} + - { name: "VIN" , address: 0x88, crc: True} + - { name: "VOUT", address: 0x8B, crc: True} + - { name: "IOUT", address: 0x8C, crc: True} + + + - name: MAX + description: MAX6620 fan speed controller + address: 0x29 + driver: I2C_PU + registers: + - { name: GLOBAL, address: 0x00} + - { name: TACH1, address: 0x10} + - { name: TACH2, address: 0x12} + - { name: TACH3, address: 0x14} + - { name: r2, address: 0x2} + - { name: r3, address: 0x3} + - { name: r4, address: 0x4} + - { name: r5, address: 0x5} + - { name: r6, address: 0x6} + - { name: r7, address: 0x7} + - { name: r8, address: 0x8} + + +variables: + - name: APSPUTR_I2C_error + description: 0=Good, >0 I2C communication error + driver: I2C_PU + rw: ro #server RW variable, not linked to IO + dtype: uint8 + + - name: APSPUTR_monitor_rate + description: Monitor rate in seconds + rw: variable + dtype: uint8 + + - name: APSPUTR_translator_busy + description: True when I2C line busy + rw: ro #server variable, not linked to IO + dtype: boolean + + - name: APSPU_PCB_ID + description: Unique PCB ID + driver: I2C_PU + devreg: ROM.ID + width: 32 + rw: ro + dtype: uint32 + + - name: APSPU_PCB_version + description: Version number + driver: I2C_PU + devreg: ROM.Version + width: 0x100 #32 characters + rw: ro + dtype: string + + - name: APSPU_PCB_number + description: PCB number + driver: I2C_PU + devreg: ROM.Serial + width: 0x100 #32 characters + rw: ro + dtype: string + + - name: [APSPU_LBA_VOUT,APSPU_RCU2A_VOUT,APSPU_RCU2D_VOUT] + description: Output voltage (V) + driver: I2C_PU + devreg: [POL_LBA.VOUT,POL_RCU2A.VOUT,POL_RCU2D.VOUT] + width: 16 + rw: ro + dtype: double + endian: "<" + scale: 4.8828e-4 #2^-11 + monitor: true + + - name: [APSPU_LBA_IOUT,APSPU_RCU2A_IOUT,APSPU_RCU2D_IOUT] + description: Output current (A) + driver: I2C_PU + devreg: [POL_LBA.IOUT,POL_RCU2A.IOUT,POL_RCU2D.IOUT] + width: 16 + rw: ro + dtype: double + scale: smbus_2bytes_to_float + monitor: true + + - name: [APSPU_LBA_TEMP,APSPU_RCU2A_TEMP,APSPU_RCU2D_TEMP] + description: DC-DC converter temperature (Celsius) + driver: I2C_PU + devreg: [POL_LBA.TEMP,POL_RCU2A.TEMP,POL_RCU2D.TEMP] + width: 16 + rw: ro + dtype: double + scale: smbus_2bytes_to_float + monitor: true + + - name: [APSPU_FAN1_RPM,APSPU_FAN2_RPM,APSPU_FAN3_RPM] + description: FAN speed in RPM. + driver: I2C_PU + devreg: [MAX.TACH1,MAX.TACH2,MAX.TACH3] +# bitoffset: 5 + width: 16 + rw: ro + dtype: double +# scale: 1.52588e-5 #FAN_TACHS/TACH_COUNT_FREQ/TACH_PERIODS = 1/8192/16 *2 (bitoffset=5) - not working correctly + scale: 4.7684e-7 #FAN_TACHS/TACH_COUNT_FREQ/TACH_PERIODS = 1/8192/16 /16 (bitoffset=0) + convert_unit: period2RPM + monitor: true + +methods: + - name: APSPUTR_Init #Called after startup to load. Should have all stored registers + driver: I2C_PU + debug: True + instructions: + - APSPU_PCB_ID : Update + - APSPU_PCB_version : Update + - APSPU_PCB_number : Update + - APSPU_FAN_monitor_on : 0 + + - name: APSPU_FAN_monitor_on + description: Setup the FAN monitor. Called automatically on power-on. + driver: I2C_PU + instructions: + - MAX.GLOBAL : 0x02 #Run monitor + - MAX.r2 : 0x88 + - MAX.r6 : 0x80 # int((math.log(TACH_PERIODS{16}) / math.log(2))) << 5, + - MAX.r3 : 0x88 + - MAX.r7 : 0x80 + - MAX.r4 : 0x88 + - MAX.r8 : 0x80 diff --git a/pypcc/config/RECVTR_HB.yaml b/pypcc/config/RECVTR_HB.yaml index 3fb4e84a694a652c9061b95e845494715bdd2e62..7a764b57784056eb4569a4533d56ad6f6df93a72 100644 --- a/pypcc/config/RECVTR_HB.yaml +++ b/pypcc/config/RECVTR_HB.yaml @@ -623,6 +623,7 @@ variables: dim2: [3,32] mask: ANT_mask read_parallel: all + disable_autoreadback: True - name: RCU_DTH_PWR description: RCU Dither source power (dBFS). Range -25 to -4. @@ -772,10 +773,10 @@ methods: # - IO3.GPIO2: Update - IO3.CONF1: Update - RCU_update: 0 - - RCU_ADC_locked: Update #check if not also in RCU_update - - RCU_ADC_sync: Update #disabled for testing + - RCU_ADC_locked: Update_background #check if not also in RCU_update + - RCU_ADC_sync: Update_background #disabled for testing # - RCU_ADC_testsignal: Update #disabled for testing - - RCU_DTH_on: Update #check if not also in RCU_update + - RCU_DTH_on: Update_background #check if not also in RCU_update - RCU_IO4_GPIO1: Update #should be last, as it will fail for low-band - RCU_IO4_GPIO2: Update @@ -866,9 +867,11 @@ methods: - RCU_ADC_shutdown : [0,0,0] # - IO3.GPIO1: 0x15 #DTH_EN=low -> ADC enabled # - IO3.GPIO2: 0x47 - - RCU_DTH_on: Update #check dither while giving ADCs some time to lock - - RCU_ADC_locked: Update #disabled for testing - - RCU_ADC_sync: Update #disabled for testing + - RCU_DTH_on: Update_background #check dither while giving ADCs some time to lock + - RCU_ADC_locked: Update_background #disabled for testing + - RCU_ADC_sync: Update_background #disabled for testing + - RCU_PWR_1V8: Update_background + - RCU_PWR_2V5: Update_background # - RCU_ADC_testsignal: Update #disabled for testing - name: RCU_update @@ -981,6 +984,10 @@ methods: mask: RCU_mask # rw: hidden instructions: + - DTH1.PA_CONFIG : [0,45,0,0,125,127] + - DTH2.PA_CONFIG : [0,45,0,0,125,127] + - DTH3.PA_CONFIG : [0,45,0,0,125,127] + - RCU_DTH_PWR : Update_background - RCU_DTH_freq : [ 5, 206, 62, 32, 5, 206, 129, 255, 5, 206, 197, 172, 5, 219, 84, 32, 5, 219, 142, 159, 5, 219, 200, 236, 5, 213, 1, 96, 5, 213, 64, 143, 5, 213, 127, 140, 5, 225, 54, 96, 5, 225, 108, 47, 5, 225, 161, 204, 5, 209, 173, 208, 5, 209, 239, 87, 5, 210, 48, 172, 5, 222, 83, 80, 5, 222, 139, 119, 5, 222, 195, 108, @@ -994,10 +1001,7 @@ methods: 5, 227, 78, 55, 5, 227, 130, 68, 5, 227, 182, 31, 5, 212, 47, 31, 5, 212, 110, 228, 5, 212, 174, 119, 5, 224, 128, 63, 5, 224, 182, 164, 5, 224, 236, 215, 5, 218, 143, 239, 5, 218, 203, 4, 5, 219, 5, 231, 5, 230, 0, 15, 5, 230, 49, 196, 5, 230, 99, 71 ] - - DTH1.PA_CONFIG : [0,45,0,0,125,127] - - DTH2.PA_CONFIG : [0,45,0,0,125,127] - - DTH3.PA_CONFIG : [0,45,0,0,125,127] - - RCU_DTH_PWR : Update + - RCU_DTH_freq : Update_background # - name: RCU_DTH_on description: Switch dither source on @@ -1018,7 +1022,7 @@ methods: - DTH1.Start : [0,1,0,0,1] - DTH2.Start : [0,1,0,0,1] - DTH3.Start : [0,1,0,0,1] - - RCU_DTH_on : Update + - RCU_DTH_on : Update_background - name: RCU_DTH_off description: Switch dither source off @@ -1052,7 +1056,7 @@ methods: - name: RCU_ADC_testsignal_on - description: Configure ADCs to give a time-syncronised test signal. Test signal is disabled by calling RCU_on. + description: Configure ADCs to give a time-syncronised test signal. driver: I2C_RCU mask: RCU_mask instructions: @@ -1063,3 +1067,16 @@ methods: - ADC3.JESD_control1 : 0x34 - ADC3.Update: 1 #Needed to update ADC registers - RCU_ADC_testsignal: Update #disabled for testing + + - name: RCU_ADC_testsignal_off + description: Switch off test signal + driver: I2C_RCU + mask: RCU_mask + instructions: + - ADC1.JESD_control1 : 0x14 + - ADC1.Update: 1 #Needed to update ADC registers + - ADC2.JESD_control1 : 0x14 + - ADC2.Update: 1 #Needed to update ADC registers + - ADC3.JESD_control1 : 0x14 + - ADC3.Update: 1 #Needed to update ADC registers + - RCU_ADC_testsignal: Update #disabled for testing diff --git a/pypcc/config/RECVTR_LB.yaml b/pypcc/config/RECVTR_LB.yaml index 2b44527f81256fe434e6c807d1ff80fdff9ec76b..b753491106bc0a5943cec094a228dea4e0640077 100644 --- a/pypcc/config/RECVTR_LB.yaml +++ b/pypcc/config/RECVTR_LB.yaml @@ -941,7 +941,7 @@ methods: - DTH3.Start : [0,1,0,0,1] - name: RCU_ADC_testsignal_on - description: Configure ADCs to give a time-syncronised test signal. The signal is disabled by calling RCU_on. + description: Configure ADCs to give a time-syncronised test signal. driver: I2C_RCU mask: RCU_mask instructions: @@ -952,3 +952,16 @@ methods: - ADC3.JESD_control1 : 0x34 - ADC3.Update: 1 #Needed to update ADC registers - RCU_ADC_testsignal: Update #disabled for testing + + - name: RCU_ADC_testsignal_off + description: Switch off test signal + driver: I2C_RCU + mask: RCU_mask + instructions: + - ADC1.JESD_control1 : 0x14 + - ADC1.Update: 1 #Needed to update ADC registers + - ADC2.JESD_control1 : 0x14 + - ADC2.Update: 1 #Needed to update ADC registers + - ADC3.JESD_control1 : 0x14 + - ADC3.Update: 1 #Needed to update ADC registers + - RCU_ADC_testsignal: Update #disabled for testing diff --git a/pypcc/config/UNB2TR.yaml b/pypcc/config/UNB2TR.yaml index 22af38cd220e5c31778750e7d38b09d69f4bcdeb..c2f2f5e2eae00a015d6043d1da689878e8d43b3e 100644 --- a/pypcc/config/UNB2TR.yaml +++ b/pypcc/config/UNB2TR.yaml @@ -20,6 +20,12 @@ drivers: parameters: [0,1, 4,4] status: UNB2TR_I2C_bus_PS_error + - name: switch_EEPROM + type: i2c_array2 + parent: I2C1 + parameters: [0,1, 6,6] + status: UNB2TR_I2C_bus_PS_error + - name: switch_FP type: i2c_array2 parent: I2C1 @@ -291,7 +297,7 @@ variables: dim: 2 - name: UNB2_PCB_version - driver: switch_UNB2 + driver: switch_EEPROM devreg: 0x50.0 width: 0x100 #32 char rw: ro @@ -300,7 +306,7 @@ variables: - name: UNB2_PCB_number description: PCB number (astron.nl/webforms/IenS-Boarden/view.php?id=xxx) - driver: switch_UNB2 + driver: switch_EEPROM devreg: 0x50.0x20 width: 0x100 #32 characters rw: ro @@ -308,7 +314,7 @@ variables: dim: 2 - name: UNB2_PCB_ID - driver: switch_UNB2 + driver: switch_EEPROM devreg: 0x50.0xFC width: 32 rw: ro diff --git a/pypcc/i2cserv/i2c_array.py b/pypcc/i2cserv/i2c_array.py index 8595b80908dc13c75596393d49c21ee221e0c5b1..102474f1d2af39f90be616136fb1a8f6d035c51c 100644 --- a/pypcc/i2cserv/i2c_array.py +++ b/pypcc/i2cserv/i2c_array.py @@ -254,7 +254,7 @@ class i2c_array(i2c_dev): try: value2[:]=storearray[RCUi] except: - logging.warning("RCU%iWrong size (no data?) in stored array %i-%i"%(RCUi,len(value2),len(storearray[RCUi]))) + logging.warning("RCU%iWrong size (no data?) in stored array"%(RCUi)) # of len(storearray[RCUi]==0) # storearray[self.RCUi]=(value[0] if len(value)==1 else value[:]) l1=int(np.floor((width+bitoffset+7)/8)) diff --git a/pypcc/i2cserv/i2c_switch_smb.py b/pypcc/i2cserv/i2c_switch_smb.py new file mode 100644 index 0000000000000000000000000000000000000000..e22f3109e2f6d6de55ebaa4280d485e225e4d41a --- /dev/null +++ b/pypcc/i2cserv/i2c_switch_smb.py @@ -0,0 +1,65 @@ +import logging +#from .i2c import i2c +from .i2c_smbus import i2c_smbus as i2c + +#import HWconf +#SWaddr=0x70 +class i2c_switch_smb(i2c): + def __init__(self,config): + i2c.__init__(self,config) +# self.SWaddr=config['devreg'][0]['addr'] + self.SWcnt=len(config['devreg']); + self.SWaddrs=[config['devreg'][x]['addr'] for x in range(self.SWcnt)]; + self.CurrentChannel=[-1 for x in range(self.SWcnt)]; + self.NoSwitch=self.SWcnt==0; + S=''; + for x in range(self.SWcnt): S+=str(self.SWaddrs[x])+","; + logging.info("i2c switch at address "+S) + if self.NoSwitch: + logging.warn("i2c switch disabled!") + + def clearSwitch(self): + for x in range(self.SWcnt): self.CurrentChannel[x]=-1; + + def SetSW1(self,channelbit): +# channel=(0 if (channelbit>5) else 1<<(channelbit)) #LTS + if self.NoSwitch: return True; + SWn=channelbit>>3; + channel=1<<(channelbit & 0x07) + result=True + for x in range(self.SWcnt): + if x==SWn: + if (channel)!=self.CurrentChannel[x]: + self.CurrentChannel[x]=channel + logging.debug("SetChannel addr %i = val %i" % (SWn,channel)); + if not(self.i2csetget(self.SWaddrs[x],[channel])): result=False + else: + if self.CurrentChannel[x]!=0: + logging.debug("SetChannel addr %i = val %i" % (x,0)); + self.CurrentChannel[x]=0 + if not(self.i2csetget(self.SWaddrs[x],[0])): result=False + if not(result): logging.info("Switch set error!") + return result + + def ClearNewChannel(self): + self.newChannel=[0 for x in self.SWaddrs]+[0];#last one is a dummy + + def AddNewChannel(self,channelbit): + SWn=(channelbit>>3); + channel=1<<(channelbit & 0x07) + self.newChannel[SWn]|=channel; + + def UpdateNewChannel(self): +# channel&=0x3F;#LTS + if self.NoSwitch: return True; + for x in range(self.SWcnt): + if self.newChannel[x]!=self.CurrentChannel[x]: + self.CurrentChannel[x]=self.newChannel[x]; + logging.debug("SetChannel2 addr %i = val %i" % (x,self.newChannel[x])); + if not(self.i2csetget(self.SWaddrs[x],[self.newChannel[x]])): return False; +# logging.debug("SetChannel=%i" % channel) +# self.CurrentChannel=channel + return True + +# def I2Ccallback(self,RCU,addr,data,reg=None,read=0): +# self.callback1(addr,data,reg,read) diff --git a/pypcc/testing/check_ip.py b/pypcc/testing/check_ip.py index 9d1c268080ee45d07d3ddda2b09da8e125227e33..c9f013c010a6ba79b6d377c2b0cf51f547e85685 100644 --- a/pypcc/testing/check_ip.py +++ b/pypcc/testing/check_ip.py @@ -13,7 +13,8 @@ import subprocess import RPi.GPIO as GPIO def get_LMP_ID(): - pins=[21,20,16,12,7,8] +# pins=[21,20,16,12,7,8] + pins=[7,8,16,12,21] #ID5..1, ID0 (GPIO 20)=UNB Npins=len(pins); GPIO.setmode(GPIO.BCM) for i,pin in enumerate(pins): diff --git a/pypcc/testing/lmp_id.py b/pypcc/testing/lmp_id.py index c0466c3a389e6f3f01e66d8b03ee76b6eea25ebc..220599e93bcb5211b17d2539cb5c23378e2f3e1e 100644 --- a/pypcc/testing/lmp_id.py +++ b/pypcc/testing/lmp_id.py @@ -1,7 +1,16 @@ import RPi.GPIO as GPIO +#LMP LMP APSCT CM rpi +#DIP CON BCK_ID PIN GPIO +#UNB D8 0 27 20 +# 1 E8 1 25 21 +# 2 E7 2 31 12 +# 3 F7 3 29 16 +# 4 D10 4 39 8 +# 5 E10 5 37 7 def get_LMP_ID(): - pins=[21,20,16,12,7,8] +# pins=[21,20,16,12,7,8] + pins=[7,8,16,12,21] #ID5..1, ID0 (GPIO 20)=UNB Npins=len(pins); GPIO.setmode(GPIO.BCM) for i,pin in enumerate(pins): diff --git a/stop_all.sh b/stop_all.sh index f2e4baa8bfe469e678ae723b242ccfb361e638ef..4deb93f71068f1e2cf6597c5ea96dceadf898d54 100755 --- a/stop_all.sh +++ b/stop_all.sh @@ -3,3 +3,9 @@ sudo systemctl stop recvtr.service sudo systemctl stop apscttr.service sudo systemctl stop apsputr.service sudo systemctl stop unb2tr.service +sudo systemctl stop ccdtr.service +sudo systemctl disable recvtr.service +sudo systemctl disable apscttr.service +sudo systemctl disable apsputr.service +sudo systemctl disable unb2tr.service +sudo systemctl disable ccdtr.service