1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
from ._basic import DAQ
import ue9
class LabJackUE9(DAQ):
"""
DAQ LabJack UE9 class.
This is custom modification of the stock ue9 class
provided by LabJack.
"""
def __init__(
self, *args, debug=False, autoOpen=True, ethernet=False, ipAddress=None, **kargs
):
"""
LabJack UE9 can be contacted via TCP, use
LabJackUE9(ethernet=True, ipAddress="192.168.1.209")
"""
super().__init__(*args, **kargs)
self.config["Device model"] = "LabJack UE9"
self.AnalogInputsNum = 4
self.AnalogOutputsNum = 2
self.daq = ue9.UE9(
debug=debug, autoOpen=autoOpen, ethernet=ethernet, ipAddress=ipAddress
)
# For applying the proper calibration to readings.
c = self.daq.getCalibrationData()
# by evmik
# fixing missing slope for gain '0'
c["AINSlopes"]["0"] = 0.0000775030
def getAIN(self, chNum):
"""get analog input (AIN) voltage"""
BipGain = 8
Resolution = 12
SettlingTime = 0
# BipGain = 8 -> bipolar range (-5V, +5V) gain 1
# UE9 default BipGain = 0 -> signal range (0V, +5V) gain 1
# other BipGain could be:
# 0 = Unipolar Gain 1, 1 = Unipolar Gain 2,
# 2 = Unipolar Gain 4, 3 = Unipolar Gain 8,
# 8 = Bipolar Gain 1
return self.daq.getAIN(
chNum, BipGain=BipGain, Resolution=Resolution, SettlingTime=SettlingTime
)
def setDAC(self, chNum, volts):
"""set digital to analog (DAC) output voltage"""
if (chNum is None) or (volts is None):
print("setOutputCh needs chNum and volts to be set")
return 0
bits = self.daq.voltageToDACBits(volts, dacNumber=chNum)
# results are completely bogus for DAC settings in UE9
self.daq.singleIO(IOType=5, Channel=chNum, DAC=bits)
return volts
def close(self):
self.daq.close()
if __name__ == "__main__":
daq = LabJackUE9()
print("testing")
print("------ Header start -------------")
print(str.join("\n", daq.getHeader()))
print("------ Header ends -------------")
|