|
|
|
|
@ -65,114 +65,45 @@ def Write_Data(output_data_path, dataStr):
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
def Configure_4WO_Scan(s, scan_channels, scan_count):
|
|
|
|
|
#def Configure_4WO_Scan(s, scan_channels, scan_count):
|
|
|
|
|
# instrSend(s, "reset()")
|
|
|
|
|
# instrSend(s, "dmm.func = \"fourwireohms\"")
|
|
|
|
|
#
|
|
|
|
|
# instrSend(s, "dmm.autorange = dmm.OFF")
|
|
|
|
|
# instrSend(s, "dmm.range = 100")
|
|
|
|
|
# instrSend(s, 'dmm.setconfig("slot1", "fourwireohms")')
|
|
|
|
|
# instrSend(s, "scan.create(\"{0}\")".format(scan_channels)) # Create the scan
|
|
|
|
|
# instrSend(s, "scan.scancount = {0}".format(scan_count)) # Set the Scan Count
|
|
|
|
|
# instrSend(s, "reading_buffer = dmm.makebuffer(scan.scancount * scan.stepcount)") # Configure Buffer
|
|
|
|
|
# instrSend(s, "scan.background(reading_buffer)") # Execute Scan and save to buffer
|
|
|
|
|
# return
|
|
|
|
|
|
|
|
|
|
def Configure_Backplane(s):
|
|
|
|
|
instrSend(s, "reset()")
|
|
|
|
|
instrSend(s, "dmm.func = \"fourwireohms\"")
|
|
|
|
|
#instrSend(s, "dmm.nplc = 0.1")
|
|
|
|
|
|
|
|
|
|
instrSend(s, "dmm.autorange = dmm.OFF")
|
|
|
|
|
instrSend(s, "dmm.range = 100")
|
|
|
|
|
|
|
|
|
|
# instrSend(s, 'dmm.setconfig("slot1", "fourwireohms")')
|
|
|
|
|
# excluveclose
|
|
|
|
|
|
|
|
|
|
## crossover connection is made on backplane 3 & 4
|
|
|
|
|
instrSend(s, 'channel.setbackplane("1001:1030", "1913")')
|
|
|
|
|
instrSend(s, 'channel.setbackplane("1031:1060", "1924")')
|
|
|
|
|
|
|
|
|
|
instrSend(s, 'channel.open("allslots")')
|
|
|
|
|
instrSend(s, 'channel.close("1015")')
|
|
|
|
|
instrSend(s, 'channel.close("1037")')
|
|
|
|
|
|
|
|
|
|
instrSend(s, 'closedSlot5 = channel.getclose("slot1")')
|
|
|
|
|
instrQuery(s, "print(closedSlot5)", 64)
|
|
|
|
|
|
|
|
|
|
instrSend(s, "dmm.measure()")
|
|
|
|
|
# instrQuery(s, "print(dmm.measure())", 64)
|
|
|
|
|
instrSend(s, 'channel.setbackplane("2001:2030", "2913")')
|
|
|
|
|
instrSend(s, 'channel.setbackplane("2031:2060", "2924")')
|
|
|
|
|
|
|
|
|
|
#instrSend(s, "scan.create(\"{0}\")".format(scan_channels)) # Create the scan
|
|
|
|
|
#instrSend(s, "scan.scancount = {0}".format(scan_count)) # Set the Scan Count
|
|
|
|
|
#instrSend(s, "reading_buffer = dmm.makebuffer(scan.scancount * scan.stepcount)") # Configure Buffer
|
|
|
|
|
#instrSend(s, "scan.background(reading_buffer)") # Execute Scan and save to buffer
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def Configure_TWO_Scan(s, scan_channels, scan_count):
|
|
|
|
|
instrSend(s, "reset()") # Reset
|
|
|
|
|
instrSend(s, "dmm.func = dmm.TWO_WIRE_OHMS") # Set measurement function
|
|
|
|
|
instrSend(s, "dmm.nplc=1") # Set NPLC
|
|
|
|
|
|
|
|
|
|
instrSend(s, "dmm.autorange = dmm.OFF")
|
|
|
|
|
instrSend(s, "dmm.range = 100")
|
|
|
|
|
|
|
|
|
|
instrSend(s, "dmm.autodelay = dmm.ON") # Ensure Auto Delay is enabled
|
|
|
|
|
instrSend(s, "dmm.autozero = dmm.ON") # Enable Auto Zero
|
|
|
|
|
instrSend(s, 'channel.setbackplane("3001:3030", "3913")')
|
|
|
|
|
instrSend(s, 'channel.setbackplane("3031:3060", "3924")')
|
|
|
|
|
|
|
|
|
|
instrSend(s, "dmm.configure.set(\"test\")") # Save Configuration
|
|
|
|
|
instrSend(s, "dmm.setconfig(\"{0}\",\"test\")".format(scan_channels)) # Assign configuration to channels
|
|
|
|
|
|
|
|
|
|
instrSend(s, "channel.connectrule = channel.BREAK_BEFORE_MAKE")
|
|
|
|
|
|
|
|
|
|
#if scan_interval > 0.1:
|
|
|
|
|
# # Establish the settings that will apply the interval between the start of scans
|
|
|
|
|
# instrSend(s, "trigger.timer[1].reset()") # Ensure the timer gets to a known relative time start point
|
|
|
|
|
# instrSend(s, "trigger.timer[1].count = 0") # No reapeating timer events
|
|
|
|
|
# instrSend(s, "trigger.timer[1].delay = {0}".format(scan_interval)) # Apply the anticipated scan interval
|
|
|
|
|
# instrSend(s, "trigger.timer[1].stimulus = scan.trigger.EVENT_MEASURE_COMP") #
|
|
|
|
|
# instrSend(s, "trigger.timer[1].passthrough = false") # Trigger only initiates the delay
|
|
|
|
|
# instrSend(s, "trigger.blender[1].reset()") # Configure the blender stimulus...
|
|
|
|
|
# instrSend(s, "trigger.blender[1].orenable = true") # ... for OR'ing operation
|
|
|
|
|
# instrSend(s, "trigger.blender[1].stimulus[1] = trigger.timer[1].EVENT_ID") # ... to respond/notify upon a timer event
|
|
|
|
|
# instrSend(s, "trigger.blender[1].stimulus[2] = scan.trigger.EVENT_SCAN_READY") # ... or when then scan is ready (configured)
|
|
|
|
|
# instrSend(s, "scan.trigger.arm.stimulus = trigger.blender[1].EVENT_ID") # Key triggering off of the blender event
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
instrSend(s, "scan.create(\"{0}\")".format(scan_channels)) # Create the scan
|
|
|
|
|
instrSend(s, "scan.scancount = {0}".format(scan_count)) # Set the Scan Count
|
|
|
|
|
instrSend(s, "reading_buffer = dmm.makebuffer(scan.scancount * scan.stepcount)") # Configure Buffer
|
|
|
|
|
instrSend(s, "scan.background(reading_buffer)") # Execute Scan and save to buffer
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
def diff_4W_mess(s, ch1, ch2):
|
|
|
|
|
instrSend(s, 'channel.exclusiveclose("{}")'.format(ch1))
|
|
|
|
|
instrSend(s, 'channel.close("{}")'.format(ch2))
|
|
|
|
|
#print(instrQuery(s, "print(dmm.measure())", 64)[:-1], end='\t')
|
|
|
|
|
return float(instrQuery(s, "print(dmm.measure())", 64))
|
|
|
|
|
|
|
|
|
|
def Configure_DCV_Scan(s, scan_channels, dcv_range, use_input_divider, scan_count, scan_interval):
|
|
|
|
|
instrSend(s, "reset()") # Reset
|
|
|
|
|
instrSend(s, "dmm.func = dmm.DC_VOLTS") # Set measurement function
|
|
|
|
|
instrSend(s, "dmm.nplc=1") # Set NPLC
|
|
|
|
|
if dcv_range < 0.001: # Set Range
|
|
|
|
|
instrSend(s, "dmm.autorange = dmm.ON")
|
|
|
|
|
else:
|
|
|
|
|
instrSend(s, "dmm.autorange = dmm.OFF")
|
|
|
|
|
instrSend(s, "dmm.range = {0}".format(dcv_range))
|
|
|
|
|
|
|
|
|
|
instrSend(s, "dmm.autodelay = dmm.ON") # Ensure Auto Delay is enabled
|
|
|
|
|
instrSend(s, "dmm.autozero = dmm.ON") # Enable Auto Zero
|
|
|
|
|
if use_input_divider == 1: # Apply the 10M input divider as needed
|
|
|
|
|
instrSend(s, "dmm.inputdivider = dmm.ON")
|
|
|
|
|
else:
|
|
|
|
|
instrSend(s, "dmm.inputdivider = dmm.OFF")
|
|
|
|
|
|
|
|
|
|
instrSend(s, "dmm.configure.set(\"mydcvolts\")") # Save Configuration
|
|
|
|
|
instrSend(s, "dmm.setconfig(\"{0}\",\"mydcvolts\")".format(scan_channels)) # Assign configuration to channels
|
|
|
|
|
|
|
|
|
|
instrSend(s, "channel.connectrule = channel.BREAK_BEFORE_MAKE")
|
|
|
|
|
|
|
|
|
|
if scan_interval > 0.1:
|
|
|
|
|
# Establish the settings that will apply the interval between the start of scans
|
|
|
|
|
instrSend(s, "trigger.timer[1].reset()") # Ensure the timer gets to a known relative time start point
|
|
|
|
|
instrSend(s, "trigger.timer[1].count = 0") # No reapeating timer events
|
|
|
|
|
instrSend(s, "trigger.timer[1].delay = {0}".format(scan_interval)) # Apply the anticipated scan interval
|
|
|
|
|
instrSend(s, "trigger.timer[1].stimulus = scan.trigger.EVENT_MEASURE_COMP") #
|
|
|
|
|
instrSend(s, "trigger.timer[1].passthrough = false") # Trigger only initiates the delay
|
|
|
|
|
instrSend(s, "trigger.blender[1].reset()") # Configure the blender stimulus...
|
|
|
|
|
instrSend(s, "trigger.blender[1].orenable = true") # ... for OR'ing operation
|
|
|
|
|
instrSend(s, "trigger.blender[1].stimulus[1] = trigger.timer[1].EVENT_ID") # ... to respond/notify upon a timer event
|
|
|
|
|
instrSend(s, "trigger.blender[1].stimulus[2] = scan.trigger.EVENT_SCAN_READY") # ... or when then scan is ready (configured)
|
|
|
|
|
instrSend(s, "scan.trigger.arm.stimulus = trigger.blender[1].EVENT_ID") # Key triggering off of the blender event
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
instrSend(s, "scan.create(\"{0}\")".format(scan_channels)) # Create the scan
|
|
|
|
|
instrSend(s, "scan.scancount = {0}".format(scan_count)) # Set the Scan Count
|
|
|
|
|
instrSend(s, "reading_buffer = dmm.makebuffer(scan.scancount * scan.stepcount)") # Configure Buffer
|
|
|
|
|
instrSend(s, "scan.background(reading_buffer)") # Execute Scan and save to buffer
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
""" ==============================================================================================================
|
|
|
|
|
MAIN CODE STARTS HERE
|
|
|
|
|
@ -187,50 +118,64 @@ output_data_path = time.strftime("data_%Y-%m-%d_%H-%M-%S.csv") # This is the o
|
|
|
|
|
|
|
|
|
|
s = socket.socket() # Establish a TCP/IP socket object
|
|
|
|
|
# Open the socket connection
|
|
|
|
|
instrConnect(s, ip_address, my_port, 20000, 1, 1)
|
|
|
|
|
instrConnect(s, ip_address, my_port, 20000, 0, 0)
|
|
|
|
|
|
|
|
|
|
t1 = time.time() # Start the timer...
|
|
|
|
|
|
|
|
|
|
scanchannels = "1015" # Define the channels to scan here. Note the following format possibilities...
|
|
|
|
|
# 1001:10060 - All channels starting with 1001 and ending with 1060
|
|
|
|
|
# 1001,1002,1004 - Just channels 1001, 1002, and 1004
|
|
|
|
|
# 1007:1010,1021,1031:1040 - Channels 1007 through 1010, channel 1021, and channels 1031 through 1040
|
|
|
|
|
rangedcv = 10 # Define the DCV range. If auto-ranging is desired, pass 0
|
|
|
|
|
useinputdivider = 1 # 1 = True; 0 = False
|
|
|
|
|
scancount = 3 # Number of times to run the scan
|
|
|
|
|
scaninterval = 1 # Delay between the start of each scan (if needed)
|
|
|
|
|
|
|
|
|
|
#Configure_DCV_Scan(s, scanchannels, rangedcv, useinputdivider, scancount, scaninterval)
|
|
|
|
|
#Configure_TWO_Scan(s, scanchannels, scancount)
|
|
|
|
|
Configure_4WO_Scan(s, scanchannels, scancount)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#expectedCnt = 30
|
|
|
|
|
#channelcount = int(float(instrQuery(s, "print(scan.stepcount)", 64)))
|
|
|
|
|
#startindex = 1
|
|
|
|
|
#endindex = channelcount
|
|
|
|
|
#total_readings_count = 0
|
|
|
|
|
#target = channelcount * scancount
|
|
|
|
|
#cntr = 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Extract readings while the scan is running....
|
|
|
|
|
#while(total_readings_count < target):
|
|
|
|
|
# vals = int(float(instrQuery(s, "print(reading_buffer.n)", 16)))
|
|
|
|
|
#
|
|
|
|
|
# while(vals < endindex):
|
|
|
|
|
# time.sleep(0.1)
|
|
|
|
|
# vals = int(float(instrQuery(s, "print(reading_buffer.n)", 16)))
|
|
|
|
|
#
|
|
|
|
|
# data_string = instrQuery(s, "printbuffer({},{}, reading_buffer.readings)".format(startindex, endindex), 2048)
|
|
|
|
|
# print("Scan {0:4} : {1}".format(cntr, data_string))
|
|
|
|
|
# Write_Data(output_data_path, data_string)
|
|
|
|
|
# startindex += channelcount
|
|
|
|
|
# endindex += channelcount
|
|
|
|
|
# total_readings_count += channelcount
|
|
|
|
|
# cntr += 1
|
|
|
|
|
|
|
|
|
|
Configure_Backplane(s)
|
|
|
|
|
|
|
|
|
|
#print(instrQuery(s, 'print(channel.getclose("allslots"))', 64)[:-1])
|
|
|
|
|
#instrSend(s, 'channel.exclusiveclose("2029")')
|
|
|
|
|
#instrSend(s, 'channel.close("3059")')
|
|
|
|
|
#print(instrQuery(s, 'print(channel.getclose("allslots"))', 64)[:-1])
|
|
|
|
|
|
|
|
|
|
print()
|
|
|
|
|
res = diff_4W_mess(s, 1015, 1045)
|
|
|
|
|
ch = instrQuery(s, 'print(channel.getclose("allslots"))', 64)[:-1]
|
|
|
|
|
print("{}\t{}".format(ch, res))
|
|
|
|
|
res = diff_4W_mess(s, 2015, 1045)
|
|
|
|
|
ch = instrQuery(s, 'print(channel.getclose("allslots"))', 64)[:-1]
|
|
|
|
|
print("{}\t{}".format(ch, res))
|
|
|
|
|
res = diff_4W_mess(s, 3015, 1045)
|
|
|
|
|
ch = instrQuery(s, 'print(channel.getclose("allslots"))', 64)[:-1]
|
|
|
|
|
print("{}\t{}".format(ch, res))
|
|
|
|
|
|
|
|
|
|
print()
|
|
|
|
|
res = diff_4W_mess(s, 1015, 2045)
|
|
|
|
|
ch = instrQuery(s, 'print(channel.getclose("allslots"))', 64)[:-1]
|
|
|
|
|
print("{}\t{}".format(ch, res))
|
|
|
|
|
res = diff_4W_mess(s, 2015, 2045)
|
|
|
|
|
ch = instrQuery(s, 'print(channel.getclose("allslots"))', 64)[:-1]
|
|
|
|
|
print("{}\t{}".format(ch, res))
|
|
|
|
|
res = diff_4W_mess(s, 3015, 2045)
|
|
|
|
|
ch = instrQuery(s, 'print(channel.getclose("allslots"))', 64)[:-1]
|
|
|
|
|
print("{}\t{}".format(ch, res))
|
|
|
|
|
|
|
|
|
|
print()
|
|
|
|
|
res = diff_4W_mess(s, 1015, 3045)
|
|
|
|
|
ch = instrQuery(s, 'print(channel.getclose("allslots"))', 64)[:-1]
|
|
|
|
|
print("{}\t{}".format(ch, res))
|
|
|
|
|
res = diff_4W_mess(s, 2015, 3045)
|
|
|
|
|
ch = instrQuery(s, 'print(channel.getclose("allslots"))', 64)[:-1]
|
|
|
|
|
print("{}\t{}".format(ch, res))
|
|
|
|
|
res = diff_4W_mess(s, 3015, 3045)
|
|
|
|
|
ch = instrQuery(s, 'print(channel.getclose("allslots"))', 64)[:-1]
|
|
|
|
|
print("{}\t{}".format(ch, res))
|
|
|
|
|
|
|
|
|
|
#print()
|
|
|
|
|
#for ch1 in [*range(1001, 1031)] + [*range(2001, 2031)] + [*range(3001, 3031)]:
|
|
|
|
|
# for ch2 in [*range(1031, 1061)] + [*range(2031, 2061)] + [*range(3031, 3061)]:
|
|
|
|
|
# res = diff_4W_mess(s, ch1, ch2)
|
|
|
|
|
# ch = instrQuery(s, 'print(channel.getclose("allslots"))', 64)[:-1]
|
|
|
|
|
# print("{}\t{}".format(ch, res))
|
|
|
|
|
# print()
|
|
|
|
|
|
|
|
|
|
#print("steps: {}".format(channelcount))
|
|
|
|
|
#
|
|
|
|
|
#while(int(float(instrQuery(s, "scanState, scanCount, stepCount = scan.state(); print(scanState)", 255))) != 6):
|
|
|
|
|
# time.sleep(0.1)
|
|
|
|
|
#
|
|
|
|
|
#print(instrQuery(s, "printbuffer(0, reading_buffer.n, reading_buffer)", 2048))
|
|
|
|
|
|
|
|
|
|
# Close the socket connection
|
|
|
|
|
instrDisconnect(s)
|
|
|
|
|
|