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
|
import sys
import traceback
import time # For sleep, clock, time and perf_counter
from datetime import datetime
import random
import u3
import u6
import ue9
class UE9qol:
def __init__(self, debug = False, autoOpen = True, **kargs):
#d = ue9.UE9(ethernet=True, ipAddress="192.168.1.209") # Over TCP/ethernet connect to UE9 with IP address 192.168.1.209
self.daq = ue9.UE9(debug=debug, autoOpen=autoOpen)
# 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 getInputCh(self, chNum):
return self.daq.getAIN(chNum)
def setOutputCh(self, chNum=None, volts=None):
if chNum == None or volts == None:
print("setOutputCh needs chNum and volts to be set")
return 0
bits = self.daq.voltageToDACBits(volts, dacNumber = chNum)
# out is completely bogus for DAC settings in UE9
out=self.daq.singleIO(IOType=5, Channel=chNum, DAC=bits)
return volts
def close(self):
self.daq.close()
class UE9qolDummy:
# to be used for graphics debugging
def __init__(self, debug = False, autoOpen = True, **kargs):
# do nothing
return
def getInputCh(self, chNum):
return random.normalvariate(chNum, 0.25)
def setOutputCh(self, chNum=None, volts=None):
# do nothing
return
def close(self):
# do nothing
return
|