Skip to content
Snippets Groups Projects
Commit f4f244a1 authored by Paulus Kruger's avatar Paulus Kruger
Browse files

Startup working

parent 9fc28b7b
No related branches found
No related tags found
No related merge requests found
...@@ -14,6 +14,11 @@ drivers: ...@@ -14,6 +14,11 @@ drivers:
parent: I2C_CLK parent: I2C_CLK
devreg: [IO1.GPIO1,IO1.GPIO1,IO1.GPIO1,IO1.GPIO1] devreg: [IO1.GPIO1,IO1.GPIO1,IO1.GPIO1,IO1.GPIO1]
parameters: [4,7,5,6] parameters: [4,7,5,6]
- name: SPIbb2
type: spibitbang2 #SPI bitbang via GPIO expander: CLK, SDI,SDO,CS
parent: I2C_CLK
devreg: [IO2.GPIO1,IO2.GPIO1,IO2.GPIO1,IO2.GPIO1]
parameters: [4,7,5,6]
#This is the I2C devices in the RCU #This is the I2C devices in the RCU
device_registers: device_registers:
...@@ -40,7 +45,7 @@ device_registers: ...@@ -40,7 +45,7 @@ device_registers:
address: [1,3] #Read / Write address different address: [1,3] #Read / Write address different
store: True store: True
- name: PLL - name: PLL2
driver: SPIbb1 driver: SPIbb1
registers: registers:
- name: PLL_stat - name: PLL_stat
...@@ -50,6 +55,16 @@ device_registers: ...@@ -50,6 +55,16 @@ device_registers:
- {name: r5, address: 0x05} - {name: r5, address: 0x05}
- {name: r6, address: 0x06} - {name: r6, address: 0x06}
- name: PLL1
driver: SPIbb2
registers:
- name: PLL_stat
description: PLL locked status
address: 0x0
- {name: r3, address: 0x03}
- {name: r5, address: 0x05}
- {name: r6, address: 0x06}
- name: ROM - name: ROM
description: 24AA02UIDT description: 24AA02UIDT
address: 0x50 address: 0x50
...@@ -183,20 +198,29 @@ variables: ...@@ -183,20 +198,29 @@ variables:
- name: APSCT_PLL_200MHz_locked_SPI - name: APSCT_PLL_200MHz_locked_SPI
description: 0x81=locked description: 0x81=locked
driver: I2C_CLK driver: I2C_CLK
devreg: PLL.PLL_stat devreg: PLL2.PLL_stat
width: 8 width: 8
rw: ro rw: ro
dtype: uint8 dtype: uint8
debug: True debug: True
- name: [APSCT_PLL_r3,APSCT_PLL_r5,APSCT_PLL_r6] - name: APSCT_PLL_160MHz_locked_SPI
description: 0x81=locked
driver: I2C_CLK driver: I2C_CLK
devreg: [PLL.r3,PLL.r5,PLL.r6] devreg: PLL1.PLL_stat
width: 8 width: 8
rw: ro rw: ro
dtype: uint8 dtype: uint8
debug: True debug: True
# - name: [APSCT_PLL_r3,APSCT_PLL_r5,APSCT_PLL_r6]
# driver: I2C_CLK
# devreg: [PLL.r3,PLL.r5,PLL.r6]
# width: 8
# rw: ro
# dtype: uint8
# debug: True
- name: [APSCT_IO1_GPIO1,APSCT_IO1_GPIO2,APSCT_IO2_GPIO1,APSCT_IO2_GPIO2] - name: [APSCT_IO1_GPIO1,APSCT_IO1_GPIO2,APSCT_IO2_GPIO1,APSCT_IO2_GPIO2]
driver: I2C_CLK driver: I2C_CLK
devreg: [IO1.GPIO1,IO1.GPIO2,IO2.GPIO1,IO2.GPIO2] devreg: [IO1.GPIO1,IO1.GPIO2,IO2.GPIO1,IO2.GPIO2]
...@@ -239,8 +263,6 @@ methods: ...@@ -239,8 +263,6 @@ methods:
debug: True debug: True
instructions: instructions:
- APSCT_I2C_error : 0 - APSCT_I2C_error : 0
- APSCT_ID : Update
- APSCT_version : Update
- APSCT_IO1_GPIO1 : Update - APSCT_IO1_GPIO1 : Update
- APSCT_IO1_GPIO2 : Update - APSCT_IO1_GPIO2 : Update
- APSCT_IO2_GPIO1 : Update - APSCT_IO2_GPIO1 : Update
...@@ -249,6 +271,14 @@ methods: ...@@ -249,6 +271,14 @@ methods:
- IO1.CONF2: Update - IO1.CONF2: Update
- IO2.CONF1: Update - IO2.CONF1: Update
- IO2.CONF2: Update - IO2.CONF2: Update
- APSCTTR_Update: 0
- name: APSCTTR_Update
driver: I2C_CLK
debug: True
instructions:
- APSCT_ID : Update
- APSCT_version : Update
- APSCT_PWR_on: Update - APSCT_PWR_on: Update
- APSCT_PWR_PLL_200MHz_on: Update - APSCT_PWR_PLL_200MHz_on: Update
- APSCT_PLL_200MHz_locked: Update - APSCT_PLL_200MHz_locked: Update
...@@ -258,49 +288,98 @@ methods: ...@@ -258,49 +288,98 @@ methods:
- APSCT_PLL_160MHz_error: Update - APSCT_PLL_160MHz_error: Update
- APSCT_PPS_ignore : Update - APSCT_PPS_ignore : Update
- name: APSCT_200MHz_on
- name: APSCT_on
driver: I2C_CLK driver: I2C_CLK
description: Configure clock. Monitored using APSCT_PWR_on, APSCT_PLL_error and APSCT_PLL_locked description: Configure clock. Monitored using APSCT_PWR_on, APSCT_PLL_error and APSCT_PLL_locked
instructions: instructions:
- APSCT_I2C_error : 0 - APSCT_I2C_error : 0
# - IO1.CONF1: 0x2C #0010 1100 PPS/PWR output, SCLK,CS,SDI - IO1.CONF1: 0x2C #0010 1100 PPS/PWR output, SCLK,CS,SDI
# - IO1.GPIO1: 0x42 #0100 0010 high:PWR enable, CS - IO1.CONF2: 0x00
# - APSCT_PWR_on: Update - IO2.CONF1: 0x2C #0010 1100 PPS/PWR output, SCLK,CS,SDI
# - WAIT: 200 #ms to wait before checking lock - IO2.CONF2: 0x03 #
# - APSCT_PLL_setup: 0 - IO1.GPIO1: 0x42 #0100 0010 high:200MHz PLL enable, CS high
# - WAIT: 100 #ms to wait before checking lock - IO1.GPIO2: 0xF8 #PWR enable ##Check if not 4??
# - APSCT_PLL_locked: Update - IO2.GPIO1: 0x00 #All low
- IO2.GPIO2: 0x00 #All low (just inputs)
- WAIT: 200
- APSCT_PLL200_setup: 0
- WAIT: 200 #ms to wait before checking lock
- APSCTTR_Update: 0 #refresh all settings
- name: APSCT_160MHz_on
driver: I2C_CLK
description: Configure clock. Monitored using APSCT_PWR_on, APSCT_PLL_error and APSCT_PLL_locked
instructions:
- APSCT_I2C_error : 0
- IO1.CONF1: 0x2C #0010 1100 PPS/PWR output, SCLK,CS,SDI
- IO1.CONF2: 0x00
- IO2.CONF1: 0x2C #0010 1100 PPS/PWR output, SCLK,CS,SDI
- IO2.CONF2: 0x03 #
- IO1.GPIO1: 0x00
- IO1.GPIO2: 0x08 #PWR enable ##Check if not 4??
- IO2.GPIO1: 0x42 #0100 0010 high:160MHz PLL enable, CS high
- IO2.GPIO2: 0x00 #All low (just inputs)
- WAIT: 200
- APSCT_PLL160_setup: 0
- WAIT: 200 #ms to wait before checking lock
- APSCTTR_Update: 0 #refresh all settings
- name: APSCT_off - name: APSCT_off
driver: I2C_CLK driver: I2C_CLK
description: Switch clock off. Monitored using APSCT_PWR_on description: Switch clock off. Monitored using APSCT_PWR_on
instructions: instructions:
- APSCT_I2C_error : 0 - APSCT_I2C_error : 0
# - IO1.CONF1: 0x2C #0010 1100 PPS/PWR output, SCLK,CS,SDI - IO1.GPIO1: 0x00
# - IO1.GPIO1: 0x00 #all low - IO1.GPIO2: 0x00
# - APSCT_PWR_on: Update - IO2.GPIO1: 0x00
# - APSCT_PLL_locked: Update - IO2.GPIO2: 0x00
- APSCTTR_Update: 0 #refresh all settings
- name: APSCT_PLL200_setup
driver: I2C_CLK
debug: true
instructions:
# - PLL2.0x03: 0x08 #Set power, this is default
- PLL2.0x04: 0xCF #
- PLL2.0x05: 0x97 #was 97, set lock time = =x17?
- PLL2.0x06: 0x10
- PLL2.0x07: 0x04 #Stop R divider
- PLL2.0x08: 0x01 #Set R divider
- PLL2.0x07: 0x00 #Start R divider
- PLL2.0x09: 0x10 #Stop N divider
- PLL2.0x0A: 0x14 #Set N divider=20, 200MHz/20=10MHz = input clock
- PLL2.0x09: 0x00 #Start N divider
- PLL2.0x0D: 0x01 #Divider output 1=1
- PLL2.0x0F: 0x01 #Divider output 2=1
- PLL2.0x11: 0x01 #Divider output 3=1
- PLL2.0x13: 0x01 #Divider output 4=1
- name: APSCT_PLL_setup - name: APSCT_PLL160_setup
driver: I2C_CLK driver: I2C_CLK
debug: true debug: true
instructions: instructions:
# - PLL.0x03: 0x08 #Set power, this is default # - PLL1.0x03: 0x08 #Set power, this is default
- PLL.0x05: 0x17 #was 97, set lock time - PLL1.0x04: 0xCF #
- PLL.0x06: 0x10 - PLL1.0x05: 0x97 #was 97, set lock time = =x17?
- PLL1.0x06: 0x10
- PLL.0x07: 0x04 #Stop R divider
- PLL.0x08: 0x01 #Set R divider - PLL1.0x07: 0x04 #Stop R divider
- PLL.0x07: 0x00 #Start R divider - PLL1.0x08: 0x01 #Set R divider
- PLL1.0x07: 0x00 #Start R divider
- PLL.0x09: 0x10 #Stop N divider
- PLL.0x0A: 0x14 #Set N divider=20, 200MHz/20=10MHz = input clock - PLL1.0x09: 0x10 #Stop N divider
- PLL.0x09: 0x00 #Start N divider - PLL1.0x0A: 0x10 #Set N divider=16, 160MHz/16=10MHz = input clock
- PLL1.0x09: 0x00 #Start N divider
- PLL.0x0D: 0x01 #Divider output 1=1
- PLL.0x0F: 0x01 #Divider output 2=1 - PLL1.0x0D: 0x01 #Divider output 1=1
- PLL.0x11: 0x01 #Divider output 3=1 - PLL1.0x0F: 0x01 #Divider output 2=1
- PLL.0x13: 0x01 #Divider output 4=1 - PLL1.0x11: 0x01 #Divider output 3=1
- PLL1.0x13: 0x01 #Divider output 4=1
...@@ -45,6 +45,7 @@ drivers: ...@@ -45,6 +45,7 @@ drivers:
- name: GPIO - name: GPIO
type: gpio type: gpio
parameters: [19,26]
#This is the I2C devices in the RCU #This is the I2C devices in the RCU
...@@ -132,11 +133,11 @@ variables: ...@@ -132,11 +133,11 @@ variables:
dtype: boolean dtype: boolean
dim: 2 dim: 2
- name: UNB2_Power_ON_OFF - name: UNB2_PWR_off
driver: GPIO driver: GPIO
mask: UNB2_mask mask: UNB2_mask
width: 1 width: 1
rw: hidden #ro rw: rw
dtype: boolean dtype: boolean
dim: 2 dim: 2
......
#import numpy as np #import numpy as np
from .hwdev import hwdev; from .hwdev import hwdev;
import logging import logging
import RPi.GPIO as GPIO
from queuetypes import *
class gpio(hwdev): class gpio(hwdev):
def __init__(self,config): def __init__(self,config):
hwdev.__init__(self,config); hwdev.__init__(self,config);
logging.info("gpio todo") self.pins=config['parameters']
self.Npins=len(self.pins);
GPIO.setmode(GPIO.BCM)
self.state=[0 for pin in self.pins]
logging.info(str(("gpio, Pins=",self.state)));
for i,pin in enumerate(self.pins):
GPIO.setup(pin,GPIO.OUT)
# for i,pin in enumerate(self.pins):
# GPIO.setup(pin,GPIO.IN)
# self.state=[GPIO.input(pin) for pin in self.pins]
# logging.info(str(("gpio, Pins=",self.state)));
def OPCUASetVariable(self,varid,var1,data,mask):
logging.info("Set gpio");
if len(mask)!=self.Npins:
logging.warning("Wrong mask length");
mask=[True]*self.Npins;
if len(data)!=self.Npins:
logging.warning("Wrong data length");
return []
for i,pin in enumerate(self.pins):
if mask[i]:
GPIO.output(pin,data[i]%2);
self.state[i]=data[i]%2
Data=OPCUAset(varid,InstType.varSet,self.state.copy(),mask.copy())
return [Data]
def OPCUAReadVariable(self,varid,var1,mask):
logging.info("Read gpio");
Data=OPCUAset(varid,InstType.varSet,self.state.copy(),mask.copy())
return [Data]
from test_common import * from test_common import *
RCUs=[0,1,2,3];
RCUs=[1,3]; connect()
setRCUmask(RCUs) setRCUmask(RCUs)
def wait(var1="RECVTR_translator_busy_R"): def wait(var1="RECVTR_translator_busy_R"):
...@@ -11,11 +12,11 @@ def wait(var1="RECVTR_translator_busy_R"): ...@@ -11,11 +12,11 @@ def wait(var1="RECVTR_translator_busy_R"):
time.sleep(0.1) time.sleep(0.1)
print("Time=",x*0.1,"s") print("Time=",x*0.1,"s")
callmethod("RCU_off") #callmethod("RCU_off")
wait() #wait()
#exit() #exit()
time.sleep(2) #time.sleep(2)
#callmethod("RCU_on") callmethod("RCU_on")
wait() wait()
#callmethod("RCU_on") #callmethod("RCU_on")
#time.sleep(1) #time.sleep(1)
......
from test_common import * from test_common import *
name="ANT_PWR_ON" name="RCU_PWR_ANT_on"
RCU=[4]; RCU=[0,1,2,3];
On=[True,True,True] On=[True,True,True]
#On=[False,False,False] #On=[False,False,False]
#Att=[10,10,10] #Att=[10,10,10]
#RCU=[1,2,3]; #RCU=[1,2,3];
#Att=[0,0,0] #Att=[0,0,0]
connect()
setAntmask(RCU) setAntmask(RCU)
att=get_value(name+"_R") att=get_value(name+"_R")
......
from test_common import * from test_common import *
connect("opc.tcp://localhost:4843/")
#callmethod("CLK_off") #callmethod("APSCT_off")
#time.sleep(1) #time.sleep(1)
#callmethod("APSCT_200MHz_on")
callmethod("CLK_on") callmethod("APSCT_160MHz_on")
for x in range(10): for x in range(10):
busy=get_value("CLK_translator_busy_R") busy=get_value("APSCTTR_translator_busy_R")
print(busy) print(busy)
if not(busy): break if not(busy): break
time.sleep(0.1) time.sleep(0.1)
......
from test_common import * from test_common import *
RCU=1; RCU=3;
connect()
setAntmask([RCU]) setAntmask([RCU])
setRCUmask([RCU]) setRCUmask([RCU])
#call_debug_method("DTH_off") #call_debug_method("DTH_off")
if False: if True:
name="RCU_DTH_freq" name="RCU_DTH_freq"
Freq=[102e6,102.101e6,102.2e6] Freq=[102e6,102.101e6,102.2e6]
# Freq=[102.2e6,102.1e6,102.0e6] # Freq=[102.2e6,102.1e6,102.0e6]
......
...@@ -9,7 +9,7 @@ from opcua import Client ...@@ -9,7 +9,7 @@ from opcua import Client
from opcua import ua from opcua import ua
#import numpy as np #import numpy as np
def connect(): def connect(Address=Address):
global client,root global client,root
# logging.basicConfig(level=logging.INFO) # logging.basicConfig(level=logging.INFO)
logging.basicConfig(level=logging.WARN) logging.basicConfig(level=logging.WARN)
...@@ -20,7 +20,7 @@ def connect(): ...@@ -20,7 +20,7 @@ def connect():
root = client.get_root_node() root = client.get_root_node()
return root return root
root=connect() #root=connect()
def disconnect(): def disconnect():
client.disconnect() client.disconnect()
...@@ -52,7 +52,7 @@ def setRCUmask(rcu=[]): ...@@ -52,7 +52,7 @@ def setRCUmask(rcu=[]):
# print(name," new:",get_value(name)) # print(name," new:",get_value(name))
def setAntmask(rcu=[],ant=[True,True,True]): def setAntmask(rcu=[],ant=[True,True,True]):
name="RCU_ANT_mask_RW" name="ANT_mask_RW"
M=get_value(name) M=get_value(name)
# print(name," old:",M) # print(name," old:",M)
for i,j in enumerate(M): for i,j in enumerate(M):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment