aboutsummaryrefslogtreecommitdiff
path: root/qolab/hardware
diff options
context:
space:
mode:
Diffstat (limited to 'qolab/hardware')
-rw-r--r--qolab/hardware/daq/__init__.py15
-rw-r--r--qolab/hardware/daq/labjack_ue9.py59
2 files changed, 74 insertions, 0 deletions
diff --git a/qolab/hardware/daq/__init__.py b/qolab/hardware/daq/__init__.py
new file mode 100644
index 0000000..8828591
--- /dev/null
+++ b/qolab/hardware/daq/__init__.py
@@ -0,0 +1,15 @@
+from qolab.hardware.basic import BasicInstrument
+
+class DAQ(BasicInstrument):
+ # Minimal set of methods to be implemented by a RFGenerator
+ def __init__(self, *args, **kwds):
+ BasicInstrument.__init__(self, *args, **kwds)
+ self.config['Device type']='DAQ'
+ self.config['Device model'] = 'Generic DAQ Without Hardware interface'
+ self.config['FnamePrefix'] = 'daq'
+ self.deviceProperties = {'AnalogInputsNum', 'AnalogOutputsNum' }
+
+ # this is device dependent
+ self.AnalogInputsNum=0
+ self.AnalogOutputsNum=0
+
diff --git a/qolab/hardware/daq/labjack_ue9.py b/qolab/hardware/daq/labjack_ue9.py
new file mode 100644
index 0000000..5b293f4
--- /dev/null
+++ b/qolab/hardware/daq/labjack_ue9.py
@@ -0,0 +1,59 @@
+from qolab.hardware.basic import BasicInstrument
+from qolab.hardware.daq import DAQ
+import ue9
+
+class LabJackUE9(DAQ):
+ """
+ This custom modification of the stock LabJack UE9 class provided by LabJack as ue9
+ """
+
+ def __init__(self, *args, debug = False, autoOpen = True, ethernet=False, ipAddress="192.168.1.209", **kargs):
+ """
+ LabJack UE9 can be contacted via TCP, use
+ QOL_UE9(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)
+ 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 getChanVoltage(self, chNum, BipGain):
+ BipGain = 8
+ # 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)
+
+ def setChanVoltage(self, chNum, volts):
+ 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()
+
+
+
+if __name__ == '__main__':
+ daq = LabJackUE9()
+ print("testing")
+ print('------ Header start -------------')
+ print(str.join('\n', daq.getHeader()))
+ print('------ Header ends -------------')