Skip to content
Snippets Groups Projects
Commit fc87ff1d authored by Gijs Schoonderbeek's avatar Gijs Schoonderbeek
Browse files

Merge branch 'apsct_production' into 'master'

Apsct production

See merge request !3
parents 9d5dc319 0388db4f
No related branches found
No related tags found
1 merge request!3Apsct production
"""
Copyright 2022 Stichting Nederlandse Wetenschappelijk Onderzoek Instituten,
ASTRON Netherlands Institute for Radio Astronomy
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created: 2022-12-07
This file contains the definitions of the APSPU registers etc.
"""
#
# I2C address, registers and ports for APSCT
# Created: 2023-01-06
#
#
# Power supplies
#
PWR_LOCATIONS = {"INPUT": 0,
"PLL_160M": 1,
"PLL_200M": 2,
"DIST_A": 3,
"DIST_B": 4,
"DIST_C": 5,
"DIST_D": 6,
"CTRL": 7}
PWR_VOUT = {"INPUT": 3.3,
"PLL_160M": 3.3,
"PLL_200M": 3.3,
"DIST_A": 3.3,
"DIST_B": 3.3,
"DIST_C": 3.3,
"DIST_D": 3.3,
"CTRL": 3.3}
#
# PLL constants / pin locations
#
CS = 6
SCLK = 4
SDO = 5
SDI = 7
PLL_200M = 0x20
PLL_160M = 0x21
#
# Central I2C Devices
#
EEPROM = 0x50
#
# I2C switch addresses
#
i2c_switch_addr_rcu = [0x70, 0x71, 0x72, 0x73]
i2c_bus_rcu = 1
i2c_switch_addr_unb = [0x70]
i2c_bus_unb = 3
#
# ID Pins
#
ID_PINS = [8, 7, 12, 16, 20, 21]
......@@ -43,6 +43,11 @@ class I2C:
if SLOW:
sleep(0.2)
except IOError:
ret_ack = 0
ret_value = 'ffff'
if DEBUG:
print("Reading error")
except err:
ret_ack = 0
ret_value = 'ffff'
if DEBUG:
......@@ -50,7 +55,7 @@ class I2C:
return ret_ack, ret_value
def read_last_reg(self, bytes_to_read):
def read_last_reg(self, bytes_to_read, print_on = DEBUG):
bus = smbus.SMBus(self.bus_nr)
rd_value = []
ret_value = ''
......@@ -63,8 +68,13 @@ class I2C:
except IOError:
ret_ack = 0
rd_value.append(0)
if DEBUG:
print("IO-Reading error")
if print_on:
print(f"Reading IOerror {rd_value}")
except err:
ret_ack = 0
rd_value.append(0)
if print_on:
print("Reading error")
for cnt in range(bytes_to_read):
ret_value += (hex(rd_value[cnt])[2:])
return ret_ack,ret_value
......@@ -79,6 +89,11 @@ class I2C:
if SLOW:
sleep(0.3)
except IOError:
ret_ack = 0
ret_value = 0
if DEBUG:
print("Write error")
except err:
ret_ack = 0
ret_value = 0
if DEBUG:
......@@ -93,6 +108,11 @@ class I2C:
if SLOW:
sleep(0.3)
except IOError:
ret_ack = 0
ret_value = 0
if DEBUG:
print("Write error")
except err:
ret_ack = 0
ret_value = 0
if DEBUG:
......@@ -107,6 +127,11 @@ class I2C:
if SLOW:
sleep(0.3)
except IOError:
ret_ack = 0
ret_value = 0
if DEBUG:
print("Write error")
except err:
ret_ack = 0
ret_value = 0
if DEBUG:
......@@ -122,6 +147,11 @@ class I2C:
if SLOW:
sleep(0.3)
except IOError:
ret_ack = 0
ret_value = 0
if DEBUG:
print("No ACK")
except err:
ret_ack = 0
ret_value = 0
if DEBUG:
......
This diff is collapsed.
"""
Copyright 2021 Stichting Nederlandse Wetenschappelijk Onderzoek Instituten,
ASTRON Netherlands Institute for Radio Astronomy
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Check APSCT_CLK
"""
import apsct_lib
import sys
READ_ALL = False # True
CLK_FREQ = '200MHz'
if len(sys.argv) < 2:
print("Production_apsct.py <ASTRON NR> <Serial number>")
print("e.g. python3 production_apsct.py 2023-01 1234")
exit()
apsct = apsct_lib.ApsctClass(CLK_FREQ)
state = True
modi = ["200MHz", "160MHz", "OFF"]
for mode in modi:
print(f"Check APSCT in {mode} mode")
apsct.frequency = mode
apsct.set_apsct()
if mode == "200MHz":
state = state & apsct.pll_200.read_lock()
if mode == "160MHz":
state = state & apsct.pll_160.read_lock()
apsct.frequency = "200MHz"
apsct.set_apsct()
apsct.pll_200.read_lock()
apsct.sensors.apsct_sensors()
state = state & apsct.check_apsct()
if READ_ALL:
apsct.pll_200.read_all_regs_pll()
apsct.pll_160.read_all_regs_pll()
apsct.read_io_expanderis()
if state:
apsct_id = "APSCT-" + sys.argv[1]
serial = sys.argv[2]
rw_ok = apsct.eeprom.wr_rd_eeprom(apsct_id, address=0)
if rw_ok:
rw_ok = apsct.eeprom.wr_rd_eeprom(serial, address=0x20)
if not rw_ok:
print("EEPROM Error")
else:
print("\n >>> Errors during testing <<<\n")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment