""" Reads AIN channels on T7 LabJack with a MUX80 multiplexer. The AIN channels are sampled in differential mode. """ from labjack import ljm from time import sleep from time import localtime, strftime import logging # Open first found T7 LabJack handle = ljm.openS("T7", "USB", "ANY") info = ljm.getHandleInfo(handle) print("Opened a LabJack with Device type: %i, Connection type: %i,\n" \ "Serial number: %i, IP address: %s, Port: %i,\nMax bytes per MB: %i" % \ (info[0], info[1], info[2], ljm.numberToIP(info[3]), info[4], info[5])) # Setup and call eWriteNames to configure AINs on the LabJack. numChannels = 32 numFrames = numChannels*3 # Generate lists with channel number pairings which # match the MUX80 data sheet for Differential readings pChan = range(48,56)+range(64,72)+range(80,88)+range(96,104) nChan = range(56,64)+range(72,80)+range(88,96)+range(104,112) #Set up the channels names = [] aValues = [] for p in pChan: names = names+["AIN%d_NEGATIVE_CH"%p, "AIN%d_RANGE"%p, "AIN%d_RESOLUTION_INDEX"%p] for n in nChan: aValues = aValues+[n, 10, 0] #+/-10V range with default resolution ljm.eWriteNames(handle, numFrames, names, aValues) #List of analog input names ChanNames = [] for p in pChan: ChanNames = ChanNames+["AIN%d"%p] results = ljm.eReadNames(handle, numChannels, ChanNames) #Get AIN values print results print results[31-1] ljm.close(handle)