random wiggle

This commit is contained in:
Sebastien Bourdeauducq 2020-08-11 18:36:25 +08:00
parent 2c05dda88a
commit 22bcbecab8
1 changed files with 4 additions and 4 deletions

View File

@ -114,14 +114,14 @@ class Stabilizer:
self.lock_counter = 0
self.unlock_counter = 0
self.wiggle_direction = 1
self.wiggle = 0.0
self.amp_threshold = 80.0
self.k = 30.0e-6
self.tolerance = 10e3
self.lock_counter_threshold = 60
self.unlock_counter_threshold = 500
self.wiggle = 0.15
self.wiggle_amplitude = 0.15
def input(self, samples):
spectrum = np.abs(np.fft.fft(samples*blackmanharris(len(samples))))
@ -152,10 +152,10 @@ class Stabilizer:
self.unlock_counter += 1
if not success and (self.unlock_counter > self.unlock_counter_threshold):
print("wiggle")
self.wiggle_direction = -self.wiggle_direction
self.wiggle = self.wiggle_amplitude*(np.random.random() - 0.5)
self.unlock_counter = 0
self.cb(spectrum, freq, self.locked(), tuning + self.wiggle_direction*self.wiggle)
self.cb(spectrum, freq, self.locked(), tuning + self.wiggle)
def locked(self):
return self.lock_counter > self.lock_counter_threshold