Ejemplo n.º 1
0
    def update(self):
        if self.value:
            self.evap = evaporation()
            self.cmds = []
            for k in range(self.evap.points):
                self.cmds.append('FREQ {:0.2f}kHz; VOLT {:0.2f}dbm'.format(
                    self.evap.trajectory[k], self.evap.amps[k]))

            yield sleep(1.0)  # Wait time until the start of evap

            yield self.cxn.krbjila_gpib.write('OUTP:STAT ON')
            for k in self.cmds:
                self.cxn.krbjila_gpib.write(k)
                yield sleep(self.evap.dt)
            yield self.cxn.krbjila_gpib.write('OUTP:STAT OFF')
Ejemplo n.º 2
0
 def advanceAction(self, cntx, signal):
     if self.value:
         yield self.cxn.krbjila_gpib.write('OUTP:STAT OFF')
         state = signal
         self.state = state
         if str(state) in self.to_run:
             to_run = self.to_run[str(state)]
             if 'e' in to_run:
                 if to_run['e']:
                     self.evap = evaporation()
                     self.cmds = []
                     for k in range(self.evap.points):
                         self.cmds.append('FREQ {:0.2f}MHz; POW:AMPL {:0.2f}dbm'.format(self.evap.trajectory[k], self.evap.amps[k]))
 
                     yield self.cxn.krbjila_gpib.write('OUTP:STAT ON')
                     for k in self.cmds:
                         self.cxn.krbjila_gpib.write(k)
                         yield sleep(self.evap.dt)
             # if not, then just setting a single frequency and/or amplitude
             elif ('f' in to_run) or ('a' in to_run) or ('d' in to_run):
                 if 'f' in to_run:
                    yield self.cxn.krbjila_gpib.write('FREQ ' + str(to_run['f']) + 'MHz')
                 if 'a' in to_run:
                    yield self.cxn.krbjila_gpib.write('POW:AMPL ' + str(to_run['a']) + 'dbm')
                 if 'd' in to_run:
                    if 's' in to_run:
                        if to_run['s'] == 2:
                            yield self.cxn.krbjila_gpib.write('FM1:SOUR EXT2')
                        else:
                            yield self.cxn.krbjila_gpib.write('FM1:SOUR EXT1')
                    else:
                        yield self.cxn.krbjila_gpib.write('FM1:SOUR EXT1')
                    yield self.cxn.krbjila_gpib.write('FM1:DEV ' + str(to_run['d']) + 'MHz')
                    yield self.cxn.krbjila_gpib.write('FM1:STAT ON')
                    yield self.cxn.krbjila_gpib.write('OUTP:MOD ON')
                 yield self.cxn.krbjila_gpib.write('OUTP:STAT ON')  
         else:
             yield self.cxn.krbjila_gpib.write('FREQ 6834.7MHz')
             yield self.cxn.krbjila_gpib.write('POW:AMPL -19dbm') 
Ejemplo n.º 3
0
    def update(self):
        # if enabled
        if self.value:
            if not self.enabled:
                self.enabled = 1

                # connect to serial, set baud rate, and clear the input
                self.trigger = yield serial.Serial('/dev/' + self.port)
                self.trigger.baudrate = 9600
                self.trigger.reset_input_buffer()

                # loop: listen for data from the trigger
                # need to check self.value in order to correctly
                # terminate the while loop when the device is disabled
                while self.value:
                    # find the number of bytes in the input buffer
                    bytes_waiting = yield self.trigger.in_waiting
                    if bytes_waiting:
                        # read the entire buffer
                        newstate = yield int(
                            self.trigger.read(bytes_waiting)[-1])

                        if self.state != newstate:
                            # turn off rf output
                            yield self.cxn.krbjila_gpib.write('OUTP:STAT OFF')
                            # update the state and clear the serial buffer
                            self.state = newstate
                            yield self.trigger.reset_input_buffer()

                            to_run = {}
                            # look for parameters for the triggered state
                            for attr in ['defaults', 'value']:
                                loc = getattr(self, attr, {})

                                # this check is very important! otherwise everything will break when
                                # the defaults are run at the end of the experiment
                                if type(loc) is not int:
                                    if unicode(self.state) in loc:
                                        params = loc[unicode(self.state)]
                                        if u'frequency' in params:
                                            to_run['f'] = params[u'frequency']
                                        if u'amplitude' in params:
                                            to_run['a'] = params[u'amplitude']
                                        if u'evap' in params:
                                            to_run['e'] = params[u'evap']

                            # turn on the output
                            yield self.cxn.krbjila_gpib.write('OUTP:STAT ON')

                            # now, execute the parameters
                            # first, check if an evap trajectory is set up
                            if 'e' in to_run:
                                if to_run['e']:
                                    self.evap = evaporation()
                                    self.cmds = []
                                    for k in range(self.evap.points):
                                        self.cmds.append(
                                            'FREQ {:0.2f}kHz; VOLT {:0.2f}dbm'.
                                            format(self.evap.trajectory[k],
                                                   self.evap.amps[k]))
                                    for k in self.cmds:
                                        self.cxn.krbjila_gpib.write(k)
                                        yield sleep(self.evap.dt)
                            # if not, then just setting a single frequency and/or amplitude
                            elif ('f' in to_run) or ('a' in to_run):
                                if 'f' in to_run:
                                    yield self.cxn.krbjila_gpib.write(
                                        'FREQ ' + str(to_run['f']) + 'MHz')
                                if 'a' in to_run:
                                    yield self.cxn.krbjila_gpib.write(
                                        'POW:AMPL ' + str(to_run['a']) + 'dbm')
                            # if no parameters found, just configure as default
                            else:
                                yield self.cxn.krbjila_gpib.write(
                                    'FREQ 6834.7MHz')
                                yield self.cxn.krbjila_gpib.write(
                                    'POW:AMPL -19dbm')
                        else:
                            sleep(0.010)

                # once the while loop has terminated, close the serial connection
                self.trigger.close()
                self.enabled = 0
            # if not enabled, output the default (gray molasses)
        else:
            self.state = -1
            yield self.cxn.krbjila_gpib.write('OUTP:STAT OFF')
            yield self.cxn.krbjila_gpib.write('FREQ 6834.7MHz')
            yield self.cxn.krbjila_gpib.write('POW:AMPL -19dbm')
Ejemplo n.º 4
0
import visa
from time import sleep, time
from evaporate import evaporation

rm = visa.ResourceManager('@py')


def do_evap(evap, device):
	print("Total evaporation time is {:0.1f}s".format(evap.totaltime))

	cmds = []
	for k in range(evap.points):
		cmds.append('FREQ {:0.2f}kHz; VOLT {:0.2f}dbm;'.format(evap.trajectory[k],evap.amps[k]))	
	
	asg = rm.open_resource(device)
	asg.write("FUNC SIN; VOLT:OFFS 0V")
	asg.write("OUTP:STAT ON")
	for k in cmds:
		asg.write(k)
		sleep(evap.dt)
	asg.write("OUTP:STAT OFF")
	asg.close()

device = 'GPIB0::9::INSTR'
do_evap(evaporation(), device)