From 8755a0cc9a8ef211aab534d85230fe07b1ea3fee Mon Sep 17 00:00:00 2001 From: Paulus <kruger@astron.nl> Date: Thu, 30 Sep 2021 15:29:05 +0100 Subject: [PATCH] DTH i2c fixed --- config/RCU.yaml | 25 ++++++++++++++----------- config/RCUL.yaml | 2 +- config/RECVTR.yaml | 2 +- i2cserv/i2cbitbang1.py | 11 +++++++---- scripts/DTH_test.py | 8 +++++--- 5 files changed, 28 insertions(+), 20 deletions(-) diff --git a/config/RCU.yaml b/config/RCU.yaml index 7e70e59..c01ffe1 100644 --- a/config/RCU.yaml +++ b/config/RCU.yaml @@ -181,7 +181,7 @@ device_registers: dim: 3 description: CW dither source device: SI4012 - driver: [I2Cbb1,I2Cbb1,I2Cbb1] + driver: [I2Cbb1,I2Cbb2,I2Cbb3] address: 0x70 registers: - name: Freq @@ -204,6 +204,9 @@ device_registers: address: [0x1221,0x1121] - name: CONF address: [0x1210,0x1110] +# - name: POWER +# address: [0x1260,0x1160] +# store: True variables: - name: Ant_mask @@ -409,10 +412,10 @@ variables: devreg: [IO3.GPIO1,IO3.GPIO1,IO3.GPIO2] width: 1 bitoffset: [7,6,7] - rw: ro + rw: rw dtype: boolean dim: 96 - mask: ANT_mask + mask: Ant_mask - name: ANT_PWR_ON driver: I2C_RCU @@ -687,24 +690,24 @@ methods: - RCU_DTH_config : [0,0,0] # - RCU_DTH_tune : [0,0,0,0,0,0] # - DTH1.CONF : 0 -# - DTH1.Tune : [0,0] #no tuning + - DTH1.Tune : [0,0] #no tuning + - DTH2.Tune : [0,0] #no tuning + - DTH3.Tune : [0,0] #no tuning + - RCU_DTH_tune: Update #debug # - WAIT: 10 # - DTH1.Start : [1,0,0,0,1,0x55] - DTH1.Start : [0,1,0,0,1] # - DTH1.0x60: #PA_config... # - DTH2.CONF : 0 # - WAIT: 10 -# - DTH2.Tune : [0,0] #no tuning # - WAIT: 10 - DTH2.Start : [0,1,0,0,1] # - DTH3.CONF : 0 # - WAIT: 10 -# - DTH3.Tune : [0,0] #no tuning # - WAIT: 10 - DTH3.Start : [0,1,0,0,1] - RCU_DTH_ON : Update - - RCU_DTH_config: Update #debug - - RCU_DTH_tune: Update #debug +# - RCU_DTH_config: Update #debug - name: DTH_off driver: I2C_RCU @@ -716,10 +719,10 @@ methods: # - WAIT: 100 # - RCU_DTH_SHUTDOWN : [0,0,0] # - RCU_DTH_SHUTDOWN : 1 - - DTH1.Stop : [0,0] - - DTH2.Stop : [0,0] - DTH3.Stop : [0,0] + - DTH2.Stop : [0,0] + - DTH1.Stop : [0,0] + - RCU_DTH_ON: Update # - DTH1.State : [0,0] # - DTH2.State : [0,0] # - DTH3.State : [0,0] - - RCU_DTH_ON: Update diff --git a/config/RCUL.yaml b/config/RCUL.yaml index 2ba1f01..eedc85d 100644 --- a/config/RCUL.yaml +++ b/config/RCUL.yaml @@ -151,7 +151,7 @@ device_registers: dim: 3 description: CW dither source device: SI4012 - driver: [I2Cbb1,I2Cbb1,I2Cbb1] + driver: [I2Cbb1,I2Cbb2,I2Cbb3] address: 0x70 registers: - name: Freq diff --git a/config/RECVTR.yaml b/config/RECVTR.yaml index aadfa01..f1a81f0 100644 --- a/config/RECVTR.yaml +++ b/config/RECVTR.yaml @@ -181,7 +181,7 @@ device_registers: dim: 3 description: CW dither source device: SI4012 - driver: [I2Cbb1,I2Cbb1,I2Cbb1] + driver: [I2Cbb1,I2Cbb2,I2Cbb3] address: 0x70 registers: - name: Freq diff --git a/i2cserv/i2cbitbang1.py b/i2cserv/i2cbitbang1.py index 5d94cad..db47042 100644 --- a/i2cserv/i2cbitbang1.py +++ b/i2cserv/i2cbitbang1.py @@ -51,7 +51,7 @@ class i2cbitbang1(hwdev): logging.info(str(("I2Cbb set",hex(ADC_address),value))) SetI2C(DIRdev,1,DIRpin,[1]) #Input = high - SetI2C(CLKdev,1,CLKpin,[1]) #Should be high + SetI2C(CLKdev,1,CLKpin,[1]) #Should be high for start #start SetI2C(SDAdev,1,SDApin,[0]) #Output = low SetI2C(DIRdev,1,DIRpin,[0]) #Output = low @@ -78,6 +78,7 @@ class i2cbitbang1(hwdev): SetI2C(DIRdev,1,DIRpin,[0]) #low SetI2C(CLKdev,1,CLKpin,[1]) #Should be high SetI2C(DIRdev,1,DIRpin,[1]) #Input = high + SetI2C(CLKdev,1,CLKpin,[0]) #keep low between transmission to not generate stop/start when other i2c actice return True; @@ -96,7 +97,7 @@ class i2cbitbang1(hwdev): logging.info(str(("I2Cbb get",hex(ADC_address),value))) SetI2C(DIRdev,1,DIRpin,[1]) #Input = high - SetI2C(CLKdev,1,CLKpin,[1]) #Should be high + SetI2C(CLKdev,1,CLKpin,[1]) #Should be high for start bit #start SetI2C(SDAdev,1,SDApin,[0]) #Output = low SetI2C(DIRdev,1,DIRpin,[0]) #Output = low @@ -134,13 +135,15 @@ class i2cbitbang1(hwdev): return b; TXbyte(ADC_address); - print("si status:",hex(RXbyte()))#should be 0x80 + status=RXbyte(last=(len(value)==0)) # if not(RXbyte()==0x80): return False; for i in range(len(value)): value[i]=RXbyte(last=(i==len(value)-1)) + print("si status:",hex(status),[hex(v) for v in value])#should be 0x80 #stop #SetI2C(DIRdev,1,DIRpin,[0]) #low - SetI2C(CLKdev,1,CLKpin,[1]) #Should be high + SetI2C(CLKdev,1,CLKpin,[1]) SetI2C(DIRdev,1,DIRpin,[1]) #Input = high + SetI2C(CLKdev,1,CLKpin,[0]) #keep low between transmission to not generate stop/start when other i2c actice return True; \ No newline at end of file diff --git a/scripts/DTH_test.py b/scripts/DTH_test.py index 5091d03..0655d8c 100644 --- a/scripts/DTH_test.py +++ b/scripts/DTH_test.py @@ -4,19 +4,21 @@ from test_common import * RCU=4; setAntmask([RCU]) setRCUmask([RCU]) +#call_debug_method("DTH_off") -if False: +if True: name="RCU_DTH_freq" - Freq=[102e6,102.1e6,102.2e6] + Freq=[102e6,102.101e6,102.2e6] +# Freq=[102.2e6,102.1e6,102.0e6] # Freq=[0,0,0] att=get_value(name+"_R") print("freq old:",att[3*RCU:3*RCU+3]) att[3*RCU:3*RCU+3]=[int(x) for x in Freq] + print("freq set:",att[3*RCU:3*RCU+3]) set_value(name+"_RW",att) time.sleep(0.5) att=get_value(name+"_R") print("freq new :",att[3*RCU:3*RCU+3]) - call_debug_method("DTH_on") #call_debug_method("DTH_off") -- GitLab