A controller in an optical switch providing optical coupling of an optical
signal between a source port and a target port employs, in at least one
axis, gradient control using a feedback loop that compensates for
alignment error between a source port and a target port in an optical
switch. In at least one other axis, the controller generates a control
input according to a control law that results in variable attenuation of
optical coupling between the source port and the target port in the
optical switch. A dither signal may be applied to the control input in
the at least one other axis. Amplitude of the applied dither signal may
be varied.