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
cb941b31
Commit
cb941b31
authored
Aug 01, 2018
by
Peter Jansweijer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
python 2/3 issues, typo's
parent
4587c77f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
32 deletions
+30
-32
edge_edge.py
sw/abscal_scripts/edge_edge.py
+30
-32
No files found.
sw/abscal_scripts/edge_edge.py
View file @
cb941b31
...
...
@@ -21,10 +21,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
-------------------------------------------------------------------------------
Usage:
edge_edge.py IP# [-m
=
<number>]
edge_edge.py IP# [-m
<number>]
edge_edge.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:
-m <intr> number of measurements to be taken [default: 1]
...
...
@@ -38,6 +38,7 @@ import vxi11
import
scipy
import
numpy
import
matplotlib.pyplot
as
plt
plt
.
rcParams
[
'lines.linewidth'
]
=
1
# Add parent directory (containing 'lib') to the module search path
lib_path
=
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)))
...
...
@@ -46,6 +47,7 @@ sys.path.insert(0,lib_path)
# private imports:
import
lib.LeCroy8254
as
DSO
#import lib.Keysight_DSO_S_254A as DSO
#import lib.Agilent_DSO6104A as DSO
import
lib.pat_gen
as
pat_gen
import
lib.delay_determination
as
dd
...
...
@@ -60,7 +62,7 @@ D5_6 = "1010010110" # = 0xC5 (both +RD and -RD)
D16_2p
=
"1001000101"
# = 0x50 (+RD)
D16_2m
=
"0110110101"
# = 0x50 (-RD)
D21_2
=
"1010100101"
# = 0x55 is last preamble (both +RD and -RD)
D21_6
=
"1010100110"
# = 0xD5 is Start of Frame Delimit
t
er (both +RD and -RD)
D21_6
=
"1010100110"
# = 0xD5 is Start of Frame Delimiter (both +RD and -RD)
D1_0p
=
"1000101011"
D1_0m
=
"0111010100"
D27_7p
=
"0010011011"
...
...
@@ -89,25 +91,25 @@ def average_edge_to_edge(scope, num_meas, expect_max, estimate, tolerance = 1.0e
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 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)
tol
lerance -- delay measurements outside tollerance are ski
ped (default 1 ns)
tol
erance -- delay measurements outside tolerance are skip
ped (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
"""
lst_meas
=
[]
once
=
True
for
i
in
range
(
num_meas
):
d
,
filename
=
DSO
.
get_waveforms
(
scope
,
'1,3'
)
d
,
filename
=
DSO
.
get_waveforms
(
scope
,
[
1
,
3
]
)
wf_data
=
DSO
.
file_to_waveform
(
filename
)
samples
=
DSO
.
check_waveforms
(
wf_data
)
# Make sure the buffer holds an even number of samples
...
...
@@ -117,7 +119,9 @@ def average_edge_to_edge(scope, num_meas, expect_max, estimate, tolerance = 1.0e
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
...
...
@@ -154,7 +158,7 @@ def average_edge_to_edge(scope, num_meas, expect_max, estimate, tolerance = 1.0e
##
"""
Usage:
edge_edge.py IP# [-m
=
<number>]
edge_edge.py IP# [-m
<number>]
edge_edge.py -h | --help
IP IP number of the instrument [default 192.168.32.248]
...
...
@@ -164,7 +168,7 @@ Options:
measured delay may be off target. Tolerance helps you to
skip outliers in your measurements.
-timebase <float> time base [default: 20.0e-8] # 20 ns/div
-m
<intr
> number of measurements to be taken [default: 1]
-m
<int
> number of measurements to be taken [default: 1]
-h --help Show help
"""
...
...
@@ -172,32 +176,26 @@ 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
(
"-peak"
,
help
=
"expected sample number for 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
(
"-timebase"
,
help
=
"DSO tim
base"
,
default
=
20.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
(
"-peak"
,
type
=
int
,
help
=
"expected sample number for peak"
,
default
=
0
)
parser
.
add_argument
(
"-delay"
,
type
=
float
,
help
=
"estimated delay"
,
default
=
0
)
parser
.
add_argument
(
"-tol"
,
type
=
float
,
help
=
"outliers tolerance"
,
default
=
10.0e-9
)
parser
.
add_argument
(
"-timebase"
,
type
=
float
,
help
=
"DSO time
base"
,
default
=
20.0e-9
)
parser
.
add_argument
(
"-m"
,
type
=
int
,
help
=
"number of measurements"
,
default
=
1
)
args
=
parser
.
parse_args
()
# When oscilloscope triggers on Channel 1 and trigger is set to the middle
# of the screen then the expected edge maximum for edge and SFD are at:
IP
=
str
(
args
.
IP
)
expect_max
=
int
(
args
.
peak
)
estimated_delay
=
float
(
args
.
delay
)
tolerance
=
float
(
args
.
tol
)
time_base
=
float
(
args
.
timebase
)
num_meas
=
int
(
args
.
m
)
scope
=
vxi11
.
Instrument
(
IP
)
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
.
timebase
)
meas
,
samples
,
sample_period
,
first_filename
,
last_filename
=
average_edge_to_edge
(
scope
,
num_meas
=
args
.
m
,
expect_max
=
args
.
peak
,
estimate
=
args
.
delay
,
tolerance
=
args
.
tol
)
meas
,
samples
,
sample_period
,
first_filename
,
last_filename
=
average_edge_to_edge
(
scope
,
num_meas
,
expect_max
,
estimated_delay
,
tolerance
)
print
(
"Samples:"
,
samples
)
print
(
"Sample Period:"
,
sample_period
)
print
(
"first_filename:"
,
first_filename
)
...
...
@@ -211,7 +209,7 @@ if __name__ == "__main__":
for
i
in
meas
:
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
"
)
...
...
@@ -223,14 +221,14 @@ if __name__ == "__main__":
stdev_delay
=
numpy
.
std
(
meas
,
ddof
=
1
)
print
(
"Delay between oscilloscope channels:"
)
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_edge
=
plt
.
figure
(
"Historam delay edge -> edge"
)
hist_edge_edge
=
plt
.
figure
(
"Histo
g
ram delay edge -> edge"
)
ax
=
hist_edge_edge
.
add_subplot
(
111
)
ax
.
set_xlabel
(
'Time'
)
ax
.
set_ylabel
(
'Count'
)
...
...
@@ -238,7 +236,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
(
meas
,
20
)
plt
.
show
()
else
:
...
...
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