Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
W
White Rabbit Calibration
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
White Rabbit Calibration
Commits
4587c77f
Commit
4587c77f
authored
Aug 01, 2018
by
Peter Jansweijer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
revised argparse, small python 2/3 issues, typo's
parent
b54104ca
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
60 deletions
+54
-60
edge_sfd.py
sw/abscal_scripts/edge_sfd.py
+54
-60
No files found.
sw/abscal_scripts/edge_sfd.py
View file @
4587c77f
...
...
@@ -26,24 +26,23 @@ Ch 4: SFP+ Calibartion SMA "N"
For a first run with one measurement using either:
edge_sdf.py <IP#>
edge_sdf.py <IP#> [-
-bitwidth=<20>] [--timebase=
<float>]
edge_sdf.py <IP#> [-
timebase
<float>]
Next look at the correlation plot and find the sample numbers for the pulse
and SFD maximum.
Redo measurement, now with the proper estimated max edge and sfd sample values.
edge_sdf.py <IP#> [-
-edge=<i>] [--sfd=<i>] [--bitwidth=<20>] [--timebase=
<float>]
edge_sdf.py <IP#> [-
edge <i>] [-sfd <i>] [-timebase
<float>]
Record the actual (mean) delay found and use this as a parameter for the estimated
delay. The default tolerance will automatically be narrowed to 10 ns (unless
otherwise specified)
Now a number of measurments (-m,--meas) can be taken to gather statistics
edge_sdf.py <IP#> [--edge=<i>] [--sfd=<i>] [--del=<f>] [--bitwidth=<20>] [--timebase=<float>] [--meas=<i>]
delay. Narrow the tolerance to 1 ns
Now a number of measurments (-m) can be taken to gather statistics
edge_sdf.py <IP#> [-edge <i>] [-sfd <i>][-timebase <float>] [-del <f>] [-meas <i>]
Usage:
edge_sdf.py IP#
edge_sdf.py IP# [-bitwidth
=<20>] [-timebase=
<float>]
edge_sdf.py IP# [-edge
=<i>] [-sfd=<i>] [-del=<f>] [-tol=50.0e-8] [-bitwidth=<20>] [-timebase=<float>] [-meas=<i
>]
edge_sdf.py IP# [-bitwidth
<20>] [-timebase
<float>]
edge_sdf.py IP# [-edge
<sample_no>] [-sfd <sample_no>] [-del <float>] [-tol <tolerance>] [-bitwidth <number>] [-timebase <float>] [-m <number
>]
edge_sdf.py -h | --help
IP IP number of the
instrument
[default 192.168.32.248]
IP IP number of the
oscilloscope
[default 192.168.32.248]
Options:
-edge <int> expect_max_edge [default: 0]
...
...
@@ -53,7 +52,7 @@ Options:
scypi array sample number where the correlation maximum
is expected (may be a negative number)
-delay <float> estimated_delay [default: 0]
-tol <float> tolerance [default: 1
0.0e-9
] specifies how far the
-tol <float> tolerance [default: 1] specifies how far the
measured delay may be off target. Tolerance helps you to
skip outliers in your measurements.
-bitwidth <int> bit width [default: 20] timestamp pulse width in number
...
...
@@ -71,6 +70,9 @@ import vxi11
import
scipy
import
numpy
import
matplotlib.pyplot
as
plt
plt
.
rcParams
[
'lines.linewidth'
]
=
1
import
pdb
# Add parent directory (containing 'lib') to the module search path
lib_path
=
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)))
...
...
@@ -123,7 +125,7 @@ def correlate_mathematical_eth_sfd():
delay values for the time between the SFD and Edge.
scope -- instance of python-vxi connected to scope625Zi oscilloscope
num_meas -- nuber of measurement to be taken.
num_meas -- nu
m
ber of measurement to be taken.
expect_max_edge -- edge correlation result sample number maximum is expected
expect_max_sfd -- edge correlation result sample number maximum is expected
...
...
@@ -163,21 +165,20 @@ def average_edge_to_sfd(scope, num_meas, bit_width, expect_max_edge, expect_max_
delay values for the time between the SFD and Edge.
scope -- instance of python-vxi connected to scope625Zi oscilloscope
num_meas -- nuber of measurement to be taken.
num_meas -- nu
m
ber of measurement to be taken.
bit_width -- the number of bits for a pulse (20 bits for 16 ns, 10 bits for 8 ns)
expect_max_edge -- edge correlation result sample number maximum is expected
expect_max_sfd -- edge correlation result sample number maximum is expected
estimate -- a delay estimate, used to verify proper measurements and enable
to skip outliers (due to wrong automatic correlation maximum
determination)
tollerance -- delay measurements outside tollerance are skiped (default 1 ns)
tollerance -- delay measurements outside tollerance are skiped (default 1 ns)
tolerance -- delay measurements outside tolerance are skipped (default 1 ns)
returns: <type 'numpy.ndarray'> -- an array of measured delay values
samples -- amount of samples in one waveform
sample_period -- the timebase used
firts_filename -- name of the first wavform file that contributed
last_filename -- name of the last wavform file that contributed
firts_filename -- name of the first wav
e
form file that contributed
last_filename -- name of the last wav
e
form file that contributed
"""
bit_rate
=
1.25e+9
# fixed for 1 Gbps to 1250 MHz (i.e. one bit = 800 ps)
...
...
@@ -186,7 +187,7 @@ def average_edge_to_sfd(scope, num_meas, bit_width, expect_max_edge, expect_max_
once
=
True
for
i
in
range
(
num_meas
):
d
,
filename
=
DSO
.
get_waveforms
(
scope
,
'1,3,4'
)
d
,
filename
=
DSO
.
get_waveforms
(
scope
,
[
1
,
3
,
4
]
)
wf_data
=
DSO
.
file_to_waveform
(
filename
)
samples
=
DSO
.
check_waveforms
(
wf_data
)
# Make sure the buffer holds an even number of samples
...
...
@@ -196,7 +197,9 @@ def average_edge_to_sfd(scope, num_meas, bit_width, expect_max_edge, expect_max_
if
once
==
True
:
#once = False
# extract the sample frequency from the preamble of the first enabled channel
first_channel
=
wf_data
.
keys
()[
0
]
#first_channel = wf_data.keys()[0] # Worked for Python 2...
channel_list
=
list
(
wf_data
.
keys
())
first_channel
=
channel_list
[
0
]
sample_period
=
wf_data
[
first_channel
][
"preamble"
][
"x_increment"
]
first_filename
=
filename
...
...
@@ -257,8 +260,8 @@ def average_edge_to_sfd(scope, num_meas, bit_width, expect_max_edge, expect_max_
"""
Usage:
edge_sdf.py IP#
edge_sdf.py IP# [-bitwidth
=<20>] [-timebase=
<float>]
edge_sdf.py IP# [-edge
=<i>] [-sfd=<i>] [-del=<f>] [-tol=50.0e-8] [-bitwidth=<20>] [-timebase=<float>] [-meas=<i
>]
edge_sdf.py IP# [-bitwidth
<20>] [-timebase
<float>]
edge_sdf.py IP# [-edge
<sample_no>] [-sfd <sample_no>] [-del <float>] [-tol <tolerance>] [-bitwidth <number>] [-timebase <float>] [-meas <number
>]
edge_sdf.py -h | --help
IP IP number of the instrument [default 192.168.32.248]
...
...
@@ -271,7 +274,7 @@ Options:
scypi array sample number where the correlation maximum
is expected (may be a negative number)
-delay <float> estimated_delay [default: 0]
-tol <float> tolerance [default: 1
0.0e-9
] specifies how far the
-tol <float> tolerance [default: 1] specifies how far the
measured delay may be off target. Tolerance helps you to
skip outliers in your measurements.
-bitwidth <int> bit width [default: 20] timestamp pulse width in number
...
...
@@ -287,41 +290,32 @@ if __name__ == "__main__":
import
argparse
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
"
IP"
,
help
=
"IP number of the instrument
"
,
default
=
"192.168.32.248"
)
parser
.
add_argument
(
"-edge"
,
help
=
"expected sample number for edge peak"
,
default
=
0
)
parser
.
add_argument
(
"-sfd"
,
help
=
"expected sample number for SFD peak"
,
default
=
0
)
parser
.
add_argument
(
"-delay"
,
help
=
"estimated delay"
,
default
=
0
)
parser
.
add_argument
(
"-tol"
,
help
=
"outliers tolerance"
,
default
=
10.0e-9
)
parser
.
add_argument
(
"-bitwidth"
,
help
=
"abscal_txts pulse width"
,
default
=
20
)
parser
.
add_argument
(
"-timebase"
,
help
=
"DSO tim
base"
,
default
=
50.0e-9
)
parser
.
add_argument
(
"-m"
,
help
=
"number of measurements"
,
default
=
1
)
parser
.
add_argument
(
"
scope"
,
type
=
str
,
help
=
"IP number of the oscilloscope
"
,
default
=
"192.168.32.248"
)
parser
.
add_argument
(
"-edge"
,
type
=
int
,
help
=
"expected sample number for edge peak"
,
default
=
0
)
parser
.
add_argument
(
"-sfd"
,
type
=
int
,
help
=
"expected sample number for SFD peak"
,
default
=
0
)
parser
.
add_argument
(
"-delay"
,
type
=
float
,
help
=
"estimated delay"
,
default
=
0.
0
)
parser
.
add_argument
(
"-tol"
,
type
=
float
,
help
=
"outliers tolerance"
,
default
=
1.0
)
parser
.
add_argument
(
"-bitwidth"
,
type
=
int
,
help
=
"abscal_txts pulse width"
,
default
=
20
)
parser
.
add_argument
(
"-timebase"
,
type
=
float
,
help
=
"DSO time
base"
,
default
=
50.0e-9
)
parser
.
add_argument
(
"-m"
,
type
=
int
,
help
=
"number of measurements"
,
default
=
1
)
args
=
parser
.
parse_args
()
IP
=
str
(
args
.
IP
)
expect_max_edge
=
int
(
args
.
edge
)
expect_max_sfd
=
int
(
args
.
sfd
)
estimated_delay
=
float
(
args
.
delay
)
tolerance
=
float
(
args
.
tol
)
bit_width
=
int
(
args
.
bitwidth
)
time_base
=
float
(
args
.
timebase
)
num_meas
=
int
(
args
.
m
)
print
(
"expected sample number for edge peak: "
,
expect_max_edge
)
print
(
"expected sample number for SDF peak: "
,
expect_max_sfd
)
print
(
"estimated delay: "
,
estimated_delay
)
print
(
"outlier tolerance: "
,
tolerance
)
print
(
"abscal_txts pulse width: "
,
bit_width
)
print
(
"DSO timbase: "
,
time_base
)
print
(
"number of measurements: "
,
num_meas
)
scope
=
vxi11
.
Instrument
(
IP
)
print
(
"expected sample number for edge peak: "
,
args
.
edge
)
print
(
"expected sample number for SDF peak: "
,
args
.
sfd
)
print
(
"estimated delay: "
,
args
.
delay
)
print
(
"outlier tolerance: "
,
args
.
tol
)
print
(
"abscal_txts pulse width: "
,
args
.
bitwidth
)
print
(
"DSO timbase: "
,
args
.
timebase
)
print
(
"number of measurements: "
,
args
.
m
)
scope
=
vxi11
.
Instrument
(
args
.
scope
)
# Initialize oscilloscope
# Use Channel 1 pulse input
# use Channel 3-4 Ethernet Frame input
DSO
.
osc_init
(
scope
,
time_
base
)
DSO
.
osc_init
(
scope
,
args
.
time
base
)
edge_to_sfd
,
samples
,
sample_period
,
first_filename
,
last_filename
=
average_edge_to_sfd
(
scope
,
num_meas
,
bit_width
,
expect_max_edge
,
expect_max_sfd
,
estimated_delay
,
tolerance
)
edge_to_sfd
,
samples
,
sample_period
,
first_filename
,
last_filename
=
average_edge_to_sfd
(
scope
,
num_meas
=
args
.
m
,
bit_width
=
args
.
bitwidth
,
expect_max_edge
=
args
.
edge
,
expect_max_sfd
=
args
.
sfd
,
estimate
=
args
.
delay
,
tolerance
=
args
.
tol
)
print
(
"Samples:"
,
samples
)
print
(
"Sample Period:"
,
sample_period
)
print
(
"first_filename:"
,
first_filename
)
...
...
@@ -335,7 +329,7 @@ if __name__ == "__main__":
for
i
in
edge_to_sfd
:
file
.
write
(
str
(
i
)
+
"
\n
"
)
file
.
write
(
"# Above are measured delays values exracted from the following range
\n
"
)
file
.
write
(
"# Above are measured delays values ex
t
racted from the following range
\n
"
)
file
.
write
(
"# of waveform files:
\n
"
)
file
.
write
(
"# First file: "
+
first_filename
+
"
\n
"
)
file
.
write
(
"# Last file: "
+
last_filename
+
"
\n
"
)
...
...
@@ -347,23 +341,23 @@ if __name__ == "__main__":
stdev_delay
=
numpy
.
std
(
edge_to_sfd
,
ddof
=
1
)
print
(
"Input parameters used:"
)
print
(
" expect_max_edge"
,
expect_max_
edge
)
print
(
" expect_max_sfd"
,
expect_max_
sfd
)
print
(
" estimated_delay"
,
estimated_
delay
)
print
(
" tolerance"
,
tolerance
)
print
(
" bit_width"
,
bit_
width
)
print
(
" time_base"
,
time_
base
)
print
(
" num_meas"
,
num_meas
)
print
(
" expect_max_edge"
,
args
.
edge
)
print
(
" expect_max_sfd"
,
args
.
sfd
)
print
(
" estimated_delay"
,
args
.
delay
)
print
(
" tolerance"
,
args
.
tol
)
print
(
" bit_width"
,
args
.
bit
width
)
print
(
" time_base"
,
args
.
time
base
)
print
(
" num_meas"
,
args
.
m
)
print
(
"Delay between edge and Start Of Frame delimiter:"
)
print
(
" number of measurements:"
,
num_meas
)
print
(
" number of measurements:"
,
args
.
m
)
print
(
" mean:"
,
mean_delay
)
print
(
" max:"
,
max_delay
)
print
(
" min:"
,
min_delay
)
print
(
" width:"
,
max_delay
-
min_delay
)
print
(
" st-dev:"
,
stdev_delay
)
hist_edge_sfd
=
plt
.
figure
(
"Historam delay pulse to SFD"
)
hist_edge_sfd
=
plt
.
figure
(
"Histo
g
ram delay pulse to SFD"
)
ax
=
hist_edge_sfd
.
add_subplot
(
111
)
ax
.
set_xlabel
(
'Time'
)
ax
.
set_ylabel
(
'Count'
)
...
...
@@ -371,7 +365,7 @@ if __name__ == "__main__":
ax
.
text
(
0.01
,
0.90
,
'std = {0:.6g}'
.
format
(
stdev_delay
),
transform
=
ax
.
transAxes
)
ax
.
text
(
0.01
,
0.85
,
'max = {0:.6g}'
.
format
(
max_delay
),
transform
=
ax
.
transAxes
)
ax
.
text
(
0.01
,
0.80
,
'min = {0:.6g}'
.
format
(
min_delay
),
transform
=
ax
.
transAxes
)
ax
.
text
(
0.01
,
0.75
,
'n = {0:d}'
.
format
(
num_meas
),
transform
=
ax
.
transAxes
)
ax
.
text
(
0.01
,
0.75
,
'n = {0:d}'
.
format
(
args
.
m
),
transform
=
ax
.
transAxes
)
ax
.
hist
(
edge_to_sfd
,
20
)
plt
.
show
()
...
...
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