Commit 29db66a2 authored by Peter Jansweijer's avatar Peter Jansweijer

osc_init fucnction no longer general => init dictonairy can now be forwarded

parent e829aa20
...@@ -195,7 +195,18 @@ if __name__ == "__main__": ...@@ -195,7 +195,18 @@ if __name__ == "__main__":
# Initialize oscilloscope # Initialize oscilloscope
# Use Channel 1 pulse input # Use Channel 1 pulse input
# use Channel 3-4 Ethernet Frame input # use Channel 3-4 Ethernet Frame input
DSO.osc_init(scope, args.timebase) init = { \
'channel' : [ 1 , 0 , 1 , 1 ], \
'offset' : [ 0.0 , 0.0, 0.0 , 0.0 ], \
'volt_div' : [ 0.1 , 1.0, 0.25, 0.25 ], \
'50ohm' : [ 1 , 0 , 1 , 1 ], \
'trig' : [ 1 ], \
'trig_level' : [ 0.15 ], \
'timebase' : [ float(args.timebase) ], \
'refclk' : [ 'ext' ], \
}
DSO.osc_init(scope, init)
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=args.m, expect_max=args.peak, estimate=args.delay, tolerance=args.tol)
......
...@@ -313,7 +313,17 @@ if __name__ == "__main__": ...@@ -313,7 +313,17 @@ if __name__ == "__main__":
# Initialize oscilloscope # Initialize oscilloscope
# Use Channel 1 pulse input # Use Channel 1 pulse input
# use Channel 3-4 Ethernet Frame input # use Channel 3-4 Ethernet Frame input
DSO.osc_init(scope, args.timebase) init = { \
'channel' : [ 1 , 0 , 1 , 1 ], \
'offset' : [ 0.0 , 0.0, 0.0 , 0.0 ], \
'volt_div' : [ 0.25, 1.0, 0.1 , 0.1 ], \
'50ohm' : [ 1 , 0 , 1 , 1 ], \
'trig' : [ 1 ], \
'trig_level' : [ 0.15 ], \
'timebase' : [ float(args.timebase) ], \
'refclk' : [ 'ext' ], \
}
DSO.osc_init(scope, init)
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) 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("Samples:",samples)
......
...@@ -584,7 +584,17 @@ if __name__ == "__main__": ...@@ -584,7 +584,17 @@ if __name__ == "__main__":
restarts = int(args.r) # number of link restarts over which the delta_delay is averaged restarts = int(args.r) # number of link restarts over which the delta_delay is averaged
#scope = vxi11.Instrument(args.dso) #scope = vxi11.Instrument(args.dso)
#osc_init(scope, time_base = 1.0e-9) #init = { \
# 'channel' : [ 0 , 0 , 1 , 1 ], \
# 'offset' : [ 0.0 , 0.0, -1.5 , -1.5 ], \
# 'volt_div' : [ 0.25, 1.0, 0.5 , 0.5 ], \
# '50ohm' : [ 0 , 0 , 1 , 1 ], \
# 'trig' : [ 3 ], \
# 'trig_level' : [ 0.14 ], \
# 'timebase' : [ 1.0e-9 ], \
# 'refclk' : [ 'ext' ], \
#}
#DSO.osc_init(scope, init)
# Initialize Time Interval Counter (1-2) # Initialize Time Interval Counter (1-2)
# Use Channel 1 PPS SPEC-1 (50 Ohm, Level 1.4) # Use Channel 1 PPS SPEC-1 (50 Ohm, Level 1.4)
......
...@@ -517,56 +517,87 @@ def file_to_waveform(filename): ...@@ -517,56 +517,87 @@ def file_to_waveform(filename):
return waveform_data return waveform_data
############################################################################ ############################################################################
def osc_init(scope, time_base = 50.0e-9):
def osc_init(scope, init):
""" """
Initialize the Oscilloscope for the timestamp edge to SFD measurement. Initialize the KEYSIGHT TECHNOLOGIES,DSO
scope -- instance of python-vxi connected to the oscilloscope scope -- instance of python-vxi connected to the oscilloscope
time_base -- <float> time base, default 50 ns/div init -- <dict> for example:
init = { \
'channel' : [ 1 , 0 , 1 , 0 ], \
'offset' : [ 0.0, 0.0, 0.0 , 0.0 ], \
'volt_div' : [ 0.5, 1.0, 0.125, 1.0 ], \
'50ohm' : [ 1 , 0 , 1 , 0 ], \
#'sinxx' : [ 0 , 0 , 0 , 0 ], \
'trig' : [ 1 ], \
'trig_level' : [ 0.14 ], \
'timebase' : [ 50e-9 ], \
'refclk' : [ 'ext' ], \
""" """
#scope = vxi11.Instrument("192.168.32.248") #scope = vxi11.Instrument("192.168.32.248")
print(scope.ask("*IDN?")) print(scope.ask("*IDN?"))
# Returns 'KEYSIGHT TECHNOLOGIES,DSOS254A,MY55160101,05.50.0004' # Returns 'KEYSIGHT TECHNOLOGIES,DSOS254A,MY55160101,05.50.0004'
# Use Channel 1 pulse input # Initialize the oscilloscope trigger
# use Channel 3 Ethernet Frame input
# A fixed trigger level is important for proper timing measurement
# Choose 1.4 Volt for a direct signal but 0.8 Volt when the signal
# is split by a power splitter
scope.write(":TRIGger:EDGE:SOURce CHANnel1")
scope.write(":TRIGger:SWEep TRIGgered") scope.write(":TRIGger:SWEep TRIGgered")
trig = str(init['trig'][0])
triglevel = str(float(init['trig_level'][0]))
scope.write(":TRIGger:EDGE:SOURce CHANnel"+ trig)
scope.write(":TRIGger:LEVel CHANnel"+ trig + ", " + triglevel)
use_power_splitter = True """
# For Keysight sinxx interpolation is a "Horizontal" setting that
if use_power_splitter: # applies to all enabled channels! Default = False
scope.write(":TRIGger:LEVel CHANnel1, 0.15") sinxx = False
scope.write(":CHANnel1:RANGe 2.0") # 250 mV/div """
else:
scope.write(":TRIGger:LEVel CHANnel1, 0.3")
scope.write(":CHANnel1:RANGe 4.0") # 500 mV/div
scope.write(":CHANnel1:INPut DCFifty")
scope.write(":CHANnel1:OFFSet 0.0")
scope.write(":CHANnel3:INPut DCFifty") for ch in range(4):
scope.write(":CHANnel3:OFFSet 0.0") # Set channel ON/OFF
scope.write(":CHANnel3:RANGe 2.0") # 250 mV/div if init['channel'][ch] == 1:
scope.write(":CHANnel4:INPut DCFifty") scope.write(":CHANnel" + str(ch+1) + ":DISPlay ON")
scope.write(":CHANnel4:OFFSet 0.0") else:
scope.write(":CHANnel4:RANGe 2.0") # 250 mV/div scope.write(":CHANnel" + str(ch+1) + ":DISPlay OFF")
# Set channel Offset
scope.write(":CHANnel" + str(ch+1) + ":OFFSet " + str(float(init['offset'][ch])))
# Set channel Volt/Div
volt_div = float(init['volt_div'][ch]/0.125) # Volt/Div is per 125 mV
scope.write(":CHANnel" + str(ch+1) + ":RANGe " + str(volt_div))
# Set channel Coupling
#'50ohm' : [ 1 , 0 , 1 , 0 ], \
if init['50ohm'][ch] == 1:
scope.write(":CHANnel" + str(ch+1) + ":INPut DCFifty")
else:
scope.write(":CHANnel" + str(ch+1) + ":INPut DC")
"""
# Set Interpolation for all used channels to "16 point Sin(x)/x"
#'sinxx' : [ 1 , 0 , 1 , 0 ], \
# Check if one of the channels is set to sinxx then enable sinxx for all
if init['sinxx'][ch] == 1:
sinxx = True
if sinxx:
scope.write(":ACQuire:INTerpolate INT16")
else:
scope.write(":ACQuire:INTerpolate OFF")
"""
# Trigger in the centre of the screen; important for maximum estimations # Trigger in the centre of the screen and set timebase
# forwarded to function average_edge_to_sfd
scope.write(":TIMebase:DELay 0") scope.write(":TIMebase:DELay 0")
scope.write(":TIMebase:RANGe "+str(10*time_base)) # set 50 ns/div scope.write(":TIMebase:RANGe "+str(10*float(init['timebase'][0]))) # set 50 ns/div
scope.write(":TIMebase:REFClock ON") # set external refrence clock
return # Set internal/external 10 MHz timebase
if init['refclk'][0] == 'ext':
scope.write(":TIMebase:REFClock ON")
else:
scope.write(":TIMebase:REFClock OFF")
return
############################################################################ ############################################################################
## ##
## If run from commandline, we can test the library ## If run from commandline, we can test the library
......
...@@ -705,55 +705,74 @@ def file_to_waveform(filename): ...@@ -705,55 +705,74 @@ def file_to_waveform(filename):
return waveform_data return waveform_data
############################################################################ ############################################################################
def osc_init(scope, time_base = 50.0e-9):
def osc_init(scope, init):
""" """
Initialize the Oscilloscope for the timestamp edge to SFD measurement. Initialize the LeCroy,DSO
scope -- instance of python-vxi connected to the oscilloscope scope -- instance of python-vxi connected to the oscilloscope
time_base -- <float> time base, default 50 ns/div init -- <dict> for example:
init = { \
'channel' : [ 1 , 0 , 1 , 0 ], \
'offset' : [ 0.0, 0.0, 0.0 , 0.0 ], \
'volt_div' : [ 0.5, 1.0, 0.125, 1.0 ], \
'50ohm' : [ 1 , 0 , 1 , 0 ], \
#'sinxx' : [ 0 , 0 , 0 , 0 ], \
'trig' : [ 1 ], \
'trig_level' : [ 0.14 ], \
'timebase' : [ 50e-9 ], \
'refclk' : [ 'ext' ], \
""" """
#scope = vxi11.Instrument("192.168.32.243") #scope = vxi11.Instrument("192.168.32.248")
print(scope.ask("*IDN?")) print(scope.ask("*IDN?"))
# Returns '*IDN LECROY,HDO4034-MS,LCRY-HDO,7.9.0' # Returns 'LECROY,WAVERUNNER8254M-MS,LCRY4253N20398,8.4.1'
# Use Channel 1 pulse input # Initialize the oscilloscope trigger
# use Channel 3 Ethernet Frame input trig = str(init['trig'][0])
triglevel = str(float(init['trig_level'][0]))
# A fixed trigger level is important for proper timing measurement scope.write("TRIG_SELECT EDGE,SR,C" + trig)
# MiniCircuits Splitters ZFRSC-123+ have ~ 6 + 3,75 dB attenuation (~ factor 3). scope.write("C" + trig + ":TRIG_LEVEL " + triglevel)
# A 2,4 V signal split once results in 0,8 V, slit twice in 260 mV.
scope.write("TRIG_SELECT EDGE,SR,C1") for ch in range(4):
# Set channel ON/OFF
use_power_splitter = True if init['channel'][ch] == 1:
scope.write("C" + str(ch+1) + ":TRACE ON")
if use_power_splitter: else:
scope.write("C1:TRIG_LEVEL 0.15") scope.write("C" + str(ch+1) + ":TRACE OFF")
scope.write("C1:Volt_DIV 0.25")
else: # Set channel Offset
scope.write("C1:TRIG_LEVEL 0.3") scope.write("C" + str(ch+1) + ":OFFSET " + str(float(init['offset'][ch])))
scope.write("C1:Volt_DIV 0.5")
# Set channel Volt/Div
scope.write("C1:COUPLING D50") volt_div = float(init['volt_div'][ch])
scope.write("C1:OFFSET 0.0") scope.write("C" + str(ch+1) + ":Volt_DIV " + str(volt_div))
scope.write("VBS 'app.Acquisition.C1.InterpolateType = \"sinxx\"'") # Set channel Coupling
#'50ohm' : [ 1 , 0 , 1 , 0 ], \
scope.write("C3:COUPLING D50") if init['50ohm'][ch] == 1:
scope.write("C3:OFFSET 0.0") scope.write("C" + str(ch+1) + ":COUPLING D50")
scope.write("C3:Volt_DIV 0.25") else:
scope.write("VBS 'app.Acquisition.C3.InterpolateType = \"sinxx\"'") scope.write("C" + str(ch+1) + ":COUPLING D1M")
scope.write("C4:COUPLING D50")
scope.write("C4:OFFSET 0.0")
scope.write("C4:Volt_DIV 0.25")
scope.write("VBS 'app.Acquisition.C4.InterpolateType = \"sinxx\"'")
"""
# Set Interpolation for all used channels to "Compatible Mode 10"
#'sinxx' : [ 1 , 0 , 1 , 0 ], \
if init['sinxx'][ch] == 1:
scope.write("VBS 'app.Acquisition.C" + str(ch+1) + ".InterpolateType = \"sinxx\"'")
else:
scope.write("VBS 'app.Acquisition.C" + str(ch+1) + ".InterpolateType = \"linear\"'")
"""
# Trigger in the centre of the screen; important for maximum estimations # Trigger in the centre of the screen and set timebase
# forwarded to function average_edge_to_sfd
scope.write("TRIG_DELAY 0 ns") scope.write("TRIG_DELAY 0 ns")
scope.write("TIME_DIV "+str(time_base)) # set 50 ns/div scope.write("TIME_DIV "+str(float(init['timebase'][0])))
scope.write("REFERENCE_CLOCK EXTERNAL") # set external refrence clock
# Set internal/external 10 MHz timebase
if init['refclk'][0] == 'ext':
scope.write("REFERENCE_CLOCK EXTERNAL")
else:
scope.write("REFERENCE_CLOCK INTERNAL")
return return
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment