first commissioning of interferometer auto alignment

This commit is contained in:
Holler Mirko
2024-09-12 16:02:18 +02:00
committed by wakonig_k
parent 793eedb3f4
commit 07543755d9
@@ -179,28 +179,32 @@ class OMNY_rt_client:
def _omny_interferometer_optimize(self, mirror_channel, channel):
if mirror_channel == -1:
raise OMNY_rt_clientError("no mirror channel selected")
#mirror channel is mirror number and channel is smaract channel, i.e. axis of the mirror
if channel == 3:
steps_pos = self.mirror_parameters[mirror_channel]["opt_steps1_pos"]
steps_neg = self.mirror_parameters[mirror_channel]["opt_steps1_neg"]
#opt_amplitude_pos = self.mirror_parameters[mirror_channel]["opt_amplitude1_pos"]
#opt_amplitude_neg = self.mirror_parameters[mirror_channel]["opt_amplitude1_neg"]
opt_amplitude_pos = self.mirror_parameters[mirror_channel]["opt_amplitude1_pos"]
opt_amplitude_neg = self.mirror_parameters[mirror_channel]["opt_amplitude1_neg"]
elif channel == 4:
steps_pos = self.mirror_parameters[mirror_channel]["opt_steps2_pos"]
steps_neg = self.mirror_parameters[mirror_channel]["opt_steps2_neg"]
#opt_amplitude_pos = self.mirror_parameters[mirror_channel]["opt_amplitude2_pos"]
#opt_amplitude_neg = self.mirror_parameters[mirror_channel]["opt_amplitude2_neg"]
opt_amplitude_pos = self.mirror_parameters[mirror_channel]["opt_amplitude2_pos"]
opt_amplitude_neg = self.mirror_parameters[mirror_channel]["opt_amplitude2_neg"]
else:
raise OMNY_rt_clientError(f"invalid channel number {channel}.")
previous_signal = dev.rtx.controller._omny_interferometer_get_signalsample(self.mirror_parameters[mirror_channel]["opt_signalchannel"], self.mirror_parameters[mirror_channel]["opt_averaging_time"])
if previous_signal < self.mirror_parameters[mirror_channel]["opt_signal_min_begin"]:
raise OMNY_rt_clientError("error1") #(f"Minimum signal of axis {self.mirror_parameters[mirror_channel]["opt_mirrorname"]} to start alignment not present.")
min_begin = self.mirror_parameters[mirror_channel]["opt_signal_min_begin"]
if previous_signal < min_begin:
#raise OMNY_rt_clientError("error1") #(f"Minimum signal of axis {self.mirror_parameters[mirror_channel]["opt_mirrorname"]} to start alignment not present.")
print(f"Minimum signal for auto alignment {min_begin} not reached.")
return
elif previous_signal > self.mirror_parameters[mirror_channel]["opt_signal_stop"]:
print(f"Interferometer signal of axis is good") # {self.mirror_parameters[mirror_channel]["opt_mirrorname"]} is good.")
return
else:
direction = 1
cycle_counter=0
@@ -210,18 +214,36 @@ class OMNY_rt_client:
self.mirror_amplitutde_increase=0
current_sample = dev.rtx.controller._omny_interferometer_get_signalsample(self.mirror_parameters[mirror_channel]["opt_signalchannel"], self.mirror_parameters[mirror_channel]["opt_averaging_time"])
max=current_sample
while current_sample < self.mirror_parameters[mirror_channel]["opt_signal_stop"] and cycle_counter<cycle_max and reversal_counter < reversal_max:
if current_sample < self.mirror_parameters[mirror_channel]["opt_signal_min_begin"]:
raise OMNY_rt_clientError("error2") #(f"Minimum signal of axis {self.mirror_parameters[mirror_channel]["opt_mirrorname"]} to start alignment not present.")
# if current_sample < self.mirror_parameters[mirror_channel]["opt_signal_min_begin"]:
# raise OMNY_rt_clientError("error2") #(f"Minimum signal of axis {self.mirror_parameters[mirror_channel]["opt_mirrorname"]} to start alignment not present.")
if direction>0:
self._omny_interferometer_openloop_steps(channel, steps_pos, self.mirror_parameters[mirror_channel]["opt_amplitude_pos"])
self._omny_interferometer_openloop_steps(channel, steps_pos, opt_amplitude_pos)
verbose_str = f"channel {channel}, steps {steps_pos}"
else:
self._omny_interferometer_openloop_steps(channel, steps_neg, self.mirror_parameters[mirror_channel]["opt_amplitude_neg"])
print(f"Aligning axis ") #{self.mirror_parameters[mirror_channel]["opt_mirrorname"]}. Target: {self.mirror_parameters[mirror_channel]["opt_signal_stop"]}, current {current_sample}")
self._omny_interferometer_openloop_steps(channel, -steps_neg, opt_amplitude_neg)
verbose_str = f"auto action {channel}, steps {-steps_pos}"
#print(f"Aligning axis ") #{self.mirror_parameters[mirror_channel]["opt_mirrorname"]}. Target: {self.mirror_parameters[mirror_channel]["opt_signal_stop"]}, current {current_sample}")
current_sample = dev.rtx.controller._omny_interferometer_get_signalsample(self.mirror_parameters[mirror_channel]["opt_signalchannel"], self.mirror_parameters[mirror_channel]["opt_averaging_time"])
opt_mirrorname = self.mirror_parameters[self.mirror_channel]["opt_mirrorname"]
info_str = f"\rAuto aligning Channel {self.mirror_channel}, {opt_mirrorname}, Current signal: {current_sample:.0f}"
filling = " " * (50-len(info_str))
# Calculate the number of filled and unfilled segments
length = 30
percentage = current_sample / max
filled_length = int(length * percentage)
unfilled_length = length - filled_length
bar = '#' * filled_length + '-' * unfilled_length
print(info_str + filling + " " + bar + f" {max:.0f} "+verbose_str+" (q)uit \r", end='')
if previous_signal>current_sample:
if direction<0:
steps_pos=int(steps_pos/2)
@@ -235,7 +257,7 @@ class OMNY_rt_client:
previous_signal=current_sample
cycle_counter+=1
print(f"Finished aligning axis") # {self.mirror_parameters[mirror_channel]["opt_mirrorname"]}. Target: {self.mirror_parameters[mirror_channel]["opt_signal_stop"]}, current {current_sample}")
print(f"\r\nFinished aligning channel {channel} of mirror {mirror_channel}\n\r") # {self.mirror_parameters[mirror_channel]["opt_mirrorname"]}. Target: {self.mirror_parameters[mirror_channel]["opt_signal_stop"]}, current {current_sample}")
def omny_tweak_interferometer(self):
self._tweak_interferometer()