aboutsummaryrefslogtreecommitdiff
path: root/qolab
diff options
context:
space:
mode:
Diffstat (limited to 'qolab')
-rw-r--r--qolab/hardware/rf_generator/qol_lmx2487.py55
1 files changed, 33 insertions, 22 deletions
diff --git a/qolab/hardware/rf_generator/qol_lmx2487.py b/qolab/hardware/rf_generator/qol_lmx2487.py
index ed4ade2..e9011f9 100644
--- a/qolab/hardware/rf_generator/qol_lmx2487.py
+++ b/qolab/hardware/rf_generator/qol_lmx2487.py
@@ -11,19 +11,28 @@ class QOL_LMX2487(RFGenerator):
The communication with RF generator is done via nodeMCU controlling esp2866 chip.
"""
- def __init__(self, *args, port='/dev/ttyUSB0', speed=115200, timeout=1, setToDefaults=False, **kwds):
+
+ def __init__(
+ self,
+ *args,
+ port="/dev/ttyUSB0",
+ speed=115200,
+ timeout=1,
+ setToDefaults=False,
+ **kwds,
+ ):
super().__init__(*args, **kwds)
- self.config['Device model'] = 'QOL made RF generator based on TI LMX2487 chip'
+ self.config["Device model"] = "QOL made RF generator based on TI LMX2487 chip"
self.port = port
self.speed = speed
self.timeout = timeout
- self.connection = serial.Serial( self.port, self.speed, timeout=self.timeout)
+ self.connection = serial.Serial(self.port, self.speed, timeout=self.timeout)
self.log = []
self.logCapacity = 10
self._FreqFixed = None
self.hopeFree = True
- self.hopeFreeFreqJump = 100e3 # we break laser lock if Freq change is larger
- self.dwellTime=0.1 # needed for hope free setling
+ self.hopeFreeFreqJump = 100e3 # we break laser lock if Freq change is larger
+ self.dwellTime = 0.1 # needed for hope free setling
if setToDefaults:
self.sendSerialCmd("set_lmx2487_board_to_default_state()")
@@ -39,20 +48,21 @@ class QOL_LMX2487(RFGenerator):
return strOut
def sendSerialCmd(self, cmd):
- self.connection.write(bytes(cmd+'\r','ascii'))
+ self.connection.write(bytes(cmd + "\r", "ascii"))
if "3.4" == serial.__version__:
# older version style
- resp = self.connection.read_until(terminator=b'> ')
+ resp = self.connection.read_until(terminator=b"> ")
else:
# new style after 20180616
- resp = self.connection.read_until(expected=b'> ')
- resp = resp.decode('utf-8')
+ resp = self.connection.read_until(expected=b"> ")
+ resp = resp.decode("utf-8")
self.add2log(resp)
return resp
@BasicInstrument.tsdb_append
- def setFreqFixed(self,freq):
- """
+ def setFreqFixed(self, freq):
+ """Set frequency of RF signal.
+
Will do incremental hope free tuning to desired frequency,
if self.hopeFree is True.
RF generator itself is fine, but our laser looses lock without it.
@@ -61,7 +71,7 @@ class QOL_LMX2487(RFGenerator):
finished = False
while not finished:
frNow = self.getFreqFixed()
- dF = freq-frNow
+ dF = freq - frNow
if dF >= 0:
dFSign = 1
else:
@@ -73,7 +83,7 @@ class QOL_LMX2487(RFGenerator):
else:
fr = frNow + dFSign * self.hopeFreeFreqJump
self._FreqFixed = fr
- cmd_str=f'setFreq({fr:.2f})'
+ cmd_str = f"setFreq({fr:.2f})"
self.sendSerialCmd(cmd_str)
if not finished:
time.sleep(self.dwellTime)
@@ -82,20 +92,21 @@ class QOL_LMX2487(RFGenerator):
def getFreqFixed(self):
# talking to hardware is slow, so we use cached value if we can
if self._FreqFixed is None:
- resp = self.sendSerialCmd('getFreq()')
- m = re.search('[0-9.]+', resp)
+ resp = self.sendSerialCmd("getFreq()")
+ m = re.search("[0-9.]+", resp)
if m is not None:
self._FreqFixed = float(m.group())
return self._FreqFixed
-if __name__ == '__main__':
+if __name__ == "__main__":
import platform
- if platform.system() == 'Linux':
- rfgen=QOL_LMX2487(port='/dev/ttyUSB0', speed=115200, timeout=1)
+
+ if platform.system() == "Linux":
+ rfgen = QOL_LMX2487(port="/dev/ttyUSB0", speed=115200, timeout=1)
else:
- rfgen=QOL_LMX2487(port='COM4', speed=115200, timeout=1)
+ rfgen = QOL_LMX2487(port="COM4", speed=115200, timeout=1)
print("testing")
- print('------ Header start -------------')
- print(str.join('\n', rfgen.getHeader()))
- print('------ Header ends -------------')
+ print("------ Header start -------------")
+ print(str.join("\n", rfgen.getHeader()))
+ print("------ Header ends -------------")