Example #1
0
 def performSetValue(self, quant, value, sweepRate=0.0, options={}):
     """Perform the Set Value instrument operation. This function should
     return the actual value set by the instrument"""
     if quant.name in ('Wait for new trace', ):
         # do nothing
         pass
     elif quant.name in ('Marker 1 - Function', ):
         m_idx = int(quant.name[7])
         if self.getValue(quant.name) == 'Band Power':
             self.writeAndLog('CALC:MARK%d:FUNC:BPOW:STAT ON' % m_idx)
         elif self.getValue(quant.name) == 'Noise Density':
             self.writeAndLog('CALC:MARK%d:FUNC:NOIS ON' % m_idx)
         else:
             pass
     elif quant.name in ('RBW', 'VBW', 'Detector', 'Sweep Time',
                         'Input Attenuation'):
         # manual performSetValue operation on certain quantities only if automatic setting is unchecked in the driver
         if not self.getValue(quant.name + ' - Auto'):
             # run standard VISA case
             value = VISA_Driver.performSetValue(self, quant, value,
                                                 sweepRate, options)
         else:
             # if automatic setting is checked, read the value from the instrument and save to local driver
             value = self.setValue(quant.name,
                                   self.readValueFromOther(quant.name))
     else:
         # run standard VISA case
         value = VISA_Driver.performSetValue(self, quant, value, sweepRate,
                                             options)
     return value
 def performSetValue(self, quant, value, sweepRate=0.0, options={}):
     """Perform the Set Value instrument operation. This function
     should return the actual value set by the instrument."""
     # check quantity name
     if quant.name == 'FrequencyA':
         self.writeAndLog('C0')
         self.writeAndLog('f%f' % (1.e-6 * value))
     elif quant.name == 'PowerA':
         self.writeAndLog('C0')
         self.writeAndLog('W%f' % value)
     elif quant.name == 'OutputA':
         self.writeAndLog('C0')
         self.writeAndLog('r%d' % value)
     elif quant.name == 'FrequencyB':
         self.writeAndLog('C1')
         self.writeAndLog('f%f' % (1.e-6 * value))
     elif quant.name == 'PowerB':
         self.writeAndLog('C1')
         self.writeAndLog('W%f' % value)
     elif quant.name == 'OutputB':
         self.writeAndLog('C1')
         self.writeAndLog('r%d' % value)
     else:
         # otherwise, call standard VISA case
         VISA_Driver.performSetValue(self, quant, value, sweepRate, options)
     return value
Example #3
0
 def performSetValue(self, quant, value, sweepRate=0.0, options={}):
     """Perform the Set Value instrument operation. This function should
     return the actual value set by the instrument"""
     # check if set value and in sweep mode
     if quant.name in ('Voltage', 'Current'):
         # check limits
         (dStep, dMax) = self.getMaxValueAndSmallestStep()
         if abs(value) > dMax:
             # new value out of range, return error
             raise Exception(
                 'New value (%.6g) is out of range (max = %.6g)' %
                 (value, dMax))
         # calculate actual value based on smallest step size
         value = dStep * np.round(value / dStep)
         # check if sweep mode or output off, if not call generic driver
         if sweepRate == 0.0 or (not self.getValue('Output')):
             return VISA_Driver.performSetValue(self,
                                                quant,
                                                value,
                                                0.0,
                                                options=options)
         # sweep mode, do it here
         # get old value to find sweep time and step size
         currValue = self.performGetValue(quant)
         if value == currValue:
             # already at the final value, return
             return value
         # if sweep range is less than two minimal steps, don't sweep
         if abs(value - currValue) < 2.5 * dStep:
             return VISA_Driver.performSetValue(self,
                                                quant,
                                                value,
                                                0.0,
                                                options=options)
         dSweepTime = abs(value - currValue) / sweepRate
         # don't allow sweep times that are shorter than 0.1 s
         dSweepTime = max(dSweepTime, 0.1)
         sSweepTime = '%.1f' % dSweepTime
         sCmd = '*CLS;:PROG:REP 0;' + \
                'SLOP %s;' % sSweepTime + \
                'INT %s;'  % sSweepTime + \
                'EDIT:STAR;' + \
                ':SOUR:LEV %.6E;' % value + \
                ':PROG:EDIT:END;' + \
                ':PROG:RUN'
         self.is_sweeping = True
         VISA_Driver.writeAndLog(self, sCmd)
         # return target value
         return value
     else:
         # for all other quantities, call the generic VISA driver
         return VISA_Driver.performSetValue(self,
                                            quant,
                                            value,
                                            sweepRate,
                                            options=options)
Example #4
0
 def performSetValue(self, quant, value, sweepRate=0.0, options={}):
     """Perform the Set Value instrument operation. This function
     should return the actual value set by the instrument."""
     # check quantity name
     if quant.name == 'Frequency':
         self.write('P%08.fZ0K0L3M0N6O3' % (value / 1000.))
     else:
         # otherwise, call standard VISA case
         VISA_Driver.performSetValue(self, quant, value, sweepRate, options)
     return value
Example #5
0
 def performSetValue(self, quant, value, sweepRate=0.0, options={}):
     """Perform the Set Value instrument operation. This function
     should return the actual value set by the instrument."""
     # check quantity name
     if quant.name == 'Frequency':
         self.write('FR%011.0fHZ' % value)
     elif quant.name == 'Power':
         self.write('LE%+.1fDM' % value)
     else:
         # otherwise, call standard VISA case
         VISA_Driver.performSetValue(self, quant, value, sweepRate, options)
     return value
Example #6
0
    def performSetValue(self, quant, value, sweepRate=0.0, options={}):
        """Perform the Set Value instrument operation. This function should
        return the actual value set by the instrument"""
        # start with setting local quant value
        # proceed depending on command
        if quant.name == 'Clock source':
            # for clock source, first read current value
            old_clock = self.askAndLog(':CLK:SOUR?')
            # get command string for new value, check if they match
            new_clock = quant.getCmdStringFromValue(value)
            if old_clock != new_clock:
                # clock has changed, update
                self.writeAndLog(':CLK:SOUR %s' % new_clock)
                # if internal, make sure clock frequency is 19.2 GHz
                if new_clock == 'CLKIN':
                    self.writeAndLog(':CLK:FREQ 19.2E9')
                # after clock change, we need to calibrate the system clock
                self.writeAndLog(':CAL:SCLK')

        else:
            # for all other cases, call VISA driver
            value = VISA_Driver.performSetValue(self,
                                                quant,
                                                value,
                                                sweepRate,
                                                options=options)
        return value
    def performSetValue(self, quant, value, sweepRate=0.0, options={}):
        """Perform the Set Value instrument operation. This function should
        return the actual value set by the instrument"""
		# create new channels if needed
        if quant.name in ('S11 - Enabled', 'S21 - Enabled', 'S12 - Enabled',
                          'S22 - Enabled'):
            # get updated list of measurements in use
            param = quant.name[:3]
            self.getActiveMeasurements()
            # clear old measurements for this parameter
            if param in self.dMeasParam:
                for name in self.dMeasParam[param]:
                    self.writeAndLog("CALC:PAR:DEL '%s'" % name)
            # create new measurement, if enabled is true
            if value:
                newName = 'LabC_%s' % param
                self.writeAndLog("CALC:PAR:SDEF '%s','%s'" % (newName, param))
                # show on PNA screen
                iTrace = 1 + ['S11', 'S21', 'S12', 'S22'].index(param)
                self.writeAndLog("DISP:WIND:TRAC%d:FEED '%s'" % (iTrace, newName))
                # add to dict with list of measurements
                self.dMeasParam[param] = [newName]
        elif quant.name in ('Wait for new trace',):
            # do nothing
            pass
        else:
            # run standard VISA case 
            value = VISA_Driver.performSetValue(self, quant, value, sweepRate, options)
        return value
 def performSetValue(self, quant, value, sweepRate=0.0, options={}):
     """Perform the Set Value instrument operation. This function should
     return the actual value set by the instrument"""
     if quant.name in ('Zero-span mode',):
         # set span to zero
         if value == True:
             quantSpan = self.instrCfg.getQuantity('Span')
             self.performSetValue(quantSpan, 0.0)
             quantPts = self.instrCfg.getQuantity('# of points')
             self.performSetValue(quantPts, 2)
             # sweep time should be set to a small value (for example, 10 ms)
             self.writeAndLog(':SWE:TIME:AUTO 0;:SWE:TIME 10E-3;')
         else:
             # set lowest possible span to get out of zero-span mode
             quantSpan = self.instrCfg.getQuantity('Span')
             self.performSetValue(quantSpan, 100.)
             # sweep time should be set to auto
             self.writeAndLog(':SWE:TIME:AUTO 1;')
     elif quant.name in ('Wait for new trace',):
         # turn on continous acquisition if not waiting     
         if value == False:
             self.writeAndLog(':INIT:CONT ON;')
     else:
         # run standard VISA case 
         value = VISA_Driver.performSetValue(self, quant, value, sweepRate, options)
     return value
 def performSetValue(self, quant, value, sweepRate=0.0, options={}):
     """Perform the Set Value instrument operation. This function should
     return the actual value set by the instrument"""
     
     if quant.name == 'Channel 1 Voltage':
         self.setVoltage(1, value)
     elif quant.name == 'Channel 2 Voltage':
         self.setVoltage(2, value)
     elif quant.name == 'Channel 3 Voltage':
         self.setVoltage(3, value)
     elif quant.name == 'Channel 4 Voltage':
         self.setVoltage(4, value)   
     elif quant.name == 'Channel 1 Autosweep':
         self.bSweep1 = value 
     elif quant.name == 'Channel 2 Autosweep':
         self.bSweep2 = value 
     elif quant.name == 'Channel 3 Autosweep':
         self.bSweep3 = value 
     elif quant.name == 'Channel 4 Autosweep':
         self.bSweep4 = value     
     else:
         # for all other quantities, call the generic VISA driver
         return VISA_Driver.performSetValue(self, quant, value, sweepRate,
                                            options=options)
     return value                         
    def performSetValue(self, quant, value, sweepRate=0.0, options={}):
        """Perform the Set Value instrument operation. This function should
        return the actual value set by the instrument"""

        #Try and parse the quantity name to get the quant type and channel number
        qname, qchannel = parse_qname(quant.name)

        if qname == 'Active Channel':
            ch_num = quant.getCmdStringFromValue(value)

            self.writeAndLog('SCAN %s, 0' % ch_num, bCheckError=False)

            #Wait three seconds for instrument to settle
            for x in range(100):
                self.wait(0.03)
                self.reportProgress(x / 100)

        elif qchannel is not None:

            #Grab the right command and index for the quantity
            for _cmd, _quants in SPECIAL_QUANTS.items():
                if qname in _quants:
                    cmd = _cmd
                    qix = _quants.index(qname)
                    break

            vals_list = self.askAndLog('%s? %s' % (cmd, qchannel),
                                       bCheckError=False).split(',')

            #Datatype 2 is COMBO
            if quant.datatype == 2:
                new_val = quant.getCmdStringFromValue(value)
            #Datatype 0 is DOUBLE, but for these commands it's really an INT
            elif quant.datatype == 0:
                new_val = '%d' % value
            #None of the inset/intype commands should be any other datatype, so raise error
            else:
                raise ValueError("Unknown data type")

            vals_list[qix] = new_val

            #If the user tries to set the resistance range of any channel
            #or the range/value of the control channel, turn off Autorange
            if (qname == 'Range') or (quant.name == 'Excitation Value A'):
                vals_list[2] = '0'

            self.writeAndLog('%s %s,%s' % (cmd, qchannel, ','.join(vals_list)))

            #Give the box a little time to do its thing
            self.wait(0.1)

            #Double check that anything actually changed. Not all options are always available
            #depending on setting. Like, if Autorange is on, then you can't set excitations.
            value = self.performGetValue(quant, options={})

        else:
            value = VISA_Driver.performSetValue(self, quant, value, sweepRate,
                                                options)

        return value
 def performSetValue(self, quant, value, sweepRate=0.0, options={}):
     """Perform the Set Value instrument operation. This function should
     return the actual value set by the instrument"""
     #        if quant.name in ('Zero-span mode',):
     if quant.name in ('Range type', ):
         if quant.getValueString(value) == 'Zero-span mode':
             # set span to zero
             self.sendValueToOther('Span', 0.0)
             self.sendValueToOther('# of points', 2.0)
             # sweep time should be set to a small value (for example, 10 ms)
             self.writeAndLog(':SWE:TIME:AUTO 0;:SWE:TIME 10E-3;')
         else:
             # set lowest possible span to get out of zero-span mode
             self.sendValueToOther('Span', 100.0)
             # sweep time should be set to auto
             self.writeAndLog(':SWE:TIME:AUTO 1;')
     elif quant.name in ('Wait for new trace', ):
         # turn on continous acquisition if not waiting
         if value == False:
             self.writeAndLog(':INIT:CONT ON;')
     else:
         # run standard VISA case
         value = VISA_Driver.performSetValue(self, quant, value, sweepRate,
                                             options)
     return value
 def performSetValue(self, quant, value, sweepRate=0.0, options={}):
     """Perform the Set Value instrument operation. This function should
     return the actual value set by the instrument"""
     if quant.name == 'S11 - Enabled':
         if value is True:
             # TODO: Strange block
             del_name = 'CH1_WIN1_LINE1_PARAM1'
             newName = 'LabC_S11'
         else:
             del_name = 'LabC_S11'
             newName = 'CH1_WIN1_LINE1_PARAM1'
         self.writeAndLog("CALC:PAR:DEL '%s'" %
                          del_name)  # Delete the default measurement.
         self.writeAndLog(
             "CALC:PAR:DEF '%s',%s" %
             (newName,
              'S11'))  # Replace it with a new measurement named 'LabC_S11'
         self.writeAndLog(
             "DISP:WIND:TRAC%d:FEED '%s'" % (1, newName)
         )  # Display the trace of new measurement on front panel.
     elif quant.name in (
             'S21 - Enabled',
             'S12 - Enabled',
             'S22 - Enabled',
     ):
         param = quant.name[:3]
         self.getActiveMeasurements()
         # Clear all measurements.
         if param in self.dMeasParam:  # TODO: Strange condition.
             for name in self.dMeasParam[param]:
                 self.writeAndLog("CALC:PAR:DEL '%s'" % name)
         # Add a new measurement if enabled.
         if value is True:
             newName = 'LabC_%s' % param
             self.writeAndLog("CALC:PAR:DEF '%s',%s" %
                              (newName, param))  # Add a new measurement.
             iTrace = 1 + ['S11', 'S21', 'S12', 'S22'].index(param)
             # Add a new trace for displaying measurement
             self.writeAndLog("DISP:WIND:TRAC%d:FEED '%s'" %
                              (iTrace, newName))
             self.dMeasParam[param] = [
                 newName
             ]  # Update list of currently active measurments.
     elif quant.name in ('Wait for new trace',
                         # 'Range type', # TODO: Why?
                         ):
         # Do nothing, just changing local values.
         pass
     else:
         # For all other cases, call VISA driver
         value = VISA_Driver.performSetValue(self, quant, value, sweepRate,
                                             options)
         # Try to get the value from instrument.
         if quant.get_cmd:
             value = self.askAndLog(quant.get_cmd)
         elif quant.set_cmd:
             value = self.askAndLog(quant.set_cmd + '?')
         else:
             pass
     return value
Example #13
0
 def performSetValue(self, quant, value, sweepRate=0.0, options={}):
     """Perform the Set Value instrument operation. This function should
     return the actual value set by the instrument"""
     if quant.name in ('Ch1 - voltage', 'Ch2 - voltage'):
         ch = quant.name[2]
         start = self.readValueFromOther(quant.name)
         stop = value
         self.log(f'Set {quant.name} called. start:{start}, stop:{stop}')
         dt = 0.1
         rate = self.getValue('Sweep speed')
         step = min(rate * dt,
                    abs(stop - start) / 2) * np.sign(stop - start)
         value = start
         while np.sign(
             (value - stop) * (start - stop)) == 1 and not self.isStopped():
             if np.sign((value + step - stop) * (start - stop)) == 1:
                 value = value + step
             else:
                 value = stop
             self.writeAndLog(f':SOUR{ch}:APPL:DC 1,1,{value}')
             time.sleep(dt)
     elif quant.name in ('Sweep speed'):
         quant.setValue(value)
     else:
         value = VISA_Driver.performSetValue(self, quant, value, sweepRate,
                                             options)
     # wait for instrument
     time.sleep(0.05)
     return value
Example #14
0
 def performSetValue(self, quant, value, sweepRate=0.0, options={}):
     """Perform the Set Value instrument operation. This function should
     return the actual value set by the instrument"""
     # perform special setValue for delay commands
     name = str(quant.name)
     if name.endswith(('Start time', 'Start reference',
                       'Stop time', 'Stop reference')):
         # get pulse channel in use
         lName =  name.split(' ')
         key = '%s - %s' % (lName[0], lName[2])
         sChannel = '%d' % self.dChCmd[key]
         # get buddy quantity
         if lName[3] == 'time':
             sTime = quant.getCmdStringFromValue(value)
             sRef = self.getCmdStringFromValue('%s - %s reference' % 
                                               (lName[0], lName[2]))
         else:
             sTime = self.getCmdStringFromValue('%s - %s time' %
                                                (lName[0], lName[2]))
             sRef = quant.getCmdStringFromValue(value)
         sCmd = 'DLAY %s,%s,%s' % (sChannel, sRef, sTime)
         self.writeAndLog(sCmd)
         return value
     else:
         # for all other quantities, call the generic VISA driver
         return VISA_Driver.performSetValue(self, quant, value, sweepRate,
                                            options=options)
	def performSetValue(self, quant, value, sweepRate=0.0, options={}):
		"""Perform the Set Value instrument operation. This function should return the actual value set by the instrument"""
		if quant.name in ('Range type',):
			if quant.getValueString(value) == 'Zero-span mode':
				# set span to zero
				self.sendValueToOther('Span', 0.0)
				self.sendValueToOther('# of points', 2.0)
				#sweep time should be set to a small value (for example, 10 ms)
				self.writeAndLog(':SWE:TIME 1E-3;')
			else:
                # set lowest possible span to get out of zero-span mode
				if self.getValue('Span') < 10:
					self.sendValueToOther('Span', 1000000)
				if self.getValue('# of points') == 2:
					self.sendValueToOther('# of points', 1001)
				# sweep time should be set to auto
				self.writeAndLog(':SWE:TIME:AUTO 1;')
		elif quant.name in ('Wait for new trace',):
            # turn on continous acquisition if not waiting     
			if value == False:
				self.writeAndLog(':INIT:CONT ON;')
		elif quant.name in ('Trace type CS', 'Trace type CW', 'Measurement Type'):
			pass
		else:
			# run standard VISA case 
			value = VISA_Driver.performSetValue(self, quant, value, sweepRate, options)
		return value
Example #16
0
    def performSetValue(self, quant, value, sweepRate=0.0, options={}):
        """Perform the Set Value instrument operation. This function should
        return the actual value set by the instrument"""
		# create new channels if needed
        if quant.name in ('S11 - Enabled', 'S21 - Enabled', 'S12 - Enabled',
                          'S22 - Enabled'):
            # get updated list of measurements in use
            param = quant.name[:3]
            self.getActiveMeasurements()
            # clear old measurements for this parameter
            if param in self.dMeasParam:
                for name in self.dMeasParam[param]:
                    self.writeAndLog("CALC:PAR:DEL '%s'" % name)
            # create new measurement, if enabled is true
            if value:
                newName = 'LabC_%s' % param
                self.writeAndLog("CALC:PAR:SDEF '%s','%s'" % (newName, param))
                # show on PNA screen
                iTrace = 1 + ['S11', 'S21', 'S12', 'S22'].index(param)
                self.writeAndLog("DISP:WIND:TRAC%d:FEED '%s'" % (iTrace, newName))
                # add to dict with list of measurements
                self.dMeasParam[param] = [newName]
        elif quant.name in ('Wait for new trace',):
            # do nothing
            pass
        elif quant.name == '# of points':
            self.write(':SENS:SWE:POIN ' + str(int(value)))
        elif quant.name == '# of averages':
            self.write(':SENS:AVER:COUN ' + str(int(value)))
        else:
            # run standard VISA case 
            value = VISA_Driver.performSetValue(self, quant, value, sweepRate, options)
        return value
 def performSetValue(self, quant, value, sweepRate=0.0, options={}):
     """Perform the Set Value instrument operation. This function
     should return the actual value set by the instrument."""
     # keep track of if waveform is updated, to avoid sending it many
     # times
     if self.isFirstCall(options):
         self.bWaveUpdated = False
     if quant.name == 'Arbitrary waveform':
         # set value, then mark that waveform needs an update
         quant.setValue(value)
         self.bWaveUpdated = True
     else:
         # there seem to be a descipancy on what voltage mean
         if quant.name == 'Voltage':
             value /= 2.
         # for all other cases, call VISA driver
         value = VISA_Driver.performSetValue(self,
                                             quant,
                                             value,
                                             sweepRate,
                                             options=options)
         if quant.name == 'Voltage':
             value *= 2.
     # if final call and wave is updated, send it to AWG
     if self.isFinalCall(options) and self.bWaveUpdated:
         self.sendWaveform()
     return value
Example #18
0
 def performSetValue(self, quant, value, sweepRate=0.0, options={}):
     """Perform the Set Value instrument operation. This function should
     return the actual value set by the instrument"""
     # update visa commands for triggers
     if quant.name in ('S11 - Enabled', 'S21 - Enabled', 'S12 - Enabled',
                       'S22 - Enabled'):
         if self.getModel() in ('E5071C', ):
             # new trace handling, use trace numbers, set all at once
             lParam = ['S11', 'S21', 'S12', 'S22']
             dParamValue = dict()
             for param in lParam:
                 dParamValue[param] = self.getValue('%s - Enabled' % param)
             dParamValue[quant.name[:3]] = value
             # add parameters, if enabled
             self.dMeasParam = dict()
             for (param, enabled) in dParamValue.items():
                 if enabled:
                     nParam = len(self.dMeasParam) + 1
                     self.writeAndLog(":CALC:PAR%d:DEF %s" %
                                      (nParam, param))
                     self.dMeasParam[param] = nParam
             # set number of visible traces
             self.writeAndLog(":CALC:PAR:COUN %d" % len(self.dMeasParam))
         else:
             # get updated list of measurements in use
             self.getActiveMeasurements()
             param = quant.name[:3]
             # old-type handling of traces
             if param in self.dMeasParam:
                 # clear old measurements for this parameter
                 for name in self.dMeasParam[param]:
                     self.writeAndLog("CALC:PAR:DEL '%s'" % name)
             # create new measurement, if enabled is true
             if value:
                 newName = 'LabC_%s' % param
                 self.writeAndLog("CALC:PAR:EXT '%s','%s'" %
                                  (newName, param))
                 # show on PNA screen
                 iTrace = 1 + ['S11', 'S21', 'S12', 'S22'].index(param)
                 #                sPrev = self.askAndLog('DISP:WIND:CAT?')
                 #                if sPrev.find('EMPTY')>0:
                 #                    # no previous traces
                 #                    iTrace = 1
                 #                else:
                 #                    # previous traces, add new
                 #                    lTrace = sPrev[1:-1].split(',')
                 #                    iTrace = int(lTrace[-1]) + 1
                 self.writeAndLog("DISP:WIND:TRAC%d:FEED '%s'" %
                                  (iTrace, newName))
                 # add to dict with list of measurements
                 self.dMeasParam[param] = [newName]
     elif quant.name in ('Wait for new trace', ):
         # do nothing
         pass
     else:
         # run standard VISA case
         value = VISA_Driver.performSetValue(self, quant, value, sweepRate,
                                             options)
     return value
 def performSetValue(self, quant, value, sweepRate=0.0, options={}):
     """Perform the set value operation"""
     # check type of quantity: There seems to be a problem with some float type commands... (i.e. oscillator frequency) Use the fixed point version instead.
     if quant.name in ("Oscillator Frequency"):
         self.writeAndLog(quant.set_cmd + " " + str(int(value * 1000)))  # Fixed point version uses mHz
     else:
         return VISA_Driver.performSetValue(self, quant, value, sweepRate, options=options)
     return value
 def performSetValue(self, quant, value, sweepRate=0.0, options={}):
     """Perform the Set Value instrument operation. This function should
     return the actual value set by the instrument"""
     # if quant.name == 'blah':
     #    self.dsa. _set(value)
     # else:
     # for all other quantities, call the generic VISA driver
     return VISA_Driver.performSetValue(self, quant, value, sweepRate, options=options)
Example #21
0
 def performSetValue(self, quant, value, sweepRate=0.0, options={}):
     """Perform the Set Value instrument operation. This function should
     return the actual value set by the instrument"""
     # keep track of if waveform is updated, to avoid sending it many times
     if self.isFirstCall(options):
         self.bWaveUpdated = False
         # if sequence mode, make sure the buffer contains enough waveforms
         if self.isHardwareLoop(options):
             (seq_no, n_seq) = self.getHardwareLoopIndex(options)
             # if first call, clear sequence and create buffer
             if seq_no == 0:
                 # variable for keepin track of sequence updating
                 self.writeAndLog(':AWGC:STOP;')
                 self.bSeqUpdate = False
             # if different sequence length, re-create buffer
             if seq_no == 0 and n_seq != len(self.lOldU16):
                 self.lOldU16 = [[np.array([], dtype=np.uint16) \
                                for n1 in range(self.nCh)] for n2 in range(n_seq)]
         elif self.isHardwareTrig(options):
             # if hardware triggered, always stop outputting before setting
             self.writeAndLog(':AWGC:STOP;')
     if quant.name in ('Ch 1', 'Ch 2', 'Ch 3', 'Ch 4', 'Ch 1 - Marker 1',
                       'Ch 1 - Marker 2', 'Ch 2 - Marker 1',
                       'Ch 2 - Marker 2', 'Ch 3 - Marker 1',
                       'Ch 3 - Marker 2', 'Ch 4 - Marker 1',
                       'Ch 4 - Marker 2'):
         # set value, then mark that waveform needs an update
         quant.setValue(value)
         self.bWaveUpdated = True
     elif quant.name in ('Run'):
         self.writeAndLog(':AWGC:RUN')
         # turn on channels again, to avoid issues when turning on/off run mode
         sOutput = ''
         for n, bUpdate in enumerate(self.lInUse):
             if bUpdate:
                 sOutput += (':OUTP%d:STAT 1;' % (n + 1))
         if sOutput != '':
             self.writeAndLog(sOutput)
     else:
         # for all other cases, call VISA driver
         value = VISA_Driver.performSetValue(self,
                                             quant,
                                             value,
                                             sweepRate,
                                             options=options)
     # if final call and wave is updated, send it to AWG
     if self.isFinalCall(options) and self.bWaveUpdated:
         (seq_no, n_seq) = self.getHardwareLoopIndex(options)
         if self.isHardwareLoop(options):
             seq = seq_no
             self.reportStatus('Sending waveform (%d/%d)' %
                               (seq_no + 1, n_seq))
         else:
             seq = None
         bStart = not self.isHardwareTrig(options)
         self.sendWaveformAndStartTek(seq=seq, n_seq=n_seq, bStart=bStart)
     return value
 def performSetValue(self, quant, value, sweepRate=0.0, options={}):
     """Perform the Set Value instrument operation. This function should
     return the actual value set by the instrument"""
     if quant.name == 'Number of shifts':  
         self.numRep= value
     else:
         # for all other quantities, call the generic VISA driver
         value = VISA_Driver.performSetValue(self, quant, value, sweepRate, options=options)
     return value
    def performSetValue(self, quant, value, sweepRate=0.0, options={}):
        """Perform the Set Value instrument operation. This function should
        return the actual value set by the instrument"""

        return VISA_Driver.performSetValue(self,
                                           quant,
                                           value,
                                           sweepRate,
                                           options=options)
 def performSetValue(self, quant, value, sweepRate=0.0, options={}):
     """Perform the Set Value instrument operation. This function should
     return the actual value set by the instrument"""
     # update visa commands for triggers
     if quant.name in ('S11 - Enabled', 'S21 - Enabled', 'S12 - Enabled',
                       'S22 - Enabled'):
         if self.getModel() in ('E5071C',):
             # new trace handling, use trace numbers, set all at once
             lParam = ['S11', 'S21', 'S12', 'S22']
             dParamValue = dict()
             for param in lParam:
                 dParamValue[param] = self.getValue('%s - Enabled' % param)
             dParamValue[quant.name[:3]] = value
             # add parameters, if enabled
             self.dMeasParam = dict()
             for (param, enabled) in dParamValue.items():
                 if enabled:
                     nParam = len(self.dMeasParam)+1
                     self.writeAndLog(":CALC:PAR%d:DEF %s" %
                                      (nParam, param))
                     self.dMeasParam[param] = nParam
             # set number of visible traces
             self.writeAndLog(":CALC:PAR:COUN %d" % len(self.dMeasParam))
         else:
             # get updated list of measurements in use
             self.getActiveMeasurements()
             param = quant.name[:3]
             # old-type handling of traces
             if param in self.dMeasParam:
                 # clear old measurements for this parameter
                 for name in self.dMeasParam[param]:
                     self.writeAndLog("CALC:PAR:DEL '%s'" % name)
             # create new measurement, if enabled is true
             if value:
                 newName = 'LabC_%s' % param
                 self.writeAndLog("CALC:PAR:EXT '%s','%s'" % (newName, param))
                 # show on PNA screen
                 iTrace = 1 + ['S11', 'S21', 'S12', 'S22'].index(param)
 #                sPrev = self.askAndLog('DISP:WIND:CAT?')
 #                if sPrev.find('EMPTY')>0:
 #                    # no previous traces
 #                    iTrace = 1
 #                else:
 #                    # previous traces, add new
 #                    lTrace = sPrev[1:-1].split(',')
 #                    iTrace = int(lTrace[-1]) + 1
                 self.writeAndLog("DISP:WIND:TRAC%d:FEED '%s'" % (iTrace, newName))
                 # add to dict with list of measurements
                 self.dMeasParam[param] = [newName]
     elif quant.name in ('Wait for new trace',):
         # do nothing
         pass
     else:
         # run standard VISA case 
         value = VISA_Driver.performSetValue(self, quant, value, sweepRate, options)
     return value
 def performSetValue(self, quant, value, sweepRate=0.0, options={}):
     """Perform the Set Value instrument operation. This function should
     return the actual value set by the instrument"""
     # update visa commands for triggers
     if quant.name in (''):
         pass
     else:
         # run standard VISA case
         value = VISA_Driver.performSetValue(self, quant, value, sweepRate, options)
     return value
    def performSetValue(self, quant, value, sweepRate=0.0, options={}):
        """Perform the Set Value instrument operation. This function should
        return the actual value set by the instrument"""
		# create new channels if needed
        if quant.name in ('Wait for new trace',):
            # do nothing
            pass
        else:
            # run standard VISA case 
            value = VISA_Driver.performSetValue(self, quant, value, sweepRate, options)
        return value
Example #27
0
 def performSetValue(self, quant, value, sweepRate=0.0, options={}):
     """Perform the Set Value instrument operation. This function should
     return the actual value set by the instrument"""
     # create new channels if needed
     if quant.name in ('Wait for new trace', ):
         # do nothing
         pass
     else:
         # run standard VISA case
         value = VISA_Driver.performSetValue(self, quant, value, sweepRate,
                                             options)
     return value
 def performSetValue(self, quant, value, sweepRate=0.0, options={}):
     if quant.name == 'RF Frequency 1':
         self.f1 = float(value)
         self.reset()
     
     elif quant.name == 'RF Frequency 2':
         self.f2 = float(value)
         self.reset()
     else:
         # for all other quantities, call the generic VISA driver
         return VISA_Driver.performSetValue(self, quant, value, sweepRate, options=options)
     return value
Example #29
0
 def performSetValue(self, quant, value, sweepRate=0.0, options={}):
     """Perform the Set Value instrument operation. This function should
     return the actual value set by the instrument"""
     # keep track of if waveform is updated, to avoid sending it many times
     if self.isFirstCall(options):
         self.bWaveUpdated = False
         # if sequence mode, make sure the buffer contains enough waveforms
         if self.isHardwareLoop(options):
             (seq_no, n_seq) = self.getHardwareLoopIndex(options)
             # if first call, clear sequence and create buffer
             if seq_no==0:
                 # variable for keepin track of sequence updating
                 self.writeAndLog(':AWGC:STOP;')
                 self.bSeqUpdate = False
             # if different sequence length, re-create buffer
             if seq_no==0 and n_seq != len(self.lOldU16):
                 self.lOldU16 = [[np.array([], dtype=np.uint16) \
                                for n1 in range(self.nCh)] for n2 in range(n_seq)]
         elif self.isHardwareTrig(options):
             # if hardware triggered, always stop outputting before setting
             self.writeAndLog(':AWGC:STOP;')
     if quant.name in ('Ch 1', 'Ch 2', 'Ch 3', 'Ch 4',
                       'Ch 1 - Marker 1', 'Ch 1 - Marker 2',
                       'Ch 2 - Marker 1', 'Ch 2 - Marker 2',
                       'Ch 3 - Marker 1', 'Ch 3 - Marker 2',
                       'Ch 4 - Marker 1', 'Ch 4 - Marker 2'):
         # set value, then mark that waveform needs an update
         quant.setValue(value)
         self.bWaveUpdated = True
     elif quant.name in ('Run'):
         self.writeAndLog(':AWGC:RUN')
         # turn on channels again, to avoid issues when turning on/off run mode
         sOutput = ''
         for n, bUpdate in enumerate(self.lInUse):
             if bUpdate:
                 sOutput += (':OUTP%d:STAT 1;' % (n+1))
         if sOutput != '':
             self.writeAndLog(sOutput)
     else:
         # for all other cases, call VISA driver
         value = VISA_Driver.performSetValue(self, quant, value, sweepRate,
                                             options=options)
     # if final call and wave is updated, send it to AWG
     if self.isFinalCall(options) and self.bWaveUpdated:
         (seq_no, n_seq) = self.getHardwareLoopIndex(options)
         if self.isHardwareLoop(options):
             seq = seq_no
             self.reportStatus('Sending waveform (%d/%d)' % (seq_no+1, n_seq))
         else:
             seq = None
         bStart = not self.isHardwareTrig(options)
         self.sendWaveformAndStartTek(seq=seq, n_seq=n_seq, bStart=bStart)
     return value
 def performSetValue(self, quant, value, sweepRate=0.0, options={}):
     """Perform the set value operation"""
     # check type of quantity
     self.log("Quantity is" + str(quant.name))
     if quant.name == "# of points":
         self.log("# of points is" + str(value))
         value = int(value)
         self.log("After conversion is" + str(value))
         self.write(":WAV:POIN %d" % value)
     else:
         value = VISA_Driver.performSetValue(self, quant, value, sweepRate,
                                             options)
     return value
 def performSetValue(self, quant, value, sweepRate=0.0, options={}):
     """Perform the Set Value instrument operation. This function should
     return the actual value set by the instrument"""
     # update visa commands for triggers
     if quant.name == 'Trig slope':
         sTrig = self.getCmdStringFromValue('Trig source')
         quant.set_cmd = '%s:TRSL' % sTrig
     elif quant.name == 'Trig level':
         sTrig = self.getCmdStringFromValue('Trig source')
         quant.set_cmd = '%s:TRLV' % sTrig
     # run standard VISA case with updated commands
     value = VISA_Driver.performSetValue(self, quant, value, sweepRate, options)
     return value
Example #32
0
 def performSetValue(self, quant, value, sweepRate=0.0, options={}):
     """Perform the Set Value instrument operation. This function should
     return the actual value set by the instrument"""
     # check quantity
     if quant.name == 'Magnetic Field':
         if sweepRate != 0:
             # sweep rate should be in T/min
             self.writeAndLog('$T'+ str(sweepRate*60.0))
         self.writeAndLog('$J'+  str(value))
         self.writeAndLog('$A1')
     else:
         # run standard VISA case 
         value = VISA_Driver.performSetValue(self, quant, value, sweepRate, options)
     return value
Example #33
0
 def performSetValue(self, quant, value, sweepRate=0.0, options={}):
     """Perform the Set Value instrument operation. This function should
     return the actual value set by the instrument"""
     # update visa commands for triggers
     if quant.name == 'Trig slope':
         sTrig = self.getCmdStringFromValue('Trig source')
         quant.set_cmd = '%s:TRSL' % sTrig
     elif quant.name == 'Trig level':
         sTrig = self.getCmdStringFromValue('Trig source')
         quant.set_cmd = '%s:TRLV' % sTrig
     # run standard VISA case with updated commands
     value = VISA_Driver.performSetValue(self, quant, value, sweepRate,
                                         options)
     return value
 def performSetValue(self, quant, value, sweepRate=0.0, options={}):
     """Perform the set value operation"""
     # check type of quantity: There seems to be a problem with some float type commands... (i.e. oscillator frequency) Use the fixed point version instead.
     if quant.name in ('Oscillator Frequency'):
         self.writeAndLog(
             quant.set_cmd + " " +
             str(int(value * 1000)))  #Fixed point version uses mHz
     else:
         return VISA_Driver.performSetValue(self,
                                            quant,
                                            value,
                                            sweepRate,
                                            options=options)
     return value
 def performSetValue(self, quant, value, sweepRate=0.0, options={}):
     """Perform the Set Value instrument operation. This function should
     return the actual value set by the instrument"""
     # check quantity
     if quant.name == 'Magnetic Field':
         if sweepRate != 0:
             # sweep rate should be in T/min
             self.writeAndLog('$T'+ str(sweepRate*60.0))
         self.writeAndLog('$J'+  str(value))
         self.writeAndLog('$A1')
     else:
         # run standard VISA case 
         value = VISA_Driver.performSetValue(self, quant, value, sweepRate, options)
     return value
 def performSetValue(self, quant, value, sweepRate=0.0, options={}):
     """Perform the Set Value instrument operation. This function should
     return the actual value set by the instrument"""
     # check quantity
     if quant.name == 'Magnetic Field':
         if sweepRate != 0:
             # sweep rate should be in T/min
             self._do_write('SET:DEV:GRPZ:PSU:SIG:RFST:'+ str(sweepRate*60.0))
         self._do_write('SET:DEV:GRPZ:PSU:SIG:FSET:'+  str(value))
         self._do_write('SET:DEV:GRPZ:PSU:ACTN:RTOS')
     else:
         # run standard VISA case 
         value = VISA_Driver.performSetValue(self, quant, value, sweepRate, options)
     return value
Example #37
0
    def performSetValue(self, quant, value, sweepRate=0.0, options={}):
        """Perform the Set Value instrument operation. This function should
        return the actual value set by the instrument"""

        if self.isFinalCall(options) and self.getValue(
                'Sweep type') == 'Lorentzian':
            self.setLorentzianSweep()
        # update visa commands for triggers
        if quant.name in ('S11 - Enabled', 'S21 - Enabled', 'S12 - Enabled',
                          'S22 - Enabled'):
            if self.getModel() in ('E5071C', ):
                # new trace handling, use trace numbers, set all at once
                lParam = ['S11', 'S21', 'S12', 'S22']
                dParamValue = dict()
                for param in lParam:
                    dParamValue[param] = self.getValue('%s - Enabled' % param)
                dParamValue[quant.name[:3]] = value

                # add parameters, if enabled
                self.dMeasParam = dict()
                for (param, enabled) in dParamValue.items():
                    if enabled:
                        nParam = len(self.dMeasParam) + 1
                        self.writeAndLog(":CALC:PAR%d:DEF %s" %
                                         (nParam, param))
                        self.dMeasParam[param] = nParam
                # set number of visible traces
                self.writeAndLog(":CALC:PAR:COUN %d" % len(self.dMeasParam))

        elif quant.name in ('Acquire new trace', ):
            # do nothing
            pass
        elif quant.name in ('Sweep type'):
            # if linear:
            if self.getValue('Sweep type') == 'Linear':
                self.writeAndLog(':SENS:SWE:TYPE LIN')
            #if log:
            elif self.getValue('Sweep type') == 'Log':
                self.writeAndLog(':SENS:SWE:TYPE LOG')
            # if Lorentzian:
            elif self.getValue('Sweep type') == 'Lorentzian':
                # prepare VNA for segment sweep
                self.writeAndLog(':SENS:SWE:TYPE SEGM')

        else:
            # run standard VISA case
            value = VISA_Driver.performSetValue(self, quant, value, sweepRate,
                                                options)
        return value
Example #38
0
 def performSetValue(self, quant, value, sweepRate=0.0, options={}):
     """Perform the Set Value instrument operation. This function should
     return the actual value set by the instrument"""
     if quant.name in ('Wait for new trace',):
         # do nothing
         pass
     elif quant.name in ('Range type'):
         if value in ('Center - Span', 'Start - Stop'):
             self.writeAndLog('SENSe:LIST:POWer:STATe OFF;:INIT:CONT ON')
         elif value in ('Single', 'List'):
             self.writeAndLog('SENSe:LIST:POWer:SET OFF,ON,OFF,IMM,POS,0,0')
     else:
         # run standard VISA case
         value = VISA_Driver.performSetValue(self, quant, value, sweepRate, options)
     return value
 def performSetValue(self, quant, value, sweepRate=0.0, options={}):
     """Perform the Set Value instrument operation. This function should
     return the actual value set by the instrument"""
     name = str(quant.name)
     if name == 'Firmware Version':
         # read-only channels don't perform setValue
         pass
     elif name.endswith(('Active Voltage', 'Active Current')):
         return self.getValue(name)
     else:
         # else, call the generic VISA driver
         return VISA_Driver.performSetValue(self,
                                            quant,
                                            value,
                                            sweepRate,
                                            options=options)
Example #40
0
 def performSetValue(self, quant, value, sweepRate=0.0, options={}):
     """Perform the Set Value instrument operation. This function should
     return the actual value set by the instrument"""
     if quant.name in ('A1', 'A2', 'A3', 'A4', 'A5', 'A6',
                       'B1', 'B2', 'B3', 'B4', 'B5', 'B6'):
         sSet = 's' if value else 'r'
         sBank = quant.name[0].lower()
         sChannel = quant.name[1]
         dPulse = self.getValue('Pulse Length %s' % quant.name[0])*1E3
         sCmd = '%s%s%s,%d' % (sSet, sBank, sChannel, dPulse)
         self.writeAndLog(sCmd)
         reply = self.read()
         self.log('Response: ' + reply)
         return value
     else:
         # for all other quantities, call the generic VISA driver
         return VISA_Driver.performSetValue(self, quant, value, sweepRate,
                                            options=options)
 def performSetValue(self, quant, value, sweepRate=0.0, options={}):
     """Perform the Set Value instrument operation. This function should
     return the actual value set by the instrument"""
     # keep track of if waveform is updated, to avoid sending it many times
     if self.isFirstCall(options):
         self.bWaveUpdated = False
     if quant.name in ('Arb. Waveform',):
         # set value, then mark that waveform needs an update
         quant.setValue(value)
         self.bWaveUpdated = True
     else:
         # for all other cases, call VISA driver
         value = VISA_Driver.performSetValue(self, quant, value, sweepRate,
                                             options=options)
     # if final call and wave is updated, send it to AWG
     if self.isFinalCall(options) and self.bWaveUpdated:
         self.sendWaveform()
     return value
Example #42
0
    def performSetValue(self, quant, value, sweepRate=0.0, options={}):
        """Perform the Set Value instrument operation. This function should
        return the actual value set by the instrument"""
        if self.isFirstCall(options):
            self.lWaveUpdated = [False] * self.nCh

        # check if channel-specific, if so get channel + name
        if quant.name.startswith('Ch') and len(quant.name) > 6:
            ch = int(quant.name[2]) - 1
            name = quant.name[6:]
            ch_str = ':INST %d;' % (ch + 1)
        else:
            ch, name = None, ''
            ch_str = ''

        # proceed depending on command
        if name in ('Run mode', ):
            # run mode, different call types
            if value == 'Continuous':
                self.writeAndLog(ch_str + ':INIT:CONT 1; :INIT:GATE 0')
            elif value == 'Gated':
                self.writeAndLog(ch_str + ':INIT:CONT 0; :INIT:GATE 1')
            elif value == 'Triggered':
                self.writeAndLog(ch_str + ':INIT:CONT 0; :INIT:GATE 0')

        elif quant.name in ('Ch 1', 'Ch 2', 'Ch 1 - Marker 1',
                            'Ch 1 - Marker 2', 'Ch 2 - Marker 1',
                            'Ch 2 - Marker 2'):
            # set value, then mark that waveform needs an update
            quant.setValue(value)
            ch = int(quant.name[3]) - 1
            self.lWaveUpdated[ch] = True

        else:
            # for all other cases, call VISA driver
            value = VISA_Driver.performSetValue(self, quant, value, sweepRate,
                                                options)

        # For effiency, we only upload the waveform at the final call
        if self.isFinalCall(options) and np.any(self.lWaveUpdated):
            self.sendWaveformAndStart()

        return value
    def performSetValue(self, quant, value, sweepRate=0.0, options={}):
        """Perform the Set Value instrument operation. This function should
        return the actual value set by the instrument"""
        
        if quant.name == 'I Voltage':
            self.writeAndLog('P1 V'+str(float(value))+' X')
        elif quant.name == 'Q Voltage':
            self.writeAndLog('P2 V'+str(float(value))+' X')

        elif quant.name == 'Amplitude':
            self.amplitude = value
            self.setVoltages()
            
        elif quant.name == 'Phase':
            self.phase = value
            self.setVoltages()
        elif quant.name == 'I Offset':
            self.IOffset = value
            self.setVoltages()
        elif quant.name == 'Q Offset':
            self.QOffset = value
            self.setVoltages()
        elif quant.name == 'II':
            self.II = value
            self.setVoltages()
        elif quant.name == 'QQ':
            self.QQ = value
            self.setVoltages()
        elif quant.name == 'IQ':
            self.IQ = value
            self.setVoltages()
        elif quant.name == 'QI':
            self.QI = value
            self.setVoltages()
            
       
        else:
            # for all other quantities, call the generic VISA driver
            return VISA_Driver.performSetValue(self, quant, value, sweepRate,
                                               options=options)
        return value                         
Example #44
0
 def performSetValue(self, quant, value, sweepRate=0.0, options={}):
     """Perform the Set Value instrument operation. This function should
     return the actual value set by the instrument"""
     # keep track of if waveform is updated, to avoid sending it many times
     if self.isFirstCall(options):
         self.bWaveUpdated = False
     if quant.name in ('Arb. Waveform', ):
         # set value, then mark that waveform needs an update
         quant.setValue(value)
         self.bWaveUpdated = True
     else:
         # for all other cases, call VISA driver
         value = VISA_Driver.performSetValue(self,
                                             quant,
                                             value,
                                             sweepRate,
                                             options=options)
     # if final call and wave is updated, send it to AWG
     if self.isFinalCall(options) and self.bWaveUpdated:
         self.sendWaveform()
     return value
Example #45
0
 def performSetValue(self, quant, value, sweepRate=0.0, options={}):
     """Perform the Set Value instrument operation. This function should
     return the actual value set by the instrument"""
     # check quantity
     if quant.name == 'Magnetic Field':
         # conversion from T -> mT
         valueT = int(value*1000)
         # send value as integer of mT
         self.wait(delayTime)
         if sweepRate > 0:
             # convert sweep rate from T/s to mT/min
             valueR = int(sweepRate*60000)
             self.writeAndLog('$T%.5d' %  valueR)
         self.wait(delayTime)
         self.writeAndLog('$J%.5d' %  valueT)
         self.wait(delayTime)
         self.writeAndLog('$A1')
     else:
         # run standard VISA case 
         value = VISA_Driver.performSetValue(self, quant, value, sweepRate, options)
     return value
Example #46
0
 def performSetValue(self, quant, value, sweepRate=0.0, options={}):
     """Perform the Set Value instrument operation. This function should
     return the actual value set by the instrument"""
     # create new channels if needed
     if quant.name in ('Range type', ):
         if quant.getValueString(value) == 'Zero-span mode':
             # set span to zero
             self.sendValueToOther('Span', 0.0)
             self.sendValueToOther('# of points', 2.0)
             # sweep time should be set to a small value (for example, 10 ms)
             self.writeAndLog(':SWE:TIME:AUTO 0;:SWE:TIME 10E-3;')
     elif quant.name in ('Wait for new trace', ):
         # if quant.name in ('Wait for new trace',):
         # do nothing
         if value == False:
             self.writeAndLog(':INIT:CONT ON;')
         pass
     else:
         # run standard VISA case
         value = VISA_Driver.performSetValue(self, quant, value, sweepRate,
                                             options)
     return value
    def performSetValue(self, quant, value, sweepRate=0.0, options={}):
        """Perform the Set Value instrument operation. This function should
        return the actual value set by the instrument"""
        # update visa commands for triggers
        if quant.name in ('S11 - Enabled', 'S21 - Enabled', 'S12 - Enabled',
                          'S22 - Enabled'):
            self.getActiveMeasurements()
            param = quant.name[:3]
            # old-type handling of traces
            if param in self.dMeasParam:
                # clear old measurements for this parameter
                for name in self.dMeasParam[param]:
                    self.writeAndLog("CALC:PAR:DEL '%s'" % name)
            # create new measurement, if enabled is true
            if value:
                newName = 'LabC_%s' % param
                self.writeAndLog("CALC:PAR:EXT '%s','%s'" % (newName, param))
                # show on PNA screen
                iTrace = 1 + ['S11', 'S21', 'S12', 'S22'].index(param)
#                sPrev = self.askAndLog('DISP:WIND:CAT?')
#                if sPrev.find('EMPTY')>0:
#                    # no previous traces
#                    iTrace = 1
#                else:
#                    # previous traces, add new
#                    lTrace = sPrev[1:-1].split(',')
#                    iTrace = int(lTrace[-1]) + 1
                self.writeAndLog("DISP:WIND:TRAC%d:FEED '%s'" % (iTrace, newName))
                # add to dict with list of measurements
                self.dMeasParam[param] = [newName]
        elif quant.name in ('Wait for new trace',):
            # do nothing
            pass
        else:
            # run standard VISA case
            value = VISA_Driver.performSetValue(self, quant, value, sweepRate, options)
        return value
Example #48
0
 def performSetValue(self, quant, value, sweepRate=0.0, options={}):
     """Perform the set value operation"""
     # check type of quantity
     value = VISA_Driver.performSetValue(self, quant, value, sweepRate, options)
     return value
Example #49
0
 def performSetValue(self, quant, value, sweepRate=0.0, options={}):
     self.clearMessages()
     self.log('performSetValue of: '+quant.name+' with value: '+str(value))
     """Perform the Set Value instrument operation. This function should
     return the actual value set by the instrument"""
     # check quantity
     if quant.name == 'Magnetic Field' or quant.name == 'Current':
         self.log('In Magnetic Field or Current: '+quant.name)
         if quant.name == 'Magnetic Field':
             self.log('In Magnetic Field')
             perCmd = 'R18'
             sourCmd = 'R7'
             targetCmd = '$J'
             sweepRCmd = '$T'
             ###hOffSweepRate can be increased once
             ### it is shown heater status is reliable
             hOffSweepRate = 0.05 #50mT/minute
             maxSweep = 0.05 #50 mT/minute
         elif quant.name ==  'Current':
             self.log('In Current')
             perCmd = 'R16'
             sourCmd = 'R0'
             targetCmd = '$I'
             sweepRCmd = '$S'
             ###hOffSweepRate value can be increased once
             ### it is shown heater status is reliable
             hOffSweepRate = 2.29 #2.29A/minute
             maxSweep = 0.05 #50 mA/minute
         #1) Check field against persistent field
         #   Check heater status
         perVal = float(self.askAndLog(perCmd)[1:])
         self.wait(delayTime)
         sourVal = float(self.askAndLog(sourCmd)[1:])
         self.wait(delayTime)
         hStatus = self.readValueFromOther('Heater status')
         if perVal == value and not(hStatus):
             self.log('perVal == value, so returning')
             #Already at value, do nothing
             return value
         elif sourVal == value and hStatus:
             self.log('perVal == value, so returning')
             #Already at value, do nothing
             return value
         elif sourVal != perVal and not(hStatus):
             """If there is a difference between source and persistent field/current
                 Set source value to persistent value before turning heater on"""
             self.log('sour != perVal and hStatus == False, adjusting source level')
             self.writeAndLog(targetCmd+str(perVal))
             self.wait(delayTime)
             self.writeAndLog(sweepRCmd+str(hOffSweepRate))
             self.wait(delayTime)
             self.writeAndLog('$A1')
             self.wait(delayTime)
         if not hStatus:
             self.log('sour/per levels good, but heater off')
             #If heater is off, turn it on
             hStatus = self.heaterOn()
         if hStatus: 
             self.log('heater is on, setting targets and sweeping')
             #heater is on
             #4) Change set point
             self.writeAndLog(targetCmd+str(value))
             self.wait(delayTime)
             #5) Change sweep rate
             if sweepRate == 0 or sweepRate > maxSweep:
                 sweepRate = maxSweep
             self.writeAndLog(sweepRCmd+str(sweepRate))
             self.wait(delayTime)
             #6) Go to set point
             self.writeAndLog('$A1')
             self.wait(delayTime)
             #7) Wait for sweep
             valueDiff = value - perVal
             sweepTime = 60.0*abs(valueDiff)/(sweepRate)
             self.wait(delayTime)
             self.waitForSweep(quant,options,sweepTime)
             value = self.readValueFromOther(quant.name,options)
             self.heaterOff()
             return value
         else:
             return perVal
     elif quant.name == 'Current or Field':
         self.wait(delayTime)
         if value == 'Magnetic Field':
             self.writeAndLog('$M9')
             self.wait(delayTime)
         elif value == 'Current':
             self.writeAndLog('$M8')
             self.wait(delayTime)
     else:
         # run standard VISA case 
         value = VISA_Driver.performSetValue(self, quant, value, sweepRate, options)
     return value
Example #50
0
 def performSetValue(self, quant, value, sweepRate=0.0, options={}):
     """Perform the Set Value instrument operation. This function should
     return the actual value set by the instrument"""
     if quant.name == 'Function':
         # if set function, first read old function (voltage or current)
         sAll = self.askAndLog('H1 OD')
         # check for errors and raise exception if necesary
         self.queryErrors()
         # check result, should be voltage or current, convert to option string
         if sAll[3] == 'V':
             sOldValue = '1'
         elif sAll[3] == 'A':
             sOldValue = '5'
         else:
             raise InstrumentDriver.InstrumentConfig.OptionError(sAll[3], ['V', 'A'])
         # convert given value to command string
         sValue = quant.getCmdStringFromValue(value)
         # if old and new command strings are different, set new, otherwise do nothing
         if sOldValue != sValue:
             newFunc = VISA_Driver.performSetValue(self, quant, value, sweepRate,
                                                   options=options)
             # set value to zero, since we changed function
             if sValue == '1':
                 self.sendValueToOther('Voltage', 0.0)
             elif sValue == '5':
                 self.sendValueToOther('Current', 0.0)
             # also get new range by re-reading the func value
             newFunc = self.readValueFromOther('Function')
             return newFunc
         else:
             return value
     # check if set value and in sweep mode
     elif quant.name in ('Voltage', 'Current'):
         # check limits
         (dStep, dMax) = self.getMaxValueAndSmallestStep()
         if abs(value) > dMax:
             # new value out of range, return error
             raise InstrumentDriver.InstrStateError( \
                   InstrumentDriver.InstrStateError.SET, self.sName, sQuant=quant.name,
                   message = 'New value (%.6g) is out of range (max = %.6g)' % (value, dMax))
         # calculate actual value based on smallest step size
         value = dStep * np.round(value/dStep)
         # check if sweep mode, if not call generic driver
         if sweepRate == 0.0:
             return VISA_Driver.performSetValue(self, quant, value, 0.0, options=options)
         # sweep mode, do it here
         sCmd = 'M1 PI<st> SW<st> PRS S<*> PRE RU2'
         # get old value to find sweep time and step size
         currValue = self.performGetValue(quant)
         if value == currValue:
             # already at the final value, return
             return value
         # if sweep range is less than two minimal steps, don't sweep
         if abs(value-currValue) < 2.5*dStep:
             return VISA_Driver.performSetValue(self, quant, value, 0.0, options=options)
         dSweepTime = abs(value-currValue)/sweepRate
         # don't allow sweep times that are shorter than 0.1 s
         dSweepTime = max(dSweepTime, 0.1)
         sSweepTime = '%.1f' % dSweepTime
         # replace with sweep time string
         sCmd = sCmd.replace('<st>', sSweepTime)
         # check if value is to be included in the middle of the command
         sValue = quant.getCmdStringFromValue(value)
         sMsg = sCmd.replace('<*>', sValue)
         # start sweep
         self.writeAndLog(sMsg)
         # return target value
         return value
     else:
         # for all other quantities, call the generic VISA driver
         return VISA_Driver.performSetValue(self, quant, value, sweepRate,
                                            options=options)
 def performSetValue(self, quant, value, sweepRate=0.0, options={}):
     self.log("performSetValue called: " + quant.name + " value: " + str(value))
     if quant.name == "Voltage Mode":
         if value == "Fixed":
             VISA_Driver.writeAndLog(self, "SOUR:VOLT:MODE FIX")
         elif value == "Ramp":
             # General settings for ramp function
             # Rtime, start:level, end:level are set when actually sweeping
             cmd = []
             cmd.append("SOUR:VOLT:MODE ARB")
             cmd.append("SOUR:ARB:FUNC:SHAP RAMP")
             cmd.append("SOUR:ARB:COUN 1")
             cmd.append("SOUR:ARB:VOLT:RAMP:END:TIME 0")
             cmd.append("SOUR:ARB:VOLT:RAMP:STAR:TIME 0")
             sCmd = cmd.join("; :")
             VISA_Driver.writeAndLog(self, sCmd)
     elif quant.name.endswith("Amplitude"):
         # Voltage Amplitude
         # Current Amplitude
         if quant.name.startswith("Voltage"):
             cmd = "SOUR:VOLT"
             maxOutpDiff = 0.005  # Never change by more than 5mV
         else:
             cmd = "SOUR:CURR"
             maxOutpDiff = 0.001  # Never change by more than 1 mA
         initValue = VISA_Driver.askAndLog(self, cmd + "?")
         outpDiff = value - float(initValue)
         if outpDiff == 0:
             # Don't send if already at right value
             return value
         elif outpDiff > maxOutpDiff:
             # If program is trying to move to a value too far away instantly,
             #  then override by changing value
             value = initValue + maxOutpDiff
         elif outpDiff < -maxOutpDiff:
             value = initValue - maxOutpDiff
         # Enter the (modified or unmodified) value
         VISA_Driver.writeAndLog(self, cmd + " " + str(value))
         return value
     elif quant.name.endswith(" Ramp"):
         if quant.name.startswith("Voltage"):
             cmd = "SOUR:VOLT"
             cmd2 = "SOUR:ARB:VOLT:RAMP"
             maxSweepRate = 0.005  # Never sweep faster than 5mV/sec
         elif quant.name.startswith("Current"):
             cmd = "SOUR:CURR"
             cmd2 = "SOUR:ARB:CURR:RAMP"
             maxSweepRate = 0.001  # Never sweep faster than 1mA/sec
         self.log("getting init value for ramp")
         initValue = float(VISA_Driver.askAndLog(self, cmd + "?"))
         outpDiff = value - initValue
         if sweepRate == 0 or sweepRate > maxSweepRate:
             sweepRate = maxSweepRate
         rTime = abs(outpDiff) / sweepRate
         cmd = []
         cmd.append(cmd2 + ":END:LEV " + str(value))
         cmd.append(cmd2 + ":RTIM " + str(rTime))
         cmd.append(cmd2 + ":STAR:LEV " + str(initValue))
         cmd.append("TRIG")  # Sends an immediate trigger for both source and measure actions
         sCmd = "; :".join(cmd)
         VISA_Driver.writeAndLog(self, sCmd)
     elif quant.name.startswith("Measure "):
         # Enable appropriate functions, if something has been updated
         if self.isConfigUpdated():
             # Determine which variables are being measured
             quantDict = {
                 "Measure Current": ["CURR", False],
                 "Measure Voltage": ["VOLT", False],
                 "Measure Resistance": ["RES", False],
             }
             for key, list in quantDict.items():
                 list[1] = self.getValue(key)
                 if list[1]:
                     VISA_Driver.writeAndLog(self, "FUNC:ON " + list[0])
                 else:
                     VISA_Driver.writeAndLog(self, "FUNC:OFF " + list[0])
         return value
     elif quant.name == "Measurement Speed Method":
         # No commands sent to device for this quantity
         return value
     else:
         return VISA_Driver.performSetValue(self, quant, value, options=options, sweepRate=sweepRate)
 def performSetValue(self, quant, value, sweepRate=0.0, options={}):
     self.log('performSetValue called: '+quant.name+' value: '+str(value))
     if quant.name == 'Source on_off':
         if value == 'On':
             VISA_Driver.writeAndLog(self,'OUTP:STAT 1')
             return 'On'
         else:
             #Sweep source to zero before turning off, to avoid sudden jumps
             func = self.getValue('Source function')
             if func == 'Voltage':
                 self.sendValueToOther('Voltage Amplitude',0)
                 while self.sendValueToOther('Voltage Amplitude',0) != 0:
                     self.wait(0.1)
             elif func == 'Current':
                 self.sendValueToOther('Current Amplitude',0)
                 while self.sendValueToOther('Voltage Amplitude',0) != 0:
                     self.wait(0.1)
             VISA_Driver.writeAndLog(self,'OUTP:STAT 0')
             return 'Off'
     elif quant.name.endswith('Amplitude'):
         #Voltage Amplitude
         #Current Amplitude
         if quant.name.startswith('Voltage'):
             cmd = 'SOUR:VOLT'
             maxOutpDiff = 0.0005 #5mV/s
             #Program sets source every 0.1 seconds, so sweepRate = outpDiff/0.1 = 10*outpDiff
             #Note minimum output change is 5uV.
         else:
             cmd = 'SOUR:CURR'
             maxOutpDiff = 0.0001
         initValue = float(VISA_Driver.askAndLog(self,cmd+'?'))
         outpDiff = value-initValue
         if outpDiff == 0:
             #Don't send if already at right value
             return value
         elif outpDiff > maxOutpDiff:
             #If program is trying to move to a value too far away instantly,
             #  then override by changing value
                 value = initValue+maxOutpDiff
         elif outpDiff < -maxOutpDiff:
                 value = initValue-maxOutpDiff
         #Enter the (modified or unmodified) value
         VISA_Driver.writeAndLog(self,cmd+' '+str(value))
         return value
     elif quant.name.startswith('Measure '):
         #Determine which variables are being measured
         quantDict = {'Measure Current':['CURR',False], \
                      'Measure Voltage':['VOLT',False], \
                      'Measure Resistance':['RES',False]}
         for key,list in quantDict.items():
             list[1] = self.getValue(key)
         
         #If only one, turn off concurrency
         if sum(list[1] for list in quantDict.values()) == 1:
             VISA_Driver.writeAndLog(self,'FUNC:CONC 0')
         else:
             VISA_Driver.writeAndLog(self,'FUNC:CONC 1')
         
         #Enable appropriate functions
         for key,list in quantDict.items():
             if list[1]:
                 VISA_Driver.writeAndLog(self,'FUNC:ON '+'"'+list[0]+'"')
             else:
                 VISA_Driver.writeAndLog(self,'FUNC:OFF '+'"'+list[0]+'"')
         return value
     elif quant.name.endswith('Range Mode'):
         #convert auto/manual to auto on, auto off
         comboDict = {'Manual':'0','Automatic':'1'}
         value = comboDict[value]
         #Check source mode
         func = self.getValue('Source function')
         if quant.name.startswith('Voltage'):
             if func == 'Voltage':
                 #If quant matches source mode, set source range
                 VISA_Driver.writeAndLog(self,'SOUR:VOLT:RANG:AUTO '+value)
             else:
                 #Otherwise, set measurement range
                 VISA_Driver.writeAndLog(self,'SENS:VOLT:RANG:AUTO '+value)
         elif quant.name.startswith('Current'):
             if func == 'Current':
                 VISA_Driver.writeAndLog(self,'SOUR:CURR:RANG:AUTO '+value)
             else:
                 VISA_Driver.writeAndLog(self,'SENS:CURR:RANG:AUTO '+value)
         elif quant.name.startswith('Resistance'):
             #If using manual resistance mode, do nothing
             if self.getValue('Resistance Measurement Mode') == 'Automatic':   
                 VISA_Driver.writeAndLog(self,'SENS:RES:RANG:AUTO '+value)
         return int(value)
     elif quant.name == 'Voltage Manual Range' or quant.name == 'Current Manual Range' :
         #Check source mode
         func = self.getValue('Source function')
         if quant.name.startswith('Voltage'):
             if func == 'Voltage':
                 #If quant matches source mode, set source range
                 VISA_Driver.writeAndLog(self,'SOUR:VOLT:RANG '+str(value))
             else:
                 #Otherwise, set compliance rainge and measurement range
                 VISA_Driver.writeAndLog(self,'SENS:VOLT:PROT '+str(value*1.1))
                 VISA_Driver.writeAndLog(self,'SENS:VOLT:RANG '+str(value))
         elif quant.name.startswith('Current'):
             if func == 'Current':
                 VISA_Driver.writeAndLog(self,'SOUR:CURR:RANG '+str(value))
             else:
                 VISA_Driver.writeAndLog(self,'SENS:CURR:PROT '+str(value*1.05))
                 VISA_Driver.writeAndLog(self,'SENS:CURR:RANG '+str(value))
         return value
     elif quant.name == 'Averaging Time':
         self.log('Averaging called')
         NPLC = self.getValue('NPLC')
         self.log('NPLC: '+str(NPLC))
         repeat = self.getValue('Repeat Filter')
         self.log('repeat: '+str(repeat))
         medRank = self.getValue('Median Filter')
         self.log('medRank: '+str(medRank))
         avCount = self.getValue('Moving Filter')
         self.log('avCount: '+str(avCount))
         timeBase = 1.0/50.0
         avTime = NPLC*timeBase*repeat*(2*medRank+1)*avCount
         self.setValue('Averaging Time',str(avTime))
         return avTime
     else:
         return VISA_Driver.performSetValue(self,quant,value,options=options,sweepRate=sweepRate)
    def performSetValue(self, quant, value, sweepRate=0.0, options={}):
        couplingModes = ['Coupling CFRQAB','Coupling CFRQAC','Coupling RFLVAB','Coupling RFLVAC']
        self.log('Quant.name is: '+quant.name+' Set value')
        if quant.name[-1] == ')':
            #Add source selection string to beginning of every
            #source specific command (ensure setting affects right source)
            source = quant.name[-2]
            sourceCmd = 'SOURCE '+source+'; :'
        if quant.name == 'Combiner Mode':
            VISA_Driver.writeAndLog(self,'CMODE '+value)
            return value
        elif quant.name == couplingModes[0]:
            """
            This function sets all coupling modes at once, so it should
            only be called once per set_config action.

            Note: COUPLING:MODE CFRQAB (for example) makes CFRQAB the only mode
            I.e. modes can't be added one by one
            """
            modeCmds = []
            for cMode in couplingModes:
                if self.getValue(cMode) == True:
                    self.log('Adding: '+cMode)
                    modeCmds.append(cMode.split(' ')[1])
            if len(modeCmds) == 0:
                cmdStr = 'COUPLING:MODE DISABLED'
            else:
                cmdStr = 'COUPLING:MODE '+','.join(modeCmds)
            VISA_Driver.writeAndLog(self,cmdStr)
        elif quant.name in couplingModes:
            pass
        elif quant.name.startswith('Coupling'):
            cmd = quant.name.split(' ')
            """
            cmd[0] = 'Coupling'
            cmd[1] = one of the coupling modes
            cmd[2] = MODE, HARM, SUBHARM, OFFSET
            """
            if cmd[2] == 'MODE':
                comboDict = {'Harmonic':'HARM','Sub-harmonic':'SUBHARM'}
                VISA_Driver.writeAndLog(self,'COUPLING:'+cmd[1]+':'+cmd[2]+' '+comboDict[value])
            else:
                VISA_Driver.writeAndLog(self,'COUPLING:'+cmd[1]+':'+cmd[2]+' '+str(value))
        elif quant.name.startswith('Carrier Frequency'):
            initValue = self.readValueFromOther(quant.name,options)
            initValue = float(initValue)
            if value == initValue:
                return initValue
            elif sweepRate != 0:
                """
                Sweeping is done by continuously setting frequency
                Minimum time between steps is 50msec
                """
                valueDiff = value - initValue
                time = abs(valueDiff)/sweepRate
                increment = 0.05*sweepRate
                #Sweep to point
                cmd = 'SWEEP:'+sourceCmd
                cmd += 'SWEEP:TRIG STARTSTOP; '
                cmd += 'SWEEP:CFRQ:START '+str(initValue)+'; '
                cmd +='STOP '+str(value)+'; '
                cmd += 'TIME 0.05S; '
                cmd += 'INC '+str(increment)+'; '
                cmd += ':SWEEP:GO'
                VISA_Driver.writeAndLog(self,cmd)
            else:
                VISA_Driver.writeAndLog(self,sourceCmd+'CFRQ:VALUE '+str(value)+'HZ')
        elif quant.name.startswith('Carrier Phase offset'):
            VISA_Driver.writeAndLog(self,sourceCmd+'CFRQ:PHASE '+str(value)+'DEG')
        elif quant.name.startswith('RF Output On'):
            if value:
                VISA_Driver.writeAndLog(self,sourceCmd+'RFLV:ON')
            else:
                VISA_Driver.writeAndLog(self,sourceCmd+'RFLV:OFF')
        elif quant.name.startswith('RF Level'):
            VISA_Driver.writeAndLog(self,sourceCmd+'RFLV:VALUE '+str(value)+'DBM')
        elif quant.name.startswith('RF Type'):
            VISA_Driver.writeAndLog(self,sourceCmd+'RFLV:TYPE '+str(value))
        elif quant.name.startswith('Modulation Control'):
            if value:
                VISA_Driver.writeAndLog(self,sourceCmd+'MOD:ON')
            else:
                VISA_Driver.writeAndLog(self,sourceCmd+'MOD:OFF')
        elif quant.name.startswith('Modulation mode'):
            modeList = []
            pulse = self.getValue('Pulse Modulation ('+source+')')
            if 'AM' in value:
                modeList.append('AM')
            if 'FM' in value:
                modeList.append('FM')
            if 'PM' in value:
                modeList.append('PM')
            if 'FSK2L' in value:
                modeList.append('FSK2L')
            if 'FSK4L' in value:
                modeList.append('FSK4L')
            if pulse:
                modeList.append('PULSE')
            VISA_Driver.writeAndLog(self,'MODE '+','.join(modeList))
        elif quant.name.startswith('Frequency Modulation Type'):
            if value:
                VISA_Driver.writeAndLog(self,sourceCmd+'FM:OFF; :FM1:ON; :FM2:ON')
            else:
                VISA_Driver.writeAndLog(self,sourceCmd+'FM:ON; :FM1:OFF; :FM2:OFF')
        elif quant.name.startswith('Phase Modulation Type'):
            if value:
                VISA_Driver.writeAndLog(self,sourceCmd+'PM:OFF; :PM1:ON; :PM2:ON')
            else:
                VISA_Driver.writeAndLog(self,sourceCmd+'PM:ON; :PM1:OFF; :PM2:OFF')
        elif quant.name.startswith('Pulse Modulation'):
            if value:
                VISA_Driver.writeAndLog(self,'PULSE:ON')
            else:
                VISA_Driver.writeAndLog(self,'PULSE:OFF')
        elif quant.name[:2] in ['FM','PM','AM']:
            cmd = quant.name.split(' ')
            """
            cmd[0] = FM1, FM2, PM1, PM2, AM1, or AM2
            cmd[1] = Deviation, Source, Modulation, Waveform, Phase, (Depth for AM), Status
            """
            if cmd[1] == 'Status':
                if value:
                    VISA_Driver.writeAndLog(self,sourceCmd+cmd[0]+':ON')
                else:
                    VISA_Driver.writeAndLog(self,sourceCmd+cmd[0]+':OFF')
            elif cmd[1] == 'Deviation':
                VISA_Driver.writeAndLog(self,sourceCmd+cmd[0]+':DEVN '+str(value))
            elif cmd[1] == 'Source':
                comboDict = {'Internal':'INT','External AC':'EXTAC','External ALC':'EXTALC','External DC':'EXTDC'}
                VISA_Driver.writeAndLog(self,sourceCmd+cmd[0]+':'+comboDict[value])
            elif cmd[1] == 'Modulation':
                VISA_Driver.writeAndLog(self,sourceCmd+cmd[0]+':MODF:VALUE '+str(value)+'HZ')
            elif cmd[1] == 'Waveform':
                VISA_Driver.writeAndLog(self,sourceCmd+cmd[0]+':MODF:'+str(value))
            elif cmd[1] == 'Phase':
                VISA_Driver.writeAndLog(self,sourceCmd+cmd[0]+':MODF:PHASE '+str(value)+'DEG')
            elif cmd[1] == 'Depth':
                VISA_Driver.writeAndLog(self,sourceCmd+cmd[0]+':DEPTH '+str(value)+'PCT')
            else:
                self.log('Unknown command received: '+cmd[1])
        elif quant.name.startswith('DC FM'):
            VISA_Driver.writeAndLog(self,sourceCmd+'DCFMNL')
        elif quant.name.endswith('Connected'):
            return value
        else:
            self.log('No quant name triggered')
            return VISA_Driver.performSetValue(self,quant,value,options,sweepRate)
        return value
Example #54
0
 def performSetValue(self, quant, value, sweepRate=0.001, options={}):
     if quant.name == 'Output':
         if value:
             VISA_Driver.writeAndLog(self,'OUTP:STAT ON')
             return True
         else:
             #Sweep source to zero before turning off, to avoid sudden jumps
             func = self.getValue('Function')
             if func == 'Voltage':
                 self.sendValueToOther('Source Voltage Level',0)
                 while self.checkIfSweeping('Source Voltage Level',options):
                     self.wait(0.05)
             elif func == 'Current':
                 self.sendValueToOther('Source Current Level',0)
                 while self.checkIfSweeping('Source Current Level',options):
                     self.wait(0.05)
             VISA_Driver.writeAndLog(self,'OUTP:STAT OFF')
             return False
     elif quant.name == 'Function':
         if value == 'Voltage':
             VISA_Driver.writeAndLog(self,'SOUR:FUNC VOLT')
             return 'Voltage'
         elif value == 'Current':
             VISA_Driver.writeAndLog(self,'SOUR:FUNC CURR')
             return 'Current'
     elif quant.name == 'Source Current Range' or quant.name == 'Source Voltage Range':
         VISA_Driver.writeAndLog(self,'SOUR:RANG '+str(value))
         return value
     elif quant.name == 'Source Voltage Level' or quant.name == 'Source Current Level':
         self.log(quant.name+' value passed: '+str(value))
         self.log('Sweep rate: '+str(sweepRate))
         #Check current source level
         initValue = float(self.askAndLog('SOUR:LEV?'))
         if value == initValue:
             #if no change, do nothing
             return float(value)
         else:
             #It seems sometimes sweepRate is not passed to this function (e.g. when setting config)
             # Ensure that this never causes a jump in source levels
             if quant.name == 'Source Voltage Level':
                 maxSweepRate = 0.03 #30mV/sec or 1.8V/min
             else:
                 maxSweepRate = 0.03 #30mA/sec or 1.8A/min
             if sweepRate == 0 or sweepRate > maxSweepRate:
                 sweepRate = maxSweepRate
             difference = abs(value - initValue)
             duration = difference/abs(sweepRate)
             #Note minimum duration is 0.1s
             duration = max(duration,0.1)
             cmd1 = 'PROG:REP 0; '               #Program doesn't repeat
             cmd2 = 'SLOP '+str(duration)+'; '   #Source takes this long to move between values
             cmd3 = 'INT '+str(duration)+'; '    #This much time between program steps
             cmd4 = 'EDIT:STAR; '                #Add points to program
             cmd5 = ':SOUR:LEV '+str(value)+'; ' #Add target point
             cmd6 = ':PROG:EDIT:END; '           #Stop adding points to program
             cmd7 = ':PROG:RUN'                  #Run program
             sCmd = cmd1+cmd2+cmd3+cmd4+cmd5+cmd6+cmd7
             VISA_Driver.writeAndLog(self,sCmd)  #Combine all the above into one string, then send it
             return float(value)
     else:
         self.log('No other quant names triggered: '+quant.name)
         return VISA_Driver.performSetValue(self,quant,value,options,sweepRate)
    def performSetValue(self, quant, value, sweepRate=0.0, options={}):
        """Perform the Set Value instrument operation. This function should
        return the actual value set by the instrument"""
        try:
            if quant.name == "Frequency":
                self.writeAndLog("F1 %0.6f Hz" % value)
                self.dFreq = value
                return value
            elif quant.name == "Power":
                self.writeAndLog("L1 %0.2f DMCLOCF1" % value)
                self.dPower = value
                return value
            elif quant.name == "Output":
                self.bOutput = value
                if value:
                    self.writeAndLog("RF 1")
                else:
                    self.writeAndLog("RF 0")
                return value
            elif quant.name == "Phase Offset":
                self.writeAndLog("PS1 PSO %0.1f DG" % value)
                self.dPhaseOffset = value
                return value
            elif quant.name == "Amplitude Modulation":
                self.bAmplitudeModulation = value
                if value:
                    self.writeAndLog("AM 1")
                else:
                    self.writeAndLog("AM 0")
                return value
            elif quant.name == "Internal Pulse Modulation":
                self.bInternalPulseModulation = value
                if value:
                    self.writeAndLog("IP")
                    # Set the Internal Pulse Modulation to default values
                    # self.writeAndLog("PER %0.3f S W1 %0.3f S D1 %0.3f S" % self.dInternalPulsePeriod,self.dInternalPulseWidth, self.dInternalPulseDelay)
                else:
                    self.writeAndLog("P0")
                return value
            elif quant.name == "Internal Pulse Modulation Mode":
                # combo, get index
                if isinstance(value, (str, unicode)):
                    valueIndex = quant.combo_defs.index(value)
                else:
                    valueIndex = int(value)
                self.nInternalPulseModulationMode = valueIndex
            elif quant.name == "Internal Pulse Period":
                self.writeAndLog("PER %0.3f US" % value)
                self.dInternalPulsePeriod = value
                return value
            elif quant.name == "Internal Pulse Width":
                self.writeAndLog("W1 %0.3f US" % value)
                self.dInternalPulseWidth = value
                return value
            elif quant.name == "Internal Pulse Delay":
                self.writeAndLog("D1 %0.3f US" % value)
                self.dInternalPulseDelay = value
                return value
            elif quant.name == "Trigger Mode":
                # combo, get index
                if isinstance(value, (str, unicode)):
                    valueIndex = quant.combo_defs.index(value)
                else:
                    valueIndex = int(value)
                self.nTriggerMode = valueIndex
            elif quant.name == "Positive or Negative Trigger Edge":
                # combo, get index
                if isinstance(value, (str, unicode)):
                    valueIndex = quant.combo_defs.index(value)
                else:
                    valueIndex = int(value)
                self.nPosOrNegEdge = valueIndex
            elif quant.name == "Amplitude Modulation Mode":
                # combo, get index
                if isinstance(value, (str, unicode)):
                    valueIndex = quant.combo_defs.index(value)
                else:
                    valueIndex = int(value)
                self.nAmplitudeModulationMode = valueIndex
            else:
                # for all other quantities, call the generic VISA driver
                return VISA_Driver.performSetValue(self, quant, value, sweepRate, options=options)

        except Error as e:
            # re-cast errors as a generic communication error
            msg = str(e)
            raise InstrumentDriver.CommunicationError(msg)