def __init__(self): self.d = u3.U3() self.d.getCalibrationData() FIOAnalogChans = 0 EIOAnalogChans = 0 fios = FIOAnalogChans & 0xFF eios = EIOAnalogChans & 0xFF self.d.configIO(FIOAnalog=fios, EIOAnalog=eios) self.d.getFeedback(u3.PortDirWrite(Direction=[0, 0, 0], WriteMask=[0, 0, 15])) # print("Before Feedback") #Pin 0 (FIO0) Hold low to select Valves 0-15 on the Valve Master 2000 Board self.d.getFeedback(u3.BitStateWrite(IONumber=8, State = 0)) #Pin 1 (FIO1) Hold low to enable output self.d.getFeedback(u3.BitStateWrite(IONumber=9, State = 0)) #Pin 2 (FIO2) Set Low to disable H-Bridge Drivers Port A (Open Valve) self.d.getFeedback(u3.BitStateWrite(IONumber=10, State = 0)) #Pin 3 (FIO3) Set Low to disable H-Bridge Drivers Port B (Close Valve) self.d.getFeedback(u3.BitStateWrite(IONumber=11, State = 0)) self.d.getFeedback(u3.BitStateWrite(IONumber=12, State = 0)) self.d.getFeedback(u3.BitStateWrite(IONumber=13, State = 0)) self.d.getFeedback(u3.BitStateWrite(IONumber=14, State = 0)) self.d.getFeedback(u3.BitStateWrite(IONumber=15, State = 0))
def configure_MB_labjack(self): """ Configure LabJack 1 for digital module control and analog monitoring """ if self.has_labjack(1): # Analog input for voltages, currents and temperatures FIOanalog = int('00001111',2) self.LJ[1].configIO(FIOAnalog=FIOanalog,EIOAnalog=0) CIOBitDir = int('1111',2) EIOBitDir = int('11111111',2) FIOBitDir = int('00000000',2) direction = [FIOBitDir, EIOBitDir, CIOBitDir] mask = [0xff,0xff,0xff] self.logger.debug("LabJack %d direction=%s, write mask=%s", self.LJ[1].localID, direction, mask) try: status = self.LJ[1].getFeedback(u3.PortDirWrite(Direction=direction, WriteMask=mask)) self.logger.debug(" configure status: %s", status) except Exception as details: self.logger.error(" Could not set bit direction on U3 %d", self.LJ[1].localID) raise ObservatoryError("","configuring LJ 1 failed:\n"+str(details)) else: raise ObservatoryError("","LabJack 1 is not connected")
def configure_atten_labjack(self, ID): """ Configure a LabJack for PIN diode attenuator control """ if self.has_labjack(ID): self.LJ[ID].configIO(EIOAnalog=0, FIOAnalog=0) CIOBitDir = int('0000',2) EIOBitDir = int('00000000',2) FIOBitDir = int('00000000',2) direction = [FIOBitDir, EIOBitDir, CIOBitDir] mask = [0xff,0xff,0xff] self.logger.debug(" LabJack %d direction=%s, write mask=%s", ID, direction, mask) try: status = self.LJ[ID].getFeedback(u3.PortDirWrite(Direction=direction, WriteMask=mask)) self.logger.debug(" configure status: %s", status) except Exception as details: self.logger.error(" Could not set bit direction on U3 %d", self.LJ[ID].localID) raise ObservatoryError("LabJack "+str(ID), "not configured:\n"+str(details)) else: raise ObservatoryError("LabJack "+str(ID)," is not connected")
latestAinValues = [0] * numChannels numIterations = 1000 d = u3.U3() try: #Configure the IOs before the test starts FIOEIOAnalog = (2**numChannels) - 1 fios = FIOEIOAnalog & (0xFF) eios = FIOEIOAnalog / 256 d.configIO(FIOAnalog=fios, EIOAnalog=eios) d.getFeedback(u3.PortDirWrite(Direction=[0, 0, 0], WriteMask=[0, 0, 15])) feedbackArguments = [] feedbackArguments.append(u3.DAC0_8(Value=125)) feedbackArguments.append(u3.PortStateRead()) #Check if the U3 is an HV if d.configU3()['VersionInfo'] & 18 == 18: isHV = True else: isHV = False for i in range(numChannels): feedbackArguments.append( u3.AIN(i, 31, QuickSample=quickSample, LongSettling=longSettling))
print() LoopDelay = float(LoopDelay) / 1000.0 QuickSample = 1 LongSettling = 0 InputSet = [] try: LabJack = u3.U3() LabJack.getCalibrationData() try: FIOEIOAnalog = (2**InputCount) - 1 fios = FIOEIOAnalog & 0xFF eios = FIOEIOAnalog // 256 LabJack.configIO(FIOAnalog=fios, EIOAnalog=eios) LabJack.getFeedback( u3.PortDirWrite(Direction=[0, 0, 0], WriteMask=[0, 0, 15])) FeedbackArguments = [] FeedbackArguments.append(u3.DAC0_8(Value=125)) FeedbackArguments.append(u3.PortStateRead()) if LabJack.configU3()['VersionInfo'] & 18 == 18: isHV = True # U3 is an HV else: isHV = False for Input in range(InputCount): FeedbackArguments.append( u3.AIN(Input, 31, QuickSample=QuickSample, LongSettling=LongSettling)) Time0 = time.time() Time1 = Time0