Пример #1
0
    def __init__(self, reactor):
        super(HeaterWindow,self).__init__()
        print "heater control starting..."
        
        #necessary in order to join ResonatorGUI event loop
        self.reactor = reactor
	
	#temperature, as float
        self.temp = 9999
	
	#current, as float
	self.curr = 9999

        
        self.prof_module = auto_heat_profile
	self.voltmax = HeaterWindow.VOLT_MAX

        self._connect_external()
        self._makeGUI()
        self._connect_buttons()

        
        from keithley_helper import voltage_conversion as VC
        self.vc = VC()


        self.autoflag = False
        self.profile = None 
        print "heater control on"
Пример #2
0
class Thermometer(object):
    """ returns temperature on request using specified DMM server"""
    def __init__(self, dmm_server):
        self.dmm = dmm_server
        #make sure a device is present
        self.dmm.select_device()
        self.vc = VC()
        
    def getTemp(self):
        """returns temp as labrad value in K"""
        #voltage from thermometer
        voltage = self.dmm.get_dc_volts()

        #convert to temp
        return self.vc.conversion(voltage)
Пример #3
0
    def __init__(self, username, pwd):
        TargetInbox.__init__(self, username, pwd)
        self.gmail_acc = self.username + "@gmail.com"
        c = labrad.connect(WINDOWS_MACHINE_IP)
        self.gauge = c.pfeiffer_pressure_gauge
        
        from keithley_helper import voltage_conversion as VC
        self.vc = VC()
    
        self.dmm = c.keithley_2100_dmm
        self.dmm.select_device()

        #finite length FIFO (or rolling) buffers to store recent values
        self.recentTimes = collections.deque(self.NRECENT*[None], self.NRECENT)
        self.recentTemps = collections.deque(self.NRECENT*[None], self.NRECENT)
        self.recentPressures = collections.deque(self.NRECENT*[None], self.NRECENT)

        self.mailingLists = []
        self.mailingListNames = {}
Пример #4
0
 def __init__(self, dmm_server):
     self.dmm = dmm_server
     #make sure a device is present
     self.dmm.select_device()
     self.vc = VC()
Пример #5
0
class PT(TargetInbox):
    """responds with pressure and temp to inquiries"""
    
    ResponseFuncs = { 'vals?': sendvalues, 'help?': sendinfo, 'recent:T?': sendRecentTemps, 'recent:P?':sendRecentPressures, 'subscribe:PI': subscribePI,
                      'unsubscribe:PI':unsubscribePI}
    timeout =10
    NRECENT = 20

    def __init__(self, username, pwd):
        TargetInbox.__init__(self, username, pwd)
        self.gmail_acc = self.username + "@gmail.com"
        c = labrad.connect(WINDOWS_MACHINE_IP)
        self.gauge = c.pfeiffer_pressure_gauge
        
        from keithley_helper import voltage_conversion as VC
        self.vc = VC()
    
        self.dmm = c.keithley_2100_dmm
        self.dmm.select_device()

        #finite length FIFO (or rolling) buffers to store recent values
        self.recentTimes = collections.deque(self.NRECENT*[None], self.NRECENT)
        self.recentTemps = collections.deque(self.NRECENT*[None], self.NRECENT)
        self.recentPressures = collections.deque(self.NRECENT*[None], self.NRECENT)

        self.mailingLists = []
        self.mailingListNames = {}

    def getP(self):
        """pressure in mbar as a float"""
        return self.gauge.readpressure().inUnitsOf('bar').value * 1000.0
    
    def getPStr(self):
        try:
            p = self.getP()
            return "{0:.2E}".format(p)
        except AttributeError:
            return "Gauge off or not present."
    
    def getTStr(self):
        t = self.getT()
        return "{0:.2E}".format(t)

    def getT(self):
        """ temp in Kelvin as a float"""
        v = self.dmm.get_dc_volts()
        return self.vc.conversion(v)

    def getVals(self):
        p = self.getPStr()
        t = self.getTStr()
        return (p, t)

    def send(self, msg, to):
        """ send msg to address to"""
        self.authenticate()
        self.sendStr(to, msg.as_string())
        self.closeAcc()

    def authenticate(self):
        
        self.server = smtplib.SMTP("smtp.gmail.com", 587)
        self.server.ehlo()
        self.server.starttls()
        self.server.ehlo()

        self.server.login(self.gmail_acc, self.pwd)

    def sendStr(self, to, s):
        self.server.sendmail(self.gmail_acc, to, s)

    def closeAcc(self):
        self.server.close()

    def getValsText(self, msg):
        return "Values recorded at " + time.strftime("%Y - %m - %d, %H:%M:%S") 

    def getTargets(self):
        return self.ResponseFuncs.keys()

    def addMailingList(self, lst):
        if lst.name in self.mailingListNames.keys():
            raise ValueError('mailing list already exists')
        self.mailingLists.append(lst)
        
        self.mailingListNames[lst.name] = lst

    def update(self):
        """take care of stuff not related to responding"""
        T = self.getTStr()
        P = self.getPStr()
        tm = time.strftime("%Y - %m - %d, %H:%M:%S")
        #update buffers
        self.recentTemps.appendleft(T)
        self.recentPressures.appendleft(P)
        self.recentTimes.appendleft(tm)

        for lst in self.mailingLists:
            lst.act()


    def respondWithError(self, msg):
        """this is called when someone sends a bad request"""

        print "Handling bad request {0}".format(msg.title)
        sendErrMsg(self, msg)

    def loop(self):
        """ check periodically and respond"""
        print "Listening at ", self.gmail_acc
        
        try:
            while(1):

                self.update()
                self.respondChronological()
                dprint("Response completed")
                time.sleep(self.timeout)
        except KeyboardInterrupt:
            return
Пример #6
0
class HeaterWindow(QtGui.QWidget):

    #height and width in pixels
    sx = 200
    sy = 200
    title = 'Heater Control'
    CURR_MIN = 0
    CURR_MAX = 0.4

    VOLT_MIN = 0
    VOLT_MAX = 60

    #WINDOWS_MACHINE_IP = '192.168.169.30'
    WINDOWS_MACHINE_IP = 'localhost'

    AUTO_TIMESTEP = 2
    NUM_PROF_SAMP = 10000

    def __init__(self, reactor):
        super(HeaterWindow,self).__init__()
        print "heater control starting..."
        
        #necessary in order to join ResonatorGUI event loop
        self.reactor = reactor
	
	#temperature, as float
        self.temp = 9999
	
	#current, as float
	self.curr = 9999

        
        self.prof_module = auto_heat_profile
	self.voltmax = HeaterWindow.VOLT_MAX

        self._connect_external()
        self._makeGUI()
        self._connect_buttons()

        
        from keithley_helper import voltage_conversion as VC
        self.vc = VC()


        self.autoflag = False
        self.profile = None 
        print "heater control on"
        
    def _makeGUI(self):
      
        self.resize(HeaterWindow.sx, HeaterWindow.sy)
        self.setWindowTitle(HeaterWindow.title)
        
        layout = QtGui.QGridLayout()
        autobox = QtGui.QGroupBox('Auto Control')
        manualbox = QtGui.QGroupBox('Manual control')
        
        autolayout = QtGui.QGridLayout()
        manuallayout = QtGui.QGridLayout()
        
        self.setLayout(layout)
        layout.addWidget(autobox, 0, 1)
        layout.addWidget(manualbox, 0, 0)
        
        autobox.setLayout(autolayout)
        manualbox.setLayout(manuallayout)
        
        self.tempread = QtGui.QLabel()
        
        self.pressureRead =QtGui.QLabel()
        
        self.currentbox = QtGui.QDoubleSpinBox()
        self.currentset = QtGui.QPushButton('Set Current')
        self.voltagebox = QtGui.QDoubleSpinBox()
        self.voltageset = QtGui.QPushButton('Set Voltage limit')
       
        self.onBtn = QtGui.QPushButton('Output On')
        self.offBtn = QtGui.QPushButton('Output Off')
        self.srclabel = QtGui.QLabel('defined in {0}'.format(self.rpr))
       
        self.autotoggle = QtGui.QCheckBox('Auto control enabled')
        
        #manuallayout.addWidget(self.updatebtn, 2, 0)
        
        
        layout.addWidget(QtGui.QLabel('Temp, K'), 1, 0)
        layout.addWidget(self.tempread, 1, 1)

        layout.addWidget(QtGui.QLabel('Pressure, mbar'), 2, 0)
        layout.addWidget(self.pressureRead, 2, 1)

        layout.addWidget(QtGui.QLabel('Voltage Limit, V'), 3, 0)
        layout.addWidget(self.voltagebox, 3, 1)
        layout.addWidget(self.voltageset, 3, 2)
        layout.addWidget(self.onBtn, 4, 0)
    #@inlineCallbacks
        layout.addWidget(self.offBtn, 4, 1)
        
        manuallayout.addWidget(QtGui.QLabel('Current, amps'), 1, 0)
        manuallayout.addWidget(self.currentbox, 1, 1)
        manuallayout.addWidget(self.currentset, 1, 2)
        
        autolayout.addWidget(self.autotoggle, 0, 0)
        autolayout.addWidget(self.srclabel, 1, 0)
        
        self.prof_plotter = pg.PlotWidget()
        autolayout.addWidget(self.prof_plotter, 0, 1)
        self.pi = self.prof_plotter.getPlotItem()

        self.pi.setTitle('Heating Profile')
        self.pi.setLabel('bottom', 'Temp.', 'K')
        self.pi.setLabel('left', 'Current', 'A')
        self.prof_plotter.resize(600, 300)

        self.sample_temp = np.linspace(4, 300, HeaterWindow.NUM_PROF_SAMP)
        self.p1btn = QtGui.QRadioButton('std')
        self.p2btn = QtGui.QRadioButton('fast')
        self.p3btn = QtGui.QRadioButton('faster')
        self.p4btn = QtGui.QRadioButton('fastest')
        
        autolayout.addWidget(self.p1btn, 1, 3)
        autolayout.addWidget(self.p2btn, 2, 3)
        autolayout.addWidget(self.p3btn, 3, 3)
        autolayout.addWidget(self.p4btn, 4, 3)

        self.profile_keys = { 'std': 'step_std', 'fast': 'step_fast', 'faster': 'step_faster', 'fastest': 'step_fastest'}

        self.profile_buttons = [self.p1btn, self.p2btn, self.p3btn, self.p4btn]



    def _connect_buttons(self):
	self.currentset.clicked.connect(self.apply_currentbox)
	self.currentbox.setRange(HeaterWindow.CURR_MIN, HeaterWindow.CURR_MAX)
	self.autotoggle.stateChanged.connect(self.togglemode)
	self.voltageset.clicked.connect(self.apply_voltagebox)
	self.voltagebox.setRange(HeaterWindow.VOLT_MIN, HeaterWindow.VOLT_MAX)
	self.onBtn.clicked.connect(self.output_on)
	self.offBtn.clicked.connect(self.output_off)
        self.p1btn.clicked.connect(self.set_profile)
        self.p2btn.clicked.connect(self.set_profile)
        self.p3btn.clicked.connect(self.set_profile)
        self.p4btn.clicked.connect(self.set_profile)




    @inlineCallbacks
    def _connect_external(self):

        #don't import labrad globally, it screws with the reactor choice
        from labrad.wrappers import connectAsync as labrad_connect


        self.rpr = str(self.prof_module).replace('from', 'from\n')


        self.cxn = yield labrad_connect(HeaterWindow.WINDOWS_MACHINE_IP)
        #self.cxn = yield labrad_connect()
        #server for the dmm
        self.dmm = yield self.cxn.keithley_2100_dmm
        try:
            yield self.dmm.select_device()
            
        except:
            print("dmm not present")
            raise Exception

        #server for the heater power supply
        self.ps = yield self.cxn.keithley_2220_30_1()
        try:
            yield self.ps.select_device()
        except:
            print("power supply not present")
            raise Exception

        self.gauge = self.cxn.pfeiffer_pressure_gauge
         

        yield self.autoUpdate()
        self.output_off()
        

    def set_profile(self):
        for btn in self.profile_buttons:
            if btn.isChecked():
                self.profile = self.profile_keys[str(btn.text())]
        self.update_profile_plot()        
                
    def update_profile_plot(self):
        self.pi.clear() 
        self.sample_curr = np.array(map(self.get_auto_current, self.sample_temp))
        self.pi.plot(self.sample_temp, self.sample_curr)



    @inlineCallbacks
    def gettemp(self):
	v = yield self.dmm.get_dc_volts()
        t = self.vc.conversion(v)
        returnValue(t)


    @inlineCallbacks
    def getPressure(self):
        ### returns pressure in mbar as a float
        p = yield self.gauge.readpressure()
        try:
            mbar = p.inUnitsOf('bar').value * 1000.0
            returnValue(mbar)
        except AttributeError:
            returnValue(p)
        

    @inlineCallbacks
    def getcurr(self):

	i = yield self.ps.current()
        returnValue(i)
    



    
    @inlineCallbacks	
    def getvoltmax(self):
        
	v = yield self.ps.voltage()
        returnValue(v)

    @inlineCallbacks
    def update(self, dummy=None):
        #update the temperature and current readings	
        # the generator returns a Deferred. execution here resumes when the
        #deferred fires due to returnValue(), and self.temp gets the result (float!)
        #self.temp = yield self.gettemp()

        #self.tempread.setText(str(self.temp))      

        yield self.updatetemp(dummy)
        yield self.updatepressure(dummy)

        #now do the same for the current and voltage
        self.curr = yield self.getcurr()
        

        self.voltmax = yield self.getvoltmax()
        self.currentbox.setValue(self.curr)
        self.voltagebox.setValue(self.voltmax)
       

    @inlineCallbacks
    def updatetemp(self, dummy=None):
        self.temp = yield self.gettemp()
        self.tempread.setText(str(self.temp))


    @inlineCallbacks
    def updatepressure(self, dummy=None):
        self.pressure = yield self.getPressure()
        self.pressureRead.setText(str(self.pressure))

    def setcurrent(self, curr):
        if curr >= HeaterWindow.CURR_MAX:
	    curr= HeaterWindow.CURR_MAX
        self.ps.current(curr)
        self.update()

    def setvoltage(self, volt):
        if volt >= HeaterWindow.VOLT_MAX:
	    volt = HeaterWindow.VOLT_MAX
	self.ps.voltage(volt)
        self.update()


    def get_auto_current(self, temp):
        if self.profile is None:
            return 0
        else:
            return self.prof_module.new_current(temp, self.profile)


    def apply_currentbox(self, dummy=None):
        # set a new current output/limit for the power supply     
       
        curr = self.currentbox.value()

        self.setcurrent(curr)
    
    def apply_voltagebox(self, dummy=None):
        voltmax = self.voltagebox.value()
        self.setvoltage(voltmax)
        
    def autoON(self):
	self.autoflag = True
	self.currentset.setEnabled(False)

        self.autoUpdate()

    def autoOFF(self):
	self.autoflag = False
	self.currentset.setEnabled(True)
        self.setcurrent(0.00)


    def togglemode(self):
	sw = self.autotoggle.checkState()
	if sw:
	    self.autoON()
	else:
	    self.autoOFF()

    @inlineCallbacks
    def autoUpdate(self):
        """update current based on temp automatically"""
        yield self.updatetemp()
        yield self.updatepressure()

        if self.autoflag:
            nc = self.get_auto_current(self.temp)
            self.setcurrent(nc)

        self.reactor.callLater(HeaterWindow.AUTO_TIMESTEP, self.autoUpdate)
        


    def output_off(self):
        self.currentset.setEnabled(False)
        self.autotoggle.setEnabled(False)
        self.voltageset.setEnabled(False)
        self.onBtn.setEnabled(True)
        self.offBtn.setEnabled(False)
        self.setcurrent(0)
        self.setvoltage(0)
        #self.update()
        
    def output_on(self):
        self.currentset.setEnabled(True)
        self.autotoggle.setEnabled(True)
        self.voltageset.setEnabled(True)      
        self.onBtn.setEnabled(False)
        self.offBtn.setEnabled(True)
        self.setcurrent(0)
        self.setvoltage(HeaterWindow.VOLT_MAX)
Пример #7
0
initial_time = time()
#BNC 526 is at Cold Finger
filedirectory_526 = '/home/resonator/Desktop/Resonator_Voltage/526(Cold Finger)_' + run_time + '_keithley_DMM.csv'
#BNC 529 is inside the heat shield
filedirectory_529 = '/home/resonator/Desktop/Resonator_Voltage/529(Inside Heat Shield)_' + run_time + '_keithley_DMM.csv'
#
filedirectory_Cernox = '/home/resonator/Desktop/Resonator_Voltage/Cernox_' + run_time + '_keithley_DMM.csv'
##
#filedirectory_C1 = '/home/resonator/Desktop/Resonator_Voltage/C1_'+run_time+'_keithley_DMM.csv'
##
#filedirectory_C2 = '/home/resonator/Desktop/Resonator_Voltage/C2_'+run_time+'_keithley_DMM.csv'

# Each colum headers is the following:
#["Elapsed Time (minutes)", "CurrentTime(H:M)", "Voltage(V)", "Temperature(K)"

vc = VC()
rc = RC()
while (1):
    pulser.switch_manual('Cold Finger', True)
    sleep(1)
    file_526 = open(filedirectory_526, "ab")
    fcsv_526 = writer(file_526, lineterminator="\n")
    voltage = keithley.get_dc_volts()
    temp = vc.conversion(voltage)
    elapsed_time_526 = (time() - initial_time) / 60
    fcsv_526.writerow([
        round(elapsed_time_526, 4),
        strftime("%H" + "%M"), voltage,
        round(temp, 3)
    ])
    file_526.close()
Пример #8
0
#
filedirectory_C1 = 'Y:/resonator-cooling/Data/resonator_auto/C1_'+run_time+'_keithley_DMM.csv'
#
filedirectory_C2 = 'Y:/resonator-cooling/Data/resonator_auto/C2_'+run_time+'_keithley_DMM.csv'
=======
filedirectory_Cernox = '/home/resonator/Desktop/Resonator_Voltage/Cernox_'+run_time+'_keithley_DMM.csv'
##
#filedirectory_C1 = '/home/resonator/Desktop/Resonator_Voltage/C1_'+run_time+'_keithley_DMM.csv'
##
#filedirectory_C2 = '/home/resonator/Desktop/Resonator_Voltage/C2_'+run_time+'_keithley_DMM.csv'
>>>>>>> e39d30f9439e8dd711b3b16b043c47a94588e7ed

# Each colum headers is the following:
#["Elapsed Time (minutes)", "CurrentTime(H:M)", "Voltage(V)", "Temperature(K)"

vc = VC()
rc = RC()
while(1):
<<<<<<< HEAD
#    pulser.switch_manual('Cold Finger', True)
=======
    pulser.switch_manual('Cold Finger', True)
    sleep(1)
>>>>>>> e39d30f9439e8dd711b3b16b043c47a94588e7ed
    file_526 = open(filedirectory_526,"ab")
    fcsv_526 = writer(file_526,lineterminator="\n")
    voltage = keithley2.get_dc_volts()
    temp = vc.conversion(voltage)
    elapsed_time_526 = (time() - initial_time)/60
    fcsv_526.writerow([round(elapsed_time_526,4), strftime("%H"+"%M"), voltage, round(temp, 3)])
    file_526.close()
Пример #9
0
except ValueError:
    print "no time provided, using default"

fname = time.strftime("%Y-%m-%d,%H:%M:%S")+ "-temp-{0}.csv".format(tag)



if not (i is None):
    REC_TIME = int(strings[i+1]) * 3600


dmm = cxn.keithley_2100_dmm()
dmm.select_device()
from keithley_helper import voltage_conversion as VC

converter = VC()

nsamp = int(REC_TIME / DT)

data = np.zeros((nsamp, 2))
       
header_str = "recording time = {0} hrs, start time = {1}".format( REC_TIME/3600, time.strftime("%Y-%m-%d,%H:%M:%S"))
print header_str
print "saving to ", fname

for i in range(nsamp):
    try:
        v = dmm.get_dc_volts()
        temp = converter.conversion(v)
        data[i,0] = i*DT
        data[i,1] = temp