|
|
|
|
@ -18,11 +18,16 @@
|
|
|
|
|
====================================================================================================
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
## channel.exclusiveclose(
|
|
|
|
|
|
|
|
|
|
import socket
|
|
|
|
|
import struct
|
|
|
|
|
import math
|
|
|
|
|
import time
|
|
|
|
|
|
|
|
|
|
import numpy as np
|
|
|
|
|
from matplotlib import pyplot
|
|
|
|
|
|
|
|
|
|
echoCmd = 0
|
|
|
|
|
|
|
|
|
|
def instrConnect(mySocket, myAddress, myPort, timeOut, doReset, doIdQuery):
|
|
|
|
|
@ -63,100 +68,136 @@ def Write_Data(output_data_path, dataStr):
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
def Configure_4WO_Scan(s, scan_channels, scan_count):
|
|
|
|
|
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")')
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
## crossover connection is made on backplane 3 & 4
|
|
|
|
|
instrSend(s, 'channel.setbackplane("1001:1030", "1913")')
|
|
|
|
|
instrSend(s, 'channel.setbackplane("1031:1060", "1924")')
|
|
|
|
|
|
|
|
|
|
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, 'channel.setbackplane("2001:2030", "2913")')
|
|
|
|
|
instrSend(s, 'channel.setbackplane("2031:2060", "2924")')
|
|
|
|
|
|
|
|
|
|
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 get_mapped(arr):
|
|
|
|
|
map = [
|
|
|
|
|
(1,9),
|
|
|
|
|
(1,1),
|
|
|
|
|
(3,8),
|
|
|
|
|
(1,4),
|
|
|
|
|
(3,6),
|
|
|
|
|
(2,4),
|
|
|
|
|
(1,7),
|
|
|
|
|
(3,10),
|
|
|
|
|
(1,8),
|
|
|
|
|
(2,10),
|
|
|
|
|
(2,8),
|
|
|
|
|
(3,4),
|
|
|
|
|
(2,7),
|
|
|
|
|
(1,5),
|
|
|
|
|
(3,7),
|
|
|
|
|
(2,1),
|
|
|
|
|
(2,6),
|
|
|
|
|
(3,3),
|
|
|
|
|
(1,6),
|
|
|
|
|
(2,3),
|
|
|
|
|
(2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|
(9,9),
|
|
|
|
|
(9,6),
|
|
|
|
|
(8,9),
|
|
|
|
|
(8,6),
|
|
|
|
|
(7,9),
|
|
|
|
|
(7,1),
|
|
|
|
|
(9,10)
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
out = np.zeros(shape=(9, 10))
|
|
|
|
|
|
|
|
|
|
for i in range(0,90):
|
|
|
|
|
x, y = map[i]
|
|
|
|
|
out[x-1][y-1] = arr[i]
|
|
|
|
|
|
|
|
|
|
return out
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
@ -171,48 +212,32 @@ 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)
|
|
|
|
|
|
|
|
|
|
a = np.zeros(shape=(90, 90))
|
|
|
|
|
b = np.zeros(shape=(9, 10))
|
|
|
|
|
|
|
|
|
|
pyplot.ion()
|
|
|
|
|
fig, ax = pyplot.subplots()
|
|
|
|
|
|
|
|
|
|
axim = ax.imshow(a, interpolation='nearest', cmap='gray', vmin=0, vmax=30)
|
|
|
|
|
|
|
|
|
|
x = 0
|
|
|
|
|
y = 0
|
|
|
|
|
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)]:
|
|
|
|
|
a[x][y]=diff_4W_mess(s, ch1, ch2)
|
|
|
|
|
b=get_mapped(a[x])
|
|
|
|
|
axim.set_data(b)
|
|
|
|
|
fig.canvas.flush_events()
|
|
|
|
|
y+=1
|
|
|
|
|
y=0
|
|
|
|
|
x+=1
|
|
|
|
|
|
|
|
|
|
# Close the socket connection
|
|
|
|
|
instrDisconnect(s)
|
|
|
|
|
|