aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--qolab/hardware/rf_generator/__init__.py1
-rw-r--r--qolab/hardware/rf_generator/qol_lmx2487.py59
2 files changed, 60 insertions, 0 deletions
diff --git a/qolab/hardware/rf_generator/__init__.py b/qolab/hardware/rf_generator/__init__.py
index 6de404a..efa1af4 100644
--- a/qolab/hardware/rf_generator/__init__.py
+++ b/qolab/hardware/rf_generator/__init__.py
@@ -22,5 +22,6 @@ class RFGeneratorSCPI(SCPIinstr, RFGenerator):
self.config['DeviceId'] = str.strip(self.idn)
from .agilent_e8257d import AgilentE8257D
+from .qol_lmx2487 import QOL_LMX2487
diff --git a/qolab/hardware/rf_generator/qol_lmx2487.py b/qolab/hardware/rf_generator/qol_lmx2487.py
new file mode 100644
index 0000000..1c5d588
--- /dev/null
+++ b/qolab/hardware/rf_generator/qol_lmx2487.py
@@ -0,0 +1,59 @@
+from qolab.hardware.basic import BasicInstrument
+import serial
+
+
+class QOL_LMX2487(RFGenerator):
+ """
+ QOL lab made RF generator based on TI LMX2487 chip.
+ The communication with RF generator is done via nodeMCU controlling esp2866 chip.
+ """
+ def __init__(self, *args, port='/dev/ttyUSB0', speed=115200, timeout=1, setToDefaults=True, **kwds):
+ super().__init__(*args, **kwds)
+ self.port = port
+ self.speed = speed
+ self.timeout = timeout
+ self.connection = serial.Serial( self.port, self.speed, timeout=self.timeout)
+ self.log = []
+ self.logCapacity = 10
+ self._FreqFixed = None
+ if setToDefaults:
+ self.sendSerialCmd("set_lmx2487_board_to_default_state()")
+
+ def add2log(self, text):
+ self.log.append(text)
+ while len(self.log) > self.logCapacity:
+ self.log.pop(0)
+
+ def log2str(self, interval=None):
+ strOut = ""
+ for e in self.log:
+ strOut += e
+ return strOut
+
+ def sendSerialCmd(self, cmd):
+ self.connection.write(bytes(cmd+'\r','ascii'))
+ if "3.4" == serial.__version__:
+ # older version style
+ resp = self.connection.read_until(terminator=b'> ')
+ else:
+ # new style after 20180616
+ resp = self.connection.read_until(expected=b'> ')
+ resp = resp.decode('utf-8')
+ self.add2log(resp)
+ return resp
+
+ @BasicInstrument.tsdb_append
+ def setFreqFixed(self,freq):
+ self._FreqFixed = freq
+ cmd_str=f'setFreq({freq:.2f})'
+ self.sendSerialCmd(cmd_str)
+
+ @BasicInstrument.tsdb_append
+ def getFreqFixed(self):
+ """
+ getFreqFixed unable to get frequency from hardware.
+ So we use value from previews setFreqFixed.
+ """
+ return self._FreqFixed
+
+