Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions CollectingData.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


TIME_INCREMENT = 1 #in seconds
test = True
test = False

FILENAME = "test.csv"

Expand Down Expand Up @@ -40,14 +40,23 @@ def updateFile (filename, row):
"""DATA COLLECTION"""
index = count()

def collectData():
time = next(index) * TIME_INCREMENT
ch1V = random.randint(0,10)
ch1K = random.randint(0,10)
ch2V = random.randint(0,10)
ch2K = random.randint(0,10)
row = [time, ch1V, ch1K, ch2V, ch2K]
updateFile(FILENAME, row)

if (not test):
# Connect to the first available Model 240 over USB
my_model_240 = Model240()

# Define the channel configuration for a sensor with a negative temperature coefficient, autorange disabled
# current reversal disabled, the channel enabled, and set to the 100 kOhm range
rtd_config = Model240InputParameter(my_model_240.SensorTypes.NTC_RTD, False, False, my_model_240.Units.SENSOR, True,
my_model_240.InputRange.RANGE_NTCRTD_100_KIL_OHMS)
rtd_config = Model240InputParameter(my_model_240.SensorTypes.DIODE, False, False, my_model_240.Units.KELVIN, True,
my_model_240.InputRange.RANGE_DIODE)

# Apply the configuration to all channels
for channel in range(1, 3):
Expand All @@ -63,13 +72,4 @@ def collectData():
ch2K = my_model_240.get_kelvin_reading(2)

row = [time, ch1V, ch1K, ch2V, ch2K]
updateFile(FILENAME, row)

def testCollect():
time = next(index) * TIME_INCREMENT
ch1V = random.randint(0,10)
ch1K = random.randint(0,10)
ch2V = random.randint(0,10)
ch2K = random.randint(0,10)
row = [time, ch1V, ch1K, ch2V, ch2K]
updateFile(FILENAME, row)
updateFile(FILENAME, row)
50 changes: 20 additions & 30 deletions gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ def beginCollecting():
def animate(i):
"""'loop' for data collection"""
if (isRunning):
#CollectingData.collectData()
CollectingData.testCollect()
CollectingData.collectData()

pullData = open(FILENAME,"r").read()
dataList = pullData.split('\n')
Expand All @@ -55,22 +54,18 @@ def animate(i):
timeList.insert(0, float(vals[0]))
ch1VList.insert(0, float(vals[1]))
ch1KList.insert(0, float(vals[2]))
ch2VList.insert(0, int(vals[3]))
ch2KList.insert(0, int(vals[4]))
ch2VList.insert(0, float(vals[3]))
ch2KList.insert(0, float(vals[4]))

plt.clear()

if (chChoosen.get() == ' Channel 1'):
if (len(ch1KList) > 0 ):
temp.set(str(ch1KList[len(ch1KList)-1]) + "K")
plt.plot(timeList, ch1VList, label="voltage (V)")
plt.plot(timeList, ch1KList, label="temperature (K)")

if (chChoosen.get() == ' Channel 2'):
if (len(ch2KList) > 0 ):
temp.set(str(ch2KList[len(ch2KList)-1]) + "K")
plt.plot(timeList, ch2VList, label="voltage (V)")
plt.plot(timeList, ch2KList, label="temperature (K)")

if (len(ch1KList) > 0 ):
temp1.set(str(ch1KList[len(ch1KList)-1]) + "K")
temp2.set(str(ch2KList[len(ch2KList)-1]) + "K")
#plt.plot(timeList, ch1VList, label="voltage (V)")
plt.plot(timeList, ch1KList, label="Ch1 temperature (K)")
#plt.plot(timeList, ch2VList, label="voltage (V)")
plt.plot(timeList, ch2KList, label="Ch2 temperature (K)")

plt.legend(loc="upper right")

Expand All @@ -97,20 +92,15 @@ def clickButton():


"""TEMPERATURE LABEL"""
temp = tk.StringVar()
temp.set("0.0K")
tempLabel = tk.Label(window, textvariable=temp, bd=0, font=("Arial", 40), bg="white")
tempLabel.place(x=500, y=20)


"""COMBOBOX FOR SELECTING CHANNEL"""
chLabel = tk.Label(window, text="Channel:", font=("Arial", 10), bg="white")
chLabel.place(x=190, y=25)
n = tk.StringVar()
chChoosen = ttk.Combobox(window, width=27, textvariable=n)
chChoosen['values'] = (' Channel 1', ' Channel 2')
chChoosen.current(0)
chChoosen.place(x=250, y=25)
temp1 = tk.StringVar()
temp1.set("0.0K")
temp1Label = tk.Label(window, textvariable=temp1, bd=0, font=("Arial", 40), bg="white")
temp1Label.place(x=200, y=20)

temp2 = tk.StringVar()
temp2.set("0.0K")
temp2Label = tk.Label(window, textvariable=temp2, bd=0, font=("Arial", 40), bg="white")
temp2Label.place(x=450, y=20)


ani = animation.FuncAnimation(f, animate, interval = 1000 * TIME_INCREMENT, cache_frame_data=False)
Expand Down