def performOpen(self, options={}): """Perform the operation of opening the instrument connection""" # open visa communication VISA_Driver.performOpen(self, options) # set additional flags self.com.set_visa_attribute(VI_ATTR_WR_BUF_OPER_MODE, VI_FLUSH_ON_ACCESS) self.com.set_visa_attribute(VI_ATTR_RD_BUF_OPER_MODE, VI_FLUSH_ON_ACCESS) read_buff_size_bytes = 4096 write_buff_size_bytes = 4096 self.com.visalib.set_buffer(self.com.session, VI_READ_BUF, read_buff_size_bytes) self.com.__dict__['read_buff_size'] = read_buff_size_bytes self.com.visalib.set_buffer(self.com.session, VI_WRITE_BUF, write_buff_size_bytes) self.com.__dict__['write_buff_size'] = write_buff_size_bytes # timeout self.timeout_ms = int(1000 * self.dComCfg['Timeout']) self.nCh = 2 self.lWaveUpdated = [False] * self.nCh # clear all waveforms self.writeAndLog(':TRAC:DEL:ALL')
def performOpen(self, options={}): """Perform the operation of opening the instrument connection""" # calling the generic VISA open to make sure we have a connection VISA_Driver.performOpen(self, options=options) degChannels = [] self.unitFactors = [0. for i in range(8)] for i in range(1, 9): #Check if channel can be used (left and right limit tripped indicates failure or missing device) if int(self.askAndLog(str(i) + "MS").strip()[3].encode("hex"), 16) & 0x18 == 0x18: continue #Check the units unit = self.askAndLog(str(i) + "SN?").strip()[3:] self.unitFactors[i] = 1. if unit == "Dg.": degChannels.append("ch" + str(i) + "deg") elif unit == "mm": degChannels.append("ch" + str(i) + "mm") self.unitFactors[i] = .001 else: degChannels.append("ch" + str(i) + "unknown") #Set maximum velocity vmax = self.askAndLog(str(i) + "VU?")[3:] self.writeAndLog(str(i) + "VA" + vmax) self.instrCfg.setInstalledOptions(degChannels)
def performOpen(self, options={}): """Perform the operation of opening the instrument connection""" # calling the generic VISA open to make sure we have a connection VISA_Driver.performOpen(self, options=options) degChannels = [] self.unitFactors = [0. for i in range(8)] for i in range(1,9): #Check if channel can be used (left and right limit tripped indicates failure or missing device) if int(self.askAndLog(str(i)+"MS").strip()[3].encode("hex"), 16) & 0x18 == 0x18: continue #Check the units unit = self.askAndLog(str(i)+"SN?").strip()[3:] self.unitFactors[i] = 1. if unit == "Dg.": degChannels.append("ch"+str(i)+"deg") elif unit == "mm": degChannels.append("ch"+str(i)+"mm") self.unitFactors[i] = .001; else: degChannels.append("ch"+str(i)+"unknown") #Set maximum velocity vmax = self.askAndLog(str(i)+"VU?")[3:] self.writeAndLog(str(i)+"VA"+vmax) self.instrCfg.setInstalledOptions(degChannels)
def performOpen(self, options={}): VISA_Driver.performOpen(self, options) #Set the format for the output VISA_Driver.writeAndLog(self, 'FORM:ELEM VOLT,CURR,RES') #Put source modes to fixed (rather than sweep) VISA_Driver.writeAndLog(self, 'SOUR:CURR:MODE FIX; :SOUR:VOLT:MODE FIX')
def performOpen(self, options={}): """Perform the operation of opening the instrument connection""" # calling the generic VISA open to make sure we have a connection VISA_Driver.performOpen(self, options=options) # do additional initialization code here... #Hacky way to make sure the input buffer is flushed out try: self.reportProgress(1 / 8) _ = self.read(1024) except: pass #Flush everything (hopefully) self.writeAndLog('*CLS') self.writeAndLog('FLOQ') #Step through each channel and query ID #Build up a dict of IDN/Channel pairs self.ports_dict = {} for ix in range(8): channel = ix + 1 idn = self.sim900_module_ask(channel, '*IDN?', timeout=0.5, bCheckError=False) if idn not in ['None', 'Timed Out']: module_code = idn.split(',')[1] self.ports_dict[module_code] = channel else: module_code = idn self.setValue('Slot %d' % channel, module_code) self.reportProgress(channel / 8)
def performOpen(self, options={}): """Perform the operation of opening the instrument connection""" # start by calling the generic VISA open to make sure we have a connection VISA_Driver.performOpen(self, options) # check for strange bug by reading the status bit try: status = self.askAndLog('*STB?', bCheckError=False) status = int(status) except: # if conversion to int failed, re-read instrument buffer to clear sBuffer = self.read() self.log('Extra data read from Tek: %s, %s' % (str(status), sBuffer)) # get model name and number of channels sModel = self.getModel() self.nCh = 4 if sModel in ('5004', '5014') else 2 # turn off run mode self.writeAndLog(':AWGC:STOP;') # init vectors with old values self.bWaveUpdated = False self.nOldSeq = -1 self.lOldU16 = [[np.array([], dtype=np.uint16) \ for n1 in range(self.nCh)] for n2 in range(1)] # clear old waveforms self.lInUse = [False]*self.nCh for n in range(self.nCh): self.createWaveformOnTek(n+1, 0, bOnlyClear=True)
def performOpen(self, options={}): """Perform the operation of opening the instrument connection""" # add compatibility with pre-python 3 version of Labber if not hasattr(self, 'write_raw'): self.write_raw = self.write # add compatibility with pre-1.5.4 version of Labber if not hasattr(self, 'getTrigChannel'): self.getTrigChannel = self._getTrigChannel # start by calling the generic VISA open to make sure we have a connection VISA_Driver.performOpen(self, options) # check for strange bug by reading the status bit try: status = self.askAndLog('*STB?', bCheckError=False) status = int(status) except: # if conversion to int failed, re-read instrument buffer to clear sBuffer = self.read() self.log('Extra data read from Tek: %s, %s' % (str(status), sBuffer)) # get model name and number of channels sModel = self.getModel() self.nCh = 4 if sModel in ('5004', '5014') else 2 # turn off run mode self.writeAndLog(':AWGC:STOP;') # init vectors with old values self.bWaveUpdated = False self.nOldSeq = -1 self.lOldU16 = [[np.array([], dtype=np.uint16) \ for n1 in range(self.nCh)] for n2 in range(1)] # clear old waveforms self.lInUse = [False] * self.nCh for n in range(self.nCh): self.createWaveformOnTek(n + 1, 0, bOnlyClear=True)
def performOpen(self, options={}): """Perform the operation of opening the instrument connection""" # calling the generic VISA open to make sure we have a connection VISA_Driver.performOpen(self, options=options) #Detect options: (vector) magnet and swicth heater detectedOptions = [] rate = self.askAndLog('READ:SYS:VRM:RFMX').strip().rsplit( ':', 1)[1][1:-1].translate(None, string.letters + "/").split() if float(rate[0]) > 0: detectedOptions.append("x magnet") if float(rate[1]) > 0: detectedOptions.append("y magnet") if float(rate[2]) > 0: detectedOptions.append("z magnet") heater = self.askAndLog('READ:SYS:VRM:SWHT').strip().rsplit( ':', 1)[1][1:-1].split() if heater[0] != "NOSW" or heater[1] != "NOSW" or heater[2] != "NOSW": detectedOptions.append("switch heater") self.instrCfg.setInstalledOptions(detectedOptions) # Make sure that the coordinate system matches the device coordFunc = self.instrCfg.getQuantity('CoordSys') v = self.performGetValue(coordFunc) coordFunc.setValue(v)
def performOpen(self, options={}): """Perform the operation of opening the instrument connection""" # calling the generic VISA open to make sure we have a connection VISA_Driver.performOpen(self, options=options) # fix issue with termination for read visa.vpp43.set_attribute(self.com.vi, visa.VI_ATTR_SUPPRESS_END_EN, visa.VI_FALSE) self.detectedOptions = self.getOptions()
def performOpen(self, options={}): """Perform the operation of opening the instrument connection""" # init meas param dict self.dMeasParam = {} self.cData=None # calling the generic VISA open to make sure we have a connection VISA_Driver.performOpen(self, options=options)
def performOpen(self, options={}): """Perform the operation of opening the instrument connection""" # calling the generic VISA open to make sure we have a connection VISA_Driver.performOpen(self, options=options) # fix issue with termination for read visa.vpp43.set_attribute(self.com.vi, visa.VI_ATTR_SUPPRESS_END_EN, visa.VI_FALSE) #Detect options: (vector) magnet and swicth heater detectedOptions = [] rate = self.askAndLog('READ:SYS:VRM:RFMX').strip().rsplit(':',1)[1][1:-1].translate(None,string.letters+"/").split() if float(rate[0]) > 0: detectedOptions.append("x magnet") if float(rate[1]) > 0: detectedOptions.append("y magnet") if float(rate[2]) > 0: detectedOptions.append("z magnet") heater = self.askAndLog('READ:SYS:VRM:SWHT').strip().rsplit(':',1)[1][1:-1].split() if heater[0] != "NOSW" or heater[1] != "NOSW" or heater[2] != "NOSW": detectedOptions.append("switch heater") self.instrCfg.setInstalledOptions(detectedOptions) # Make sure that the coordinate system matches the device coordFunc = self.instrCfg.getQuantity('CoordSys') v = self.performGetValue(coordFunc) coordFunc.setValue(v)
def performOpen(self, options={}): """Perform the operation of opening the instrument connection""" # add compatibility with pre-Python 3 version of Labber if not hasattr(self, 'write_raw'): self.write_raw = self.write # add compatibility with pre-1.5.4 version of Labber if not hasattr(self, 'getTrigChannel'): self.getTrigChannel = self._getTrigChannel # start by calling the generic VISA open to make sure we have # a connection VISA_Driver.performOpen(self, options) # check for a strange bug by reading the status bit try: status = self.askAndLog('*STB?', bCheckError=False) status = int(status) except: # if conversion to int failed, re-read instrument buffer to # clear sBuffer = self.read() self.log('Extra data read from Tektronix AWG: %s' % sBuffer) # get model name and number of channels sModel = self.getModel() self.nCh = 4 if sModel in ('5004', '5014') else 2 # turn off run mode self.bIsStopped = False self._stop() self.writeAndLog('WLIS:WAV:DEL ALL', bCheckError=False) self.writeAndLog('SLIS:SUBS:DEL ALL', bCheckError=False) self.bFastSeq = False self.bSubSeq = False self._clear_all() for n in range(self.nCh): self.createWaveformOnTek(n + 1, 0, bOnlyClear=True)
def performOpen(self, options={}): """Perform the operation of opening the instrument connection""" # start by calling the generic VISA open to make sure we have a connection VISA_Driver.performOpen(self, options=options) #Reads out the Arduino upon start reply = self.read() self.log('Response at startup: ' + reply)
def performOpen(self, options={}): """Perform the operation of opening the instrument connection""" # calling the generic VISA open to make sure we have a connection VISA_Driver.performOpen(self, options=options) # Check if there really is an IPS120 at the other end of the wire if not "IPS120" in self.askAndLog("V"): raise InstrumentDriver.CommunicationError("Could not get an identification as IPS120.") self.writeAndLog("Q4")
def performOpen(self, options={}): """Perform the operation of opening the instrument connection""" # keep track of sweep state self.is_sweeping = False # start by calling the generic VISA open to make sure we have a connection VISA_Driver.performOpen(self, options=options) # always get function and range: they are essential for correct resolution and sweeping self.readValueFromOther('Function')
def performOpen(self, options={}): """Perform the operation of opening the instrument connection""" # start by calling the generic VISA open to make sure we have a connection VISA_Driver.performOpen(self, options=options) self.bSweep1 = self.getValue('Channel 1 Autosweep') self.bSweep2 = self.getValue('Channel 2 Autosweep') self.bSweep3 = self.getValue('Channel 3 Autosweep') self.bSweep4 = self.getValue('Channel 4 Autosweep')
def performOpen(self, options={}): """Perform the operation of opening the instrument connection""" # calling the generic VISA open to make sure we have a connection VISA_Driver.performOpen(self, options=options) # Check if there really is an IPS120 at the other end of the wire if not "IPS120" in self.askAndLog("V"): raise InstrumentDriver.CommunicationError( "Could not get an identification as IPS120.") self.writeAndLog("Q4")
def performOpen(self, options={}): """Perform the operation of opening the instrument connection""" # add compatibility with pre-python 3 version of Labber if not hasattr(self, 'write_raw'): self.write_raw = self.write # start by calling the generic VISA open to make sure we have a connection VISA_Driver.performOpen(self, options) # clear value of waveform self.setValue('Arb. Waveform', [])
def performOpen(self, options={}): """Perform the operation of opening the instrument connection""" try: # start by calling the generic VISA open to make sure we have a connection VISA_Driver.performOpen(self, options=options) except Error as e: # re-cast errors as a generic communication error msg = str(e) raise BaseDriver.CommunicationError(msg)
def performOpen(self, options={}): """Perform the operation of opening the instrument connection""" # calling the generic VISA open to make sure we have a connection VISA_Driver.performOpen(self, options=options) # check if in DC mode for n in range(2): ch = n + 1 wfInfor = self.askAndLog(f'SOUR{ch}:APPL?') if wfInfor.strip('"').split(',')[0] != 'DC': self.writeAndLog(f':SOUR{ch}:APPL:DC 1,1,0')
def performOpen(self, options={}): """Perform the operation of opening the instrument connection""" # calling the generic VISA open to make sure we have a connection VISA_Driver.performOpen(self, options=options) #This device does not respond to *IDN?, so let's check manually id = self.askAndLog("ID") if not id in ("7260", "7265"): raise InstrumentDriver.CommunicationError( "ID query did not return 7260 or 7265. Is this the right driver for the device at the right address?" ) return
def performOpen(self, options={}): """Perform the operation of opening the instrument connection""" # start by calling the generic VISA open to make sure we have a connection VISA_Driver.performOpen(self, options=options) self.amplitude = 0 self.phase = 0 self.IOffset = 0 self.QOffset = 0 self.II = 1 self.IQ = 0 self.QI = 0 self.QQ = 1
def performOpen(self, options={}): """Perform the operation of opening the instrument connection""" # calling the generic VISA open to make sure we have a connection VISA_Driver.performOpen(self, options=options) # This device does not respond to *IDN?, so let's check manually id = self.askAndLog("ID") if not id in ("7260", "7265"): raise InstrumentDriver.CommunicationError( "ID query did not return 7260 or 7265. Is this the right driver for the device at the right address?" ) return
def performOpen(self, options={}): """Perform the operation of opening the instrument connection""" # add compatibility with pre-python 3 version of Labber if not hasattr(self, 'write_raw'): self.write_raw = self.write # Call the generic VISA open to make sure we have a connection VISA_Driver.performOpen(self, options) # clear value of waveforms self.write('SOUR1:DATA:VOL:CLE') self.write('SOUR2:DATA:VOL:CLE') self.setValue('Channel 1 Arb. Waveform', []) self.setValue('Channel 2 Arb. Waveform', []) self.waves = [None] * 2
def performOpen(self, options={}): VISA_Driver.performOpen(self, options) self.wait(delayTime) """ #Switch to remote & unlocked mode #(command already in 'init:' field in INI file) VISA_Driver.writeAndLog('$C3') """ self.clearMessages() #Switch to extended resolution VISA_Driver.writeAndLog(self, '$Q4') #Clear clamped status, if applicable VISA_Driver.writeAndLog(self, '$A0') self.wait(delayTime)
def performOpen(self,options={}): VISA_Driver.performOpen(self,options) self.wait(delayTime) """ #Switch to remote & unlocked mode #(command already in 'init:' field in INI file) VISA_Driver.writeAndLog('$C3') """ self.clearMessages() #Switch to extended resolution VISA_Driver.writeAndLog(self,'$Q4') #Clear clamped status, if applicable VISA_Driver.writeAndLog(self,'$A0') self.wait(delayTime)
def performOpen(self, options={}): """Perform the operation of opening the instrument connection""" # start by calling the generic VISA open to make sure we have a connection VISA_Driver.performOpen(self, options) # get model name and number of channels sModel = self.getModel() if sModel == '5208': self.nCh = 8 elif sModel == '5204': self.nCh = 4 elif sModel == '5202': self.nCh = 2 self.nMarker = 4 self.initSetConfig()
def performOpen(self, options={}): VISA_Driver.performOpen(self, options=options) self.data = None self.xdisp = 0 self.xincr = 1 self.f1 = 0 self.f2 = 0 self.I1 = None self.Q1 = None self.I2 = None self.Q2 = None self.P1Mean = None self.P2Mean = None self.psi = None self.covar = None
def performOpen(self, options={"values_format":visa.single | visa.big_endian}): """Perform the operation of opening the instrument connection""" try: VISA_Driver.performOpen(self, options=options) # start by calling the generic VISA open to make sure we have a connection self.com.values_format=visa.single | visa.big_endian #this sets this bit order so we can interpret the binary data self.writeAndLog("HEADER OFF") #having the header on makes reading data more difficult self.writeAndLog("DATA:ENCDG FPBinary") # enable the encoding of bits we can understand (faster data transfer than ASCII) self.AvgTrace = {'Time': None, #This is a local dictionary to avoid taking a sweep twice unnecessarily 'Amplitude': None, 'RollAvg Time': None, 'RollAvg Amplitude': None} self.numRep=self.getValue("Number of shifts") except Error as e: # re-cast errors as a generic communication error msg = str(e) raise InstrumentDriver.CommunicationError(msg)
def performOpen(self, options={}): """ Perform the operation of opening the instrument connection """ # self.writeAndLog('*CLS') VISA_Driver.performOpen(self, options=options) self.writeAndLog("*CLS") self.writeAndLog("OUTX0") # set output to GPIB self.writeAndLog("PDST 3") # set Print/Plot/Dump destination to GPIB self.writeAndLog("DISP 2, 1") # set displays live self.writeAndLog("DFMT 1") # set displays to dual display self.writeAndLog("ACTD 0") # set active display to displayA self.writeAndLog("RPMF 0") # set Hz as frequency units (not RPM) self.writeAndLog("A1RG 1") # Autoranges Channel 1 self.writeAndLog("A2RG 1") # Autoranges Channel 2 self.writeAndLog("I1AR 1") # Autotracks Channel 1 self.writeAndLog("I2AR 1") # Autotracks Channel 2 self.writeAndLog("ASCL 0") # Autoscales Display 0 self.writeAndLog("ASCL 1") # Autoscales Display 1 self.writeAndLog("STRT") # Starts measurement
def performOpen(self, options={}): """ Perform the operation of opening the instrument connection """ #self.writeAndLog('*CLS') VISA_Driver.performOpen(self, options=options) self.writeAndLog('*CLS') self.writeAndLog('OUTX0') # set output to GPIB self.writeAndLog('PDST 3') #set Print/Plot/Dump destination to GPIB self.writeAndLog('DISP 2, 1') # set displays live self.writeAndLog('DFMT 1') # set displays to dual display self.writeAndLog('ACTD 0') # set active display to displayA self.writeAndLog('RPMF 0') # set Hz as frequency units (not RPM) self.writeAndLog('A1RG 1') # Autoranges Channel 1 self.writeAndLog('A2RG 1') # Autoranges Channel 2 self.writeAndLog('I1AR 1') # Autotracks Channel 1 self.writeAndLog('I2AR 1') # Autotracks Channel 2 self.writeAndLog('ASCL 0') # Autoscales Display 0 self.writeAndLog('ASCL 1') # Autoscales Display 1 self.writeAndLog('STRT') # Starts measurement
def performOpen(self, options={}): """Perform the operation of opening the instrument connection""" self.log("Opening QDAC", options, level=30) if float(qdac.VERSION) < float(REQUIRED_QDACPY_VERSION): raise Exception( "This driver requires qdac.py version {} or compatible".format( REQUIRED_QDACPY_VERSION)) if not hasattr(labberqdac(self), "Virtual" ): # For off line development we have a virtual qdac.py VISA_Driver.performOpen(self, options=options) self.log("Connected to physical device", level=30) self.q = labberqdac(self) # We are not flushing, as we the buffer is expected to be empty. Problem might be if the user turns on the QDAC after Labber is started. to be empty might need a flush here N = self.q.getNumberOfChannels() self.log("Channels: {}".format(N), level=30) # Set model string to actual model if N == 24: self.setModel(qdacmodels[0]) if N == 48: self.setModel(qdacmodels[1]) return
def performOpen(self, options={"values_format": visa.single | visa.big_endian}): """Perform the operation of opening the instrument connection""" # start by calling the generic VISA open to make sure we have a connection # always get function and range: they are essential for correct resolution and sweeping ############### quantFunc = self.instrCfg.getQuantity('Function') ###############valueFunc = self.performGetValue(quantFunc) ####################3quantFunc.setValue(valueFunc) try: VISA_Driver.performOpen(self, options=options) self.com.values_format = visa.single | visa.big_endian self.writeAndLog("HEADER OFF") self.writeAndLog("DATa:STOP 4000") self.writeAndLog("DATA:ENCDG FPBinary") # self.lTrace= [None] * 2 self.numMeas = 25 self.AvgTrace = {"Time": None, "Amplitude": None} except Error as e: # re-cast afdigitizer errors as a generic communication error msg = str(e) raise InstrumentDriver.CommunicationError(msg)
def performOpen(self, options={}): """Perform the operation of opening the instrument connection""" # start by calling the generic VISA open to make sure we have a connection try: VISA_Driver.performOpen(self, options=options) self.bOutput = False self.dFreq = 5e9 self.dPower = -40 self.dPhaseOffset = 0 self.bAmplitudeModulation = False self.nAmplitudeModulationMode = 1 self.bInternalPulseModulation = False self.nInternalPulseModulationMode = 1 self.dInternalPulsePeriod = 1e-3 self.dInternalPulseWidth = 100e-9 self.dInternalPulseDelay = 2e-6 self.nTriggerMode = 1 self.nPosOrNegEdge = 1 except Error as e: # re-cast errors as a generic communication error msg = str(e) raise InstrumentDriver.CommunicationError(msg)
def performOpen(self, options={}): """Perform the operation of opening the instrument connection. Initializes a measurement param dictionary and calls the generic VISA_Driver open""" self.dMeasParam = {} self.log(options) VISA_Driver.performOpen(self, options=options)
def performOpen(self, options={}): """Perform the operation of opening the instrument connection""" VISA_Driver.performOpen(self, options=options)
def performOpen(self, options={}): """Perform the operation of opening the instrument connection""" # calling the generic VISA open to make sure we have a connection VISA_Driver.performOpen(self, options=options)
def performOpen(self, options={}): """Perform the operation of opening the instrument connection""" # start by calling the generic VISA open to make sure we have a connection VISA_Driver.performOpen(self, options=options) # always get function and range: they are essential for correct resolution and sweeping self.readValueFromOther('Function')
def performOpen(self, options={}): VISA_Driver.performOpen(self, options=options)
def performOpen(self, options={}): VISA_Driver.performOpen(self, options) sAns = self.askAndLog('ALL 7FFF80') return sAns
def performOpen(self, options={}): """Perform the operation of opening the instrument connection""" # calling the generic VISA open to make sure we have a connection VISA_Driver.performOpen(self, options=options) # self.writeAndLog('BRDC "*RST"') pass
def performOpen(self, options={}): """Perform the operation of opening the instrument connection""" # start by calling the generic VISA open to make sure we have a connection VISA_Driver.performOpen(self, options) # configure AWG settings self.configure_awg()
def performOpen(self, options={}): """Perform the operation of opening the instrument connection""" # calling the generic VISA open to make sure we have a connection VISA_Driver.performOpen(self, options=options) # do additional initialization code here... pass
def performOpen(self, options={}): VISA_Driver.performOpen(self, options=options) # Set the format for the output VISA_Driver.writeAndLog(self, "FORM:ELEM:SENS VOLT,CURR,RES") # Put source modes to fixed (rather than sweep) VISA_Driver.writeAndLog(self, "SOUR:CURR:MODE FIX; :SOUR:VOLT:MODE FIX")
def performOpen(self, options={}): """Perform the operation of opening the instrument connection""" # start by calling the generic VISA open to make sure we have a connection VISA_Driver.performOpen(self, options) # clear value of waveform self.setValue('Arb. Waveform', [])
def performOpen(self, options={}): """Perform the operation of opening the instrument connection""" # calling the generic VISA open to make sure we have a connection VISA_Driver.performOpen(self, options=options) self.detectedOptions = self.getOptions()
def performOpen(self, options={}): VISA_Driver.performOpen(self, options=options) self.acquisitionsPerformed = 0