Skip to content
Snippets Groups Projects
Commit e5ff1a26 authored by Berk Silemek's avatar Berk Silemek
Browse files

The script for Keithley interface to pull resistance data and converting to...

The script for Keithley interface to pull resistance data and converting to temperature values for the thermistor that was used. 
parent 87fd7cb7
No related branches found
No related tags found
No related merge requests found
# -*- coding: utf-8 -*-
#
import time
import serial
import matplotlib
matplotlib.use('TkAgg')
import numpy
import matplotlib.pyplot as plt
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2TkAgg
from matplotlib.figure import Figure
import Tkinter as tk
import ttk
import sys
import math
from datetime import datetime
hl, = plt.plot([], [])
plt.ylabel('Temperature')
plt.xlabel('Sample Point')
plt.grid()
plt.rcParams.update({'font.size': 24})
plt.rcParams.update({'font.weight' : 'bold'})
plt.rcParams['lines.linewidth'] = 2
file_object = open("log.txt", "a")
dt_obj = datetime.strptime('18.12.2016 17:05:42,76',
'%d.%m.%Y %H:%M:%S,%f')
serialDev = serial.Serial(port = '/dev/ttyUSB0',baudrate=19200,parity=serial.PARITY_NONE,stopbits=serial.STOPBITS_ONE,bytesize=serial.EIGHTBITS)
serialDev.write("display:enable 0"+'\r\n')
#serialDev.write("sens:RES:NPLC RST"+'\r\n')
R0 = float(10000)
T0 = float(298.15)
beta = float(3380)
temp = float(0.0)
rate = float(0.04)
counter = 1
plotData = float(0.04)
now = datetime.today()
def update_line(hl, new_data, x_data):
hl.set_xdata(np.append(hl.get_xdata(), x_data))
hl.set_ydata(np.append(hl.get_ydata(), new_data))
hl.axes.relim()
hl.axes.autoscale_view()
plt.pause(0.0001)
def rThermistor(rt):
temperature = 1/((1/T0) + ((1/beta) * (math.log(rt/R0))))-(273.15);
return temperature
x_data = 0
while 1 :
serialDev.write("sens:data:fresh?" + '\r\n')
out = ''
time.sleep(rate)
while serialDev.inWaiting() > 0:
out += serialDev.read(1)
if out[-1] == '\n':
#print(out)
now = datetime.today()
if(out[-5:-1] == "E+03"):
rt = float(out[:-5])*1000
plotData = rThermistor(rt)
file_object.write(now.strftime('%d.%m.%Y %H:%M:%S.%f') +' ' + str(plotData) + ' ' + out)
x_data = x_data +1
elif (out[-5:-1] == "E+04"):
rt = float(out[:-5])*10000
plotData = rThermistor(rt)
file_object.write(now.strftime('%d.%m.%Y %H:%M:%S.%f') + ' ' + str(plotData) + ' ' + out)
x_data = x_data +1
else:
print 'False E+03'
#update_line(hl, plotData, x_data)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment