Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
E
euro-adc-65m-14b-40cha-gw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
eurocard
euro-adc-65m-14b-40cha
euro-adc-65m-14b-40cha-gw
Commits
3787e823
Commit
3787e823
authored
Oct 17, 2017
by
Dan Saunders
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
first version of bulk adc alignment (needs updating)
parent
2b342268
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
193 additions
and
11 deletions
+193
-11
align_adc.py
projects/64ch/software/align_adc.py
+9
-9
align_adc_bulk.py
projects/64ch/software/align_adc_bulk.py
+157
-0
inspect_tapSlip_config.py
projects/64ch/software/inspect_tapSlip_config.py
+6
-0
setup.py
projects/64ch/software/setup.py
+21
-2
No files found.
projects/64ch/software/align_adc.py
View file @
3787e823
...
...
@@ -35,7 +35,7 @@ offsets = [0, 13, 2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11]
invert
=
[
0x1d
,
0x1e
,
0x1f
,
0x20
,
0x21
,
0x22
,
0x23
,
0x24
,
0x25
]
uhal
.
setLogLevelTo
(
uhal
.
LogLevel
.
ERROR
)
board
=
uhal
.
getDevice
(
"board"
,
"ipbusudp-2.0://192.168.235.
50
:50001"
,
"file://addrtab/top.xml"
)
board
=
uhal
.
getDevice
(
"board"
,
"ipbusudp-2.0://192.168.235.
86
:50001"
,
"file://addrtab/top.xml"
)
#board = uhal.getDevice("board", "ipbusudp-2.0://192.168.235.16:50001", "file://addrtab/top_sim.xml")
board
.
getClient
()
.
setTimeoutPeriod
(
10000
)
...
...
@@ -50,7 +50,7 @@ board.dispatch()
time
.
sleep
(
1
)
chans
=
range
(
0x
1
)
chans
=
range
(
0x
64
)
adcs
=
range
(
0x10
)
patt
=
0x0ff
cap_len
=
0x80
...
...
@@ -89,18 +89,18 @@ for i_chan in chans:
time
.
sleep
(
0.01
)
while
True
:
r
=
board
.
getNode
(
"daq.chan.csr.stat"
)
.
read
()
#
board.getNode("daq.chan.buf.addr").write(0x0)
#
d = board.getNode("daq.chan.buf.data").readBlock(cap_len)
board
.
getNode
(
"daq.chan.buf.addr"
)
.
write
(
0x0
)
d
=
board
.
getNode
(
"daq.chan.buf.data"
)
.
readBlock
(
cap_len
)
board
.
dispatch
()
if
r
&
0x1
==
1
:
break
print
"Crap no capture"
,
hex
(
i_chan
),
hex
(
i_slip
),
hex
(
i_tap
),
hex
(
r
),
time
.
clock
()
c
=
0
#
for w in d:
#
if int(w) & 0x3ff == patt:
#
c += 1
#
print hex(w),
#
print hex(i_chan), hex(i_slip), hex(i_tap), c
for
w
in
d
:
if
int
(
w
)
&
0x3ff
==
patt
:
c
+=
1
#
print hex(w),
#
print hex(i_chan), hex(i_slip), hex(i_tap), c
res
[
offsets
[
i_slip
]
*
taps_per_slip
+
(
31
-
i_tap
)]
=
(
c
==
cap_len
)
ok
=
(
c
==
cap_len
)
or
ok
board
.
getNode
(
"daq.timing.csr.ctrl.chan_inc"
)
.
write
(
0x1
)
# Increment tap
...
...
projects/64ch/software/align_adc_bulk.py
0 → 100755
View file @
3787e823
#!/usr/bin/python
import
dataset
import
uhal
import
time
import
sys
import
collections
sys
.
path
.
append
(
'/home/dsaunder/workspace/go_projects/src/bitbucket.org/solidexperiment/readout-software/scripts/'
)
import
detector_config_tools
def
spi_config
(
spi
,
div
,
ctrl
,
ss
):
spi
.
getNode
(
"divider"
)
.
write
(
0xf
)
# Divide 31.25MHz ipbus clock by 32
spi
.
getNode
(
"ctrl"
)
.
write
(
0x2410
)
# 16b transfer length, auto CSN
spi
.
getNode
(
"ss"
)
.
write
(
0x1
)
# Enable SPI slave 0
spi
.
getClient
()
.
dispatch
()
def
spi_write
(
spi
,
addr
,
data
):
spi
.
getNode
(
"d0"
)
.
write
((
addr
<<
8
)
+
data
)
# Write data into addr
spi
.
getNode
(
"ctrl"
)
.
write
(
0x2510
)
# Do it
spi
.
getClient
()
.
dispatch
()
r
=
spi
.
getNode
(
"ctrl"
)
.
read
()
spi
.
getClient
()
.
dispatch
()
if
r
&
0x100
!=
0
:
print
"SPI write error"
,
hex
(
addr
),
hex
(
data
)
def
spi_read
(
spi
,
addr
):
spi
.
getNode
(
"d0"
)
.
write
(
0x8000
+
(
addr
<<
8
))
# Read from addr
spi
.
getNode
(
"ctrl"
)
.
write
(
0x2510
)
# Do it
spi
.
getClient
()
.
dispatch
()
d
=
spi
.
getNode
(
"d0"
)
.
read
()
r
=
spi
.
getNode
(
"ctrl"
)
.
read
()
spi
.
getClient
()
.
dispatch
()
if
r
&
0x100
!=
0
:
print
"SPI read error"
,
hex
(
addr
)
return
d
&
0xffff
offsets
=
[
0
,
13
,
2
,
1
,
4
,
3
,
6
,
5
,
8
,
7
,
10
,
9
,
12
,
11
]
invert
=
[
0x1d
,
0x1e
,
0x1f
,
0x20
,
0x21
,
0x22
,
0x23
,
0x24
,
0x25
]
uhal
.
setLogLevelTo
(
uhal
.
LogLevel
.
ERROR
)
# Db stuff.
ips
=
detector_config_tools
.
currentIPs
(
False
)
ips
=
[
92
]
db
=
dataset
.
connect
(
'mysql://DAQGopher:gogogadgetdatabase@localhost/solid_phase1_running'
)
configID
=
0
#first time case
if
len
(
db
[
'TapSlips'
])
!=
0
:
configID
=
max
(
db
[
'TapSlips'
][
'configID'
])[
'configID'
]
+
1
print
'Bulk scanning ips:'
,
ips
print
'New TapSlips configID'
,
configID
for
ith_ip
in
ips
:
ith_slips
,
ith_taps
=
[],
[]
print
'
\n
About to align ip:'
,
ith_ip
board
=
uhal
.
getDevice
(
"board"
,
"ipbusudp-2.0://192.168.235."
+
str
(
ith_ip
)
+
":50001"
,
"file://addrtab/top.xml"
)
board
.
getClient
()
.
setTimeoutPeriod
(
10000
)
v
=
board
.
getNode
(
"csr.id"
)
.
read
()
board
.
dispatch
()
board
.
getNode
(
"daq.timing.csr.ctrl.rst"
)
.
write
(
1
)
# Hold clk40 domain in reset
board
.
dispatch
()
board
.
getNode
(
"csr.ctrl.soft_rst"
)
.
write
(
1
)
# Reset ipbus registers
board
.
dispatch
()
time
.
sleep
(
1
)
chans
=
range
(
0x1
)
adcs
=
range
(
0x10
)
patt
=
0x0ff
cap_len
=
0x80
taps_per_slip
=
22
spi
=
board
.
getNode
(
"io.spi"
)
spi_config
(
spi
,
0xf
,
0x2410
,
0x1
)
# Divide 31.25MHz ipbus clock by 32; 16b transfer length, auto CSN; Enable SPI slave 0
for
i
in
adcs
:
board
.
getNode
(
"csr.ctrl.io_sel"
)
.
write
(
i
)
# Select ADC bank to talk to
board
.
dispatch
()
spi_write
(
spi
,
0x0
,
0x80
)
# Reset ADC
spi_write
(
spi
,
0x2
,
0x05
)
# 14b 1 lane mode
spi_write
(
spi
,
0x3
,
0x80
+
(
patt
>>
8
))
# Test pattern
spi_write
(
spi
,
0x4
,
patt
&
0xff
)
# Test pattern
for
i_chan
in
chans
:
board
.
getNode
(
"csr.ctrl.chan"
)
.
write
(
i_chan
)
# Talk to channel 0
board
.
getNode
(
"daq.chan.csr.ctrl.mode"
)
.
write
(
0x1
)
# Set to capture mode
board
.
getNode
(
"daq.chan.csr.ctrl.src"
)
.
write
(
0x0
)
# Set source to ADC
board
.
getNode
(
"daq.chan.csr.ctrl.en_sync"
)
.
write
(
0x1
)
# Enable sync commands
if
i_chan
in
invert
:
board
.
getNode
(
"daq.chan.csr.ctrl.invert"
)
.
write
(
0x1
)
# Invert the data
board
.
getNode
(
"daq.chan.csr.ctrl.en_buf"
)
.
write
(
0x1
)
# Enable this channel
board
.
dispatch
()
res
=
[
False
]
*
(
15
*
taps_per_slip
)
tr
=
[]
for
i_slip
in
range
(
1
):
ok
=
False
for
i_tap
in
range
(
32
):
board
.
getNode
(
"daq.timing.csr.ctrl.chan_cap"
)
.
write
(
0x1
)
# Capture
board
.
getNode
(
"daq.timing.csr.ctrl.chan_cap"
)
.
write
(
0x0
)
board
.
dispatch
()
time
.
sleep
(
0.01
)
while
True
:
r
=
board
.
getNode
(
"daq.chan.csr.stat"
)
.
read
()
board
.
dispatch
()
if
r
&
0x1
==
1
:
break
print
"Crap no capture"
,
hex
(
i_chan
),
hex
(
i_slip
),
hex
(
i_tap
),
hex
(
r
),
time
.
clock
()
c
=
0
res
[
offsets
[
i_slip
]
*
taps_per_slip
+
(
31
-
i_tap
)]
=
(
c
==
cap_len
)
ok
=
(
c
==
cap_len
)
or
ok
board
.
getNode
(
"daq.timing.csr.ctrl.chan_inc"
)
.
write
(
0x1
)
# Increment tap
board
.
getNode
(
"daq.timing.csr.ctrl.chan_inc"
)
.
write
(
0x0
)
board
.
dispatch
()
if
ok
:
tr
.
append
(
i_slip
)
board
.
getNode
(
"daq.timing.csr.ctrl.chan_slip"
)
.
write
(
0x1
)
# Increment slip
board
.
getNode
(
"daq.timing.csr.ctrl.chan_slip"
)
.
write
(
0x0
)
board
.
dispatch
()
trp
=
""
min
=
0
max
=
0
non_cont
=
False
for
i
in
range
(
len
(
res
)
-
1
):
if
res
[
i
+
1
]
and
not
res
[
i
]:
if
min
==
0
:
min
=
i
+
1
else
:
non_cont
=
True
elif
res
[
i
]
and
not
res
[
i
+
1
]:
if
max
==
0
:
max
=
i
else
:
non_cont
=
True
if
res
[
i
]
==
None
:
trp
+=
"_"
elif
res
[
i
]:
trp
+=
"+"
else
:
trp
+=
"."
a
=
int
((
min
+
max
)
/
2
)
d_slip
=
offsets
.
index
(
a
//
taps_per_slip
)
d_tap
=
a
%
taps_per_slip
print
trp
db
[
'TapSlips'
]
.
insert
({
'configID'
:
int
(
configID
),
'ip'
:
ith_ip
,
'tap'
:
d_tap
,
'slip'
:
d_slip
,
'channel'
:
i_chan
})
ith_slips
.
append
(
d_slip
)
ith_taps
.
append
(
d_tap
)
if
not
non_cont
:
print
"Chan, rec_slip, rec_tap:"
,
hex
(
i_chan
),
hex
(
d_slip
),
hex
(
d_tap
)
else
:
print
"Chan, NON CONTINUOUS RANGE"
,
hex
(
i_chan
),
trp
print
'ith_slips'
,
ith_slips
print
'ith_taps'
,
ith_taps
projects/64ch/software/inspect_tapSlip_config.py
0 → 100644
View file @
3787e823
import
dataset
db
=
dataset
.
connect
(
'mysql://DAQGopher:gogogadgetdatabase@localhost/solid_phase1_running'
)
for
entry
in
db
[
'TapSlips'
]:
print
entry
print
max
(
db
[
'Config'
][
'configID'
])
projects/64ch/software/setup.py
View file @
3787e823
...
...
@@ -6,8 +6,8 @@ import sys
from
I2CuHal
import
I2CCore
from
si5344
import
si5344
uhal
.
setLogLevelTo
(
uhal
.
LogLevel
.
ERROR
)
hw
=
uhal
.
getDevice
(
"board"
,
"ipbusudp-2.0://192.168.235.
50
:50001"
,
"file://addrtab/top.xml"
)
uhal
.
setLogLevelTo
(
uhal
.
LogLevel
.
INFO
)
hw
=
uhal
.
getDevice
(
"board"
,
"ipbusudp-2.0://192.168.235.
86
:50001"
,
"file://addrtab/top.xml"
)
hw
.
getNode
(
"csr.ctrl.soft_rst"
)
.
write
(
1
)
# Reset ipbus registers
hw
.
dispatch
()
...
...
@@ -27,3 +27,22 @@ fq = hw.getNode("io.freq_ctr.freq.count").read();
fv
=
hw
.
getNode
(
"io.freq_ctr.freq.valid"
)
.
read
();
hw
.
dispatch
()
print
"Freq:"
,
int
(
fv
),
int
(
fq
)
*
119.20928
/
1000000
;
'''
f_stat = hw.getNode("csr.stat").read();
hw.dispatch()
print "csr.stat", hex(f_stat)
f_ctrl = hw.getNode("csr.ctrl").read();
hw.dispatch()
print "csr.ctrl:", hex(f_ctrl)
f_ctrl_2 = hw.getNode("daq.trig.csr.stat").read();
hw.dispatch()
print "daq.trig.csr.stat", hex(f_ctrl_2)
# Checks for sync
fw = hw.getNode("daq.timing.csr.stat.wait_sync").read();
hw.dispatch()
#print "wait_sync, sync_err:", int(fw), int(fs)
'''
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment