Commit 9f42c6dd authored by Peter Jansweijer's avatar Peter Jansweijer

lined up LeCroy8254 with Keysight_DSO_S_254A

parent bb9ad97f
......@@ -22,17 +22,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
-------------------------------------------------------------------------------
Usage:
LeCroy8254.py <IP#> [-c <1,2,3,4>] [-a <averages>] [-o <dir>]
LeCroy8254.py <IP#> [-c 1234>] [-n <averages>] [-o <dir>] [-m <measurements>]
LeCroy8254.py -h | --help
IP IP number of the Oscilloscope
(for example: 192.168.32.243 which is its DevNet IP number)
IP IP number of the instrument [default 192.168.32.243]
Options:
-c <1,2,3,4> channel number
-a <number> number of averages [default: 1]
-c 1234 channel number [default 1234]
-n <number> number of averages [default: 1]
-o <dir> optional directory for output file storage [default: "data/"]
-h --help Show this screen.
-m <number> number of measurments
-h --help Show help
"""
......@@ -111,7 +111,7 @@ def get_waveforms(scope, channels=[1,2,3,4],num_avg=1,output_dir="data"):
src_str = "C"
scope.write("TRIG_MODE STOP")
for chan in channels.split(','):
for chan in channels:
scope.write(src_str + str(chan)+':TRACE ON') # For Function or Channel
# Note that setting an Average Sweep number does not mean that acquisition
# automatically takes the right number of sweeps. This needs to be
......@@ -159,7 +159,7 @@ def get_waveforms(scope, channels=[1,2,3,4],num_avg=1,output_dir="data"):
# scope.read_raw() returns <bytes>
# returned data = <bytes>
if python_version == 3:
for chan in channels.split(','):
for chan in channels:
ch_preamble_bytes = (b'#preamble:\n')
scope.write((src_str+str(chan)+":INSPECT? WAVEDESC")+"\n")
ch_preamble_bytes += scope.read_raw()
......@@ -199,7 +199,7 @@ def get_waveforms(scope, channels=[1,2,3,4],num_avg=1,output_dir="data"):
# scope.read_raw() returns <str>
# returned data = <list> with items type <str>
elif python_version == 2:
for chan in channels.split(','):
for chan in channels:
channel_preamble.append("#preamble:\n")
scope.write((src_str+str(chan)+":INSPECT? WAVEDESC")+"\n")
channel_preamble.append(scope.read())
......@@ -517,7 +517,7 @@ def raw_to_scipy_array (waveform_raw, byte_order, preamble):
#Convert to unit values.
y_data=scipy.array(struct.unpack(format_string, waveform_raw),
dtype=scipy.float64) * preamble["y_increment"] - preamble["y_origin"]
dtype=scipy.float64) * preamble["y_increment"] + preamble["y_origin"]
x_data=scipy.arange(preamble["points"]) * preamble["x_increment"] + preamble["x_origin"]
#create array with x,y axis values.
......@@ -543,9 +543,10 @@ def check_waveforms(waveform_data):
first = False
channel = ch
points = waveform_data[ch]["preamble"]["points"]
print("Info: Record Legth is", points,"sampels")
print("Info: Record Length is", points,"sampels")
count = waveform_data[ch]["preamble"]["count"]
x_inc = waveform_data[ch]["preamble"]["x_increment"]
print("Info: Sample Period is", x_inc)
timebase = waveform_data[ch]["preamble"]["x_display_range"]
else:
if waveform_data[ch]["preamble"]["points"] != points:
......@@ -758,40 +759,37 @@ def osc_init(scope, time_base = 50.0e-9):
##
"""
Usage:
LeCroy8254.py <IP#> [-c <1,2,3,4>] [-a <averages>] [-o <dir>]
LeCroy8254.py <IP#> [-c 1234>] [-n <averages>] [-o <dir>] [-m <measurements>]
LeCroy8254.py -h | --help
IP IP number of the instrument [default 192.168.32.243]
Options:
-c <1,2,3,4> channel number
-a <number> number of averages [default: 1]
-c 1234 channel number [default 1234]
-n <number> number of averages [default: 1]
-o <dir> optional directory for output file storage [default: "data/"]
-h --help Show this screen.
-m <number> number of measurments
-h --help Show help
"""
if __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("IP", type=str, help="IP number of the instrument", default="192.168.32.243")
parser.add_argument("-c", type=str, help="channel number", default='1,2')
parser.add_argument("-a", type=int, help="number of averages", default=1)
parser.add_argument("-o", type=str, help="optional directory for output file storag", default="data/")
parser.add_argument("scope", type=str, help="IP number of the instrument", default="192.168.32.243")
parser.add_argument("-channels", type=list, help="channel number", default=[1,2,3,4])
parser.add_argument("-num_avg", type=int, help="number of averages", default=1)
parser.add_argument("-output_dir", type=str, help="optional directory for output file storage", default="data")
parser.add_argument("-measurements", default=1, type=int)
args = parser.parse_args()
IP = args.IP
channels = args.c
num_avg = args.a
output_dir = args.o
scope = vxi11.Instrument(IP)
scope = vxi11.Instrument(args.scope)
print(scope.ask("*IDN?"))
print ("channels:",channels, "num_avg", num_avg)
print ("channels:",args.channels, "num_avg", args.num_avg)
# Set Interpolation for all used channels to "Compatible Mode 10"
for chan in channels.split(','):
for chan in args.channels:
scope.write("VBS 'app.Acquisition.C" + str(chan) + ".InterpolateType = \"sinxx\"'")
#print("VBS 'app.Acquisition.C" + str(chan) + ".InterpolateType = \"sinxx\"'")
......@@ -806,17 +804,21 @@ if __name__ == "__main__":
# forwarded to function average_edge_to_sfd
scope.write("TRIG_DELAY 0")
#d,filename = get_waveforms(scope, channels, record_len, num_avg)
d,filename = get_waveforms(scope, channels, num_avg, output_dir)
wf_data = file_to_waveform(filename)
for i in range(0, args.measurements):
d,filename = get_waveforms(scope, channels=args.channels, num_avg=args.num_avg, output_dir=args.output_dir)
wf_data = file_to_waveform(filename)
check_waveforms(wf_data)
plt.figure("channel:"+str(channels))
waveforms = plt.figure("channel:"+str(args.channels))
ax = waveforms.add_subplot(111)
ax.set_xlabel('Time')
ax.set_ylabel('Volt')
for chan in wf_data.keys():
x = wf_data[chan]["waveform"][0]
y = wf_data[chan]["waveform"][1]
plt.plot(x,y)
ax.plot(x,y)
plt.show()
sys.exit()
sys.exit()
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