aboutsummaryrefslogtreecommitdiff
path: root/qolab/hardware/rf_generator/qol_lmx2487.py
diff options
context:
space:
mode:
authorEugeniy E. Mikhailov <evgmik@gmail.com>2022-03-29 12:29:51 -0400
committerEugeniy E. Mikhailov <evgmik@gmail.com>2022-03-29 12:29:51 -0400
commit19f0ede75bf4c5eba448edbb1e5fe6145c83bef2 (patch)
treeea0df5b2964376be97be50544d4924f0fb4c31ad /qolab/hardware/rf_generator/qol_lmx2487.py
parentb62d8fdc6a71892f17f74821aac8f8388ec0c214 (diff)
downloadqolab-19f0ede75bf4c5eba448edbb1e5fe6145c83bef2.tar.gz
qolab-19f0ede75bf4c5eba448edbb1e5fe6145c83bef2.zip
draft of LMX2487 chip homemade RF Generator control
Diffstat (limited to 'qolab/hardware/rf_generator/qol_lmx2487.py')
-rw-r--r--qolab/hardware/rf_generator/qol_lmx2487.py59
1 files changed, 59 insertions, 0 deletions
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
+
+