Compare commits

...

6 Commits

Author SHA1 Message Date
77060d3194 show live subplot 2022-07-12 18:31:07 +02:00
7379e0ad00 fix oob error 2022-07-12 16:37:44 +02:00
1a5fe6e49b show as live image 2022-07-12 16:34:36 +02:00
2648bfd6c4 full measurement, print to console 2022-07-12 15:48:34 +02:00
f858d81b1a measure test pattern for debug inter-bank short 2022-07-07 16:34:10 +02:00
d5a528115f roughly working differential measuring 2022-07-05 15:32:15 +02:00

251
kisli.py
View File

@@ -18,11 +18,16 @@
==================================================================================================== ====================================================================================================
""" """
## channel.exclusiveclose(
import socket import socket
import struct import struct
import math import math
import time import time
import numpy as np
from matplotlib import pyplot
echoCmd = 0 echoCmd = 0
def instrConnect(mySocket, myAddress, myPort, timeOut, doReset, doIdQuery): def instrConnect(mySocket, myAddress, myPort, timeOut, doReset, doIdQuery):
@@ -63,101 +68,137 @@ def Write_Data(output_data_path, dataStr):
return return
def Configure_4WO_Scan(s, scan_channels, scan_count): def Configure_Backplane(s):
instrSend(s, "reset()") instrSend(s, "reset()")
instrSend(s, "dmm.func = \"fourwireohms\"") instrSend(s, "dmm.func = \"fourwireohms\"")
#instrSend(s, "dmm.nplc = 0.1")
instrSend(s, "dmm.autorange = dmm.OFF") instrSend(s, "dmm.autorange = dmm.OFF")
instrSend(s, "dmm.range = 100") instrSend(s, "dmm.range = 100")
instrSend(s, 'dmm.setconfig("slot1", "fourwireohms")') ## 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.setbackplane("2001:2030", "2913")')
instrSend(s, 'channel.setbackplane("2031:2060", "2924")')
instrSend(s, 'channel.setbackplane("3001:3030", "3913")')
instrSend(s, 'channel.setbackplane("3031:3060", "3924")')
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 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_TWO_Scan(s, scan_channels, scan_count): def get_mapped(arr):
instrSend(s, "reset()") # Reset map = [
instrSend(s, "dmm.func = dmm.TWO_WIRE_OHMS") # Set measurement function (1,9),
instrSend(s, "dmm.nplc=1") # Set NPLC (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,9),
(1,3),
(3,9),
(3,2),
(3,5),
(2,2),
(2,5),
(1,2),
(1,10),
(3,1),
instrSend(s, "dmm.autorange = dmm.OFF") (4,7),
instrSend(s, "dmm.range = 100") (5,8),
(4,6),
(6,2),
(5,5),
(6,3),
(4,1),
(5,7),
(4,4),
(5,6),
(4,5),
(6,4),
(4,2),
(6,5),
(4,3),
(5,9),
(5,4),
(6,1),
(5,3),
(6,6),
(4,8),
(6,7),
(4,9),
(6,8),
(5,2),
(6,9),
(5,1),
(6,10),
(4,10),
(5,10),
instrSend(s, "dmm.autodelay = dmm.ON") # Ensure Auto Delay is enabled (7,2),
instrSend(s, "dmm.autozero = dmm.ON") # Enable Auto Zero (7,10),
(9,3),
(7,7),
(9,5),
(8,7),
(7,4),
(9,1),
(7,3),
(8,1),
(8,3),
(9,7),
(8,4),
(7,6),
(9,4),
(8,10),
(8,5),
(9,8),
(7,5),
(8,8),
(8,2),
(7,8),
(9,2),
(9,9),
(9,6),
(8,9),
(8,6),
(7,9),
(7,1),
(9,10)
]
instrSend(s, "dmm.configure.set(\"test\")") # Save Configuration out = np.zeros(shape=(9, 10))
instrSend(s, "dmm.setconfig(\"{0}\",\"test\")".format(scan_channels)) # Assign configuration to channels
instrSend(s, "channel.connectrule = channel.BREAK_BEFORE_MAKE") for i in range(0,90):
x, y = map[i]
out[x-1][y-1] = arr[i]
#if scan_interval > 0.1: return out
# # 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 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 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 s = socket.socket() # Establish a TCP/IP socket object
# Open the socket connection # 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... t1 = time.time() # Start the timer...
scanchannels = "1015" # Define the channels to scan here. Note the following format possibilities... Configure_Backplane(s)
# 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) a = np.zeros(shape=(90, 90))
#Configure_TWO_Scan(s, scanchannels, scancount) b = np.zeros(shape=(9, 10))
Configure_4WO_Scan(s, scanchannels, scancount)
pyplot.ion()
fig, ax = pyplot.subplots()
expectedCnt = 30 axim = ax.imshow(a, interpolation='nearest', cmap='gray', vmin=0, vmax=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
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 # Close the socket connection
instrDisconnect(s) instrDisconnect(s)