Compare commits
3 commits
8179bdb629
...
ecc33261a2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ecc33261a2 | ||
|
|
ea6f1a00d2 | ||
|
|
68d335b9ad |
3 changed files with 108 additions and 21 deletions
119
src/dorn.py
119
src/dorn.py
|
|
@ -1,10 +1,11 @@
|
|||
import math, time, sys
|
||||
|
||||
def _connect(ifc):
|
||||
global _ifc, acmd, rfifo
|
||||
global _ifc, acmd, rfifo, menable
|
||||
_ifc = ifc
|
||||
acmd = ifc.acmd
|
||||
rfifo = ifc.rfifo
|
||||
menable = ifc.menable
|
||||
|
||||
def degCβ(a, R1=10e3, R25=10e3, B25=3940, res=0x1000):
|
||||
if not a:
|
||||
|
|
@ -67,6 +68,38 @@ def HK4_LEIA_fmt(s, i, n, d):
|
|||
Tpa0 = {d[5]:6.2f} °C, Tpa1= {d[6]:6.2f} °C, Tpa2 = {d[7]:6.2f} °C.
|
||||
"""
|
||||
|
||||
def HK3_THHOR_fmt(s, i, n, d):
|
||||
return f"""{i}. {n}
|
||||
VssP = {d[0]:6.3f} V,
|
||||
Vcore = {d[1]:6.3f} V,
|
||||
Vcc = {d[2]:6.3f} V,
|
||||
Vprim = {d[3]:6.2f} V,
|
||||
"""
|
||||
|
||||
def HK4_THHOR_fmt(s, i, n, d):
|
||||
return f"""{i}. {n}
|
||||
VccP = {d[0]:6.3f} V,
|
||||
VssS = {d[1]:6.3f} V,
|
||||
VccS = {d[2]:6.3f} V,
|
||||
Vpll = {d[3]:6.3f} V,
|
||||
"""
|
||||
|
||||
def HK5_THHOR_fmt(s, i, n, d):
|
||||
return f"""{i}. {n}
|
||||
Ibias = {d[0]:6.1f} nA,
|
||||
Vbias = {d[1]:6.1f} V,
|
||||
Vdig = {d[2]:6.3f} V,
|
||||
Vss = {d[3]:6.3f} V,
|
||||
"""
|
||||
|
||||
def HK7_THHOR_fmt(s, i, n, d):
|
||||
return f"""{i}. {n}
|
||||
Tpa1 = {d[0]:6.2f} °C,
|
||||
Tpa2 = {d[1]:6.2f} °C,
|
||||
Tpa3 = {d[2]:6.2f} °C,
|
||||
Tfpga = {d[3]:6.2f} °C,
|
||||
"""
|
||||
|
||||
class DORN_CONFIG:
|
||||
# stis_ana_core 2×24 ch
|
||||
dorn_addr = 0x2000
|
||||
|
|
@ -124,7 +157,8 @@ class DORN_CONFIG:
|
|||
def m_trigs(self):
|
||||
return (1 << self.n_trigs()) - 1
|
||||
|
||||
NTC = [dict(R1=10e3, R25=10e3, B25=3940, res=0x1000)]
|
||||
NTC = [dict(R1=10e3, R25=10e3, B25=3940, res=0x1000),
|
||||
dict(R1=22e3, R25=10e3, B25=3940, res=0x1000), ]
|
||||
|
||||
HK4_SETH = [
|
||||
[
|
||||
|
|
@ -234,16 +268,54 @@ class DORN_CONFIG:
|
|||
self.HK[3] = ("HK_AD", self.HK3_LEIA, HK3_LEIA_fmt)
|
||||
self.HK[4] = ("HK_PA", self.HK4_LEIA, HK4_LEIA_fmt)
|
||||
|
||||
NTC_THHOR = (degC, dict(idx=1))
|
||||
HK_THHOR = [
|
||||
("V₃",
|
||||
[[
|
||||
("VssP", 2.5, ("VccP", -1.5)),
|
||||
("Vcore", 1),
|
||||
("Vcc", 2.505),
|
||||
("Vprim", 11),
|
||||
]],
|
||||
HK3_THHOR_fmt),
|
||||
("V₄",
|
||||
[[
|
||||
("VccP", 2),
|
||||
("VssS", 2.5, ("VccS", -1.5)),
|
||||
("VccS", 2),
|
||||
("Vpll", 1.0012),
|
||||
]],
|
||||
HK4_THHOR_fmt),
|
||||
("V₅,Ibias",
|
||||
[[
|
||||
("Ibias", 10470/470 * 51/1051 * 100, -7),
|
||||
("Vbias", -8850/220, ("Vss", -8850/470)),
|
||||
("Vdig", 2),
|
||||
("Vss", 2.5034, ("Vcc", -1.505)),
|
||||
]],
|
||||
HK5_THHOR_fmt),
|
||||
("Vref", None, HK_fmt),
|
||||
("NTC",
|
||||
[[
|
||||
("Tpa0", NTC_THHOR),
|
||||
("Tpa1", NTC_THHOR),
|
||||
("Tpa2", NTC_THHOR),
|
||||
("Tfpga", NTC_THHOR),
|
||||
]],
|
||||
HK7_THHOR_fmt),
|
||||
]
|
||||
|
||||
def thhor(self):
|
||||
self.slices=(0,)
|
||||
self.n_channels = 12
|
||||
self.NTC = [dict(R1=22e3, R25=10e3, B25=3940, res=0x1000)]
|
||||
self.VREF = [3.359] # ADC supply voltage
|
||||
self.HK[3:] = self.HK_THHOR
|
||||
|
||||
CONFIG = DORN_CONFIG()
|
||||
|
||||
def hk(sl=0, what="print", data=None):
|
||||
if not data:
|
||||
_ifc.menable()
|
||||
menable()
|
||||
fifo_enable(en=True, sl=sl, hk=True)
|
||||
fifo_reset(sl=sl, hk=True)
|
||||
strobe(sl=sl, hk=True)
|
||||
|
|
@ -275,6 +347,7 @@ def hk(sl=0, what="print", data=None):
|
|||
Vref = CONFIG.Vref(sl)/4096
|
||||
ddata = []
|
||||
VV = {"Vref": CONFIG.Vref(sl)}
|
||||
deferred = []
|
||||
for a in range(8):
|
||||
V = {}
|
||||
ddata.append(V)
|
||||
|
|
@ -285,26 +358,38 @@ def hk(sl=0, what="print", data=None):
|
|||
# (name, factor, (offset_name, factor))
|
||||
# (name, (func, {args}))
|
||||
if not HK:
|
||||
V.update({c:data[a][c] for c in range(8)})
|
||||
V.update({c:data[a][c] for c in range(ND)})
|
||||
continue
|
||||
HK = HK[sl % len(HK)]
|
||||
for c in range(8):
|
||||
for c in range(ND):
|
||||
H = HK[c]
|
||||
if len(H) > 1:
|
||||
if isinstance(H[1], tuple):
|
||||
data[a][c] = H[1][0](data[a][c], **H[1][1])
|
||||
else:
|
||||
data[a][c] *= Vref*H[1]
|
||||
V[H[0]] = data[a][c]
|
||||
VV.update(V)
|
||||
for c in range(8):
|
||||
H = HK[c]
|
||||
if len(H) > 2:
|
||||
if isinstance(H[2], tuple):
|
||||
data[a][c] += VV[H[2][0]] * H[2][1]
|
||||
else:
|
||||
if len(H) > 2 and not isinstance(H[2], tuple):
|
||||
data[a][c] += H[2]
|
||||
if len(H) <= 2 or not isinstance(H[2], tuple):
|
||||
V[H[0]] = data[a][c]
|
||||
ddata[a][H[0]] = data[a][c]
|
||||
else:
|
||||
deferred.append((a,c,H))
|
||||
VV.update(V)
|
||||
while deferred:
|
||||
ndef = []
|
||||
nn = len(deferred)
|
||||
for a,c,H in deferred:
|
||||
if H[2][0] in VV:
|
||||
data[a][c] += VV[H[2][0]] * H[2][1]
|
||||
VV[H[0]] = data[a][c]
|
||||
ddata[a][H[0]] = data[a][c]
|
||||
else:
|
||||
ndef.append((a,c,H))
|
||||
deferred = ndef
|
||||
if len(deferred) >= nn:
|
||||
print("Unresolved offsets", repr(deferred), VV, file=sys.stderr)
|
||||
break
|
||||
|
||||
if what=="cooked":
|
||||
return sl, data
|
||||
|
|
@ -531,8 +616,8 @@ def print_trigger_config():
|
|||
ff = [dorn_config(0x084+i) for i in range(4)]
|
||||
tri.append(ff)
|
||||
e = ff[3]
|
||||
df = [_ifc.Areg(0x11+i) for i in range(3)]
|
||||
df.append(_ifc.Areg(5))
|
||||
df = [acmd(0x11+i) for i in range(3)]
|
||||
df.append(acmd(5))
|
||||
tri.append(df)
|
||||
ct0 = tri[0][0] | (tri[0][1]<<16) & 0xff0000
|
||||
ct1 = tri[1][0] | (tri[1][1]<<16) & 0xff0000
|
||||
|
|
@ -560,7 +645,7 @@ fifos enable SA/EV/HK HI {(e>>7)&7:03b} {(e>>10)&7:03b} {(e>>6)&1}
|
|||
def read_event(sl=None, ev=None):
|
||||
if ev is None:
|
||||
fifo_read(sl=sl, ev=True)
|
||||
ev = _ifc._read_fifo(2)
|
||||
ev = rfifo(2)
|
||||
if (ev[0] & 0xfffc) != 0x5718:
|
||||
raise ValueError(f"EV packet magic mismatch {ev[0]:04x}")
|
||||
Ba = ev[5]
|
||||
|
|
|
|||
|
|
@ -402,6 +402,7 @@ class dose_cmd(uart.uart):
|
|||
c = bytes((n, z)) + c + bytes(14)
|
||||
r, e, d = self.cmd("C", c[:16])
|
||||
s = int2flags(self.FPGA_FLGS, d[0])
|
||||
if self._verbose:
|
||||
print(f"FPGA cmd status {s!r}", file=sys.stderr)
|
||||
return d
|
||||
|
||||
|
|
@ -505,6 +506,7 @@ class dose_cmd(uart.uart):
|
|||
nnn -= nn
|
||||
d += dd[2:]
|
||||
r = struct.unpack(f">{len(d)//2}H", d)[:n]
|
||||
if self._verbose:
|
||||
print(f"FIFO[{fifo}] ← {[f"{rr:04x}" for rr in r]}", file=sys.stderr)
|
||||
return r
|
||||
|
||||
|
|
|
|||
|
|
@ -2044,7 +2044,7 @@ footprint=C0603
|
|||
T 40000 52750 5 10 1 1 90 4 1
|
||||
refdes=R50
|
||||
T 39850 52550 5 10 1 1 90 0 1
|
||||
value=10kΩ
|
||||
value=15kΩ
|
||||
}
|
||||
C 40600 51400 1 90 0 capacitor-1.sym
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue