improve speed and reliability of laser lock
This commit is contained in:
parent
d41493934b
commit
dadd09d914
16
noptica.py
16
noptica.py
|
@ -112,13 +112,16 @@ class Stabilizer:
|
|||
self.freq_target = freq_target
|
||||
self.cb = cb
|
||||
|
||||
self.amp_counter = 0
|
||||
self.lock_counter = 0
|
||||
self.unlock_counter = 0
|
||||
self.wiggle = 0.0
|
||||
self.tuning = 0.0
|
||||
|
||||
self.amp_threshold = 80.0
|
||||
self.k = 30.0e-6
|
||||
self.tolerance = 10e3
|
||||
self.amp_counter_threshold = 60
|
||||
self.lock_counter_threshold = 60
|
||||
self.unlock_counter_threshold = 500
|
||||
self.wiggle_amplitude = 0.15
|
||||
|
@ -132,14 +135,16 @@ class Stabilizer:
|
|||
if amplitude > self.amp_threshold:
|
||||
freq = self.freqs[i]
|
||||
delta = freq - self.freq_target
|
||||
tuning = delta*self.k
|
||||
self.amp_counter += 1
|
||||
if self.amp_counter > self.amp_counter_threshold:
|
||||
self.tuning = delta*self.k
|
||||
if abs(delta) < self.tolerance:
|
||||
success = True
|
||||
else:
|
||||
freq = None
|
||||
tuning = 0.0
|
||||
self.amp_counter = 0
|
||||
max_tuning_abs = 0.5 - self.wiggle_amplitude - 1e-9
|
||||
tuning = max(min(tuning, max_tuning_abs), -max_tuning_abs)
|
||||
self.tuning = max(min(self.tuning, max_tuning_abs), -max_tuning_abs)
|
||||
|
||||
if success:
|
||||
self.lock_counter += 1
|
||||
|
@ -151,11 +156,12 @@ class Stabilizer:
|
|||
else:
|
||||
self.unlock_counter += 1
|
||||
if not success and (self.unlock_counter > self.unlock_counter_threshold):
|
||||
print("wiggle")
|
||||
self.wiggle = self.wiggle_amplitude*np.random.uniform(-1.0, 1.0)
|
||||
print("wiggle", self.wiggle)
|
||||
self.unlock_counter = 0
|
||||
self.amp_counter = 0
|
||||
|
||||
self.cb(spectrum, freq, self.locked(), tuning + self.wiggle)
|
||||
self.cb(spectrum, freq, self.locked(), self.tuning + self.wiggle)
|
||||
|
||||
def locked(self):
|
||||
return self.lock_counter > self.lock_counter_threshold
|
||||
|
|
Loading…
Reference in New Issue