# An Application of Simulated Annealing in Compensation of Nonlinearity of Scanners
## 2 Materials and Methods  
The optical setup is composed of a Mach-Zehnder fiber interferometer that uses a super luminescent diode (SLD) with a central wavelength of 1300 nm and a spectral bandwidth of 25 nm. Both the reference and sample were in the same arm in this configuration of interferometer. To avoid light being sent back into the source, the coupling was performed via an optical isolator (ISO). The light was sent to a directional optical fiber coupler. It was then collimated and sent to a scanning head made of two galvo-scanners (#6110, Cambridge Technology CO., Bedford, MA, USA). The light reflected off the mirrors are focused on the sample using a microscope objective (LSM02, Thorlabs, Newton, NJ, USA); the effective focal length of the lens is 18 mm and the working distance is 7.5 mm. The sample is a metal plate consisting of a regular pattern of equidistant hexagonal holes, with the size of 100 microns. The plate is placed 3 mm in front of the sample mirror. The spot size of the light on the sample mirror is much smaller than the size of the hexagonal hole in the plate. The distance between the metal grid and the mirror helped separate, by depth, the reflections of the mirror from the reflections of the metal grid. Both the mirrors are PF-10-03 (Thorlabs, Newton, NJ, USA). The back-reflected light from the sample and mirror is detected using a balanced photodetector (Newfocus, 80 MHz electronic bandwidth, Newport, Irvine, CA, USA), with internal adjustable gain. More details of the design of this system are described in [27]. The hardware configuration of the compensation/optimization system is shown in Figure 2.  
The galvo-mirror is driven by a triangular signal of 5-volt peak-to-peak. Although the pattern of the holes is periodic, the spikes did not look equidistant due to the nonlinearity of the scanning. As a result, the peak produced by a fast Fourier transform (FFT) of the photodetected signal is not narrow around the frequency component given by \(2\eta/T\), where \(T\) is the period of the input triangular signal and \(n\) is the number of slits in the metal plate. Our aim is to alter the shape of each ramp in the triangular signal, using an optimization algorithm [22; 28; 29; 30; 31; 32; 33; 34], until the photodetected signal presented maximum regularity in the succession of peaks corresponding to the beam being scanned over regularly placed empty spaces, to produce equidistant spikes, and narrow the FFT peak. Figure 1: A Triangular signal (solid black) and the response function of a typical galvo (solid red). The scanner smooths the shape of the triangular signal as it cannot follow the abrupt slope changes. The optimization procedure is as follows: An initial triangular signal is sent to the galvo-scanner driver through a PCI-6229 (PCI output card, National Instrument, Austin, TX, USA). The photodetector signal is then acquired into a computer by a PXI-6133 (PCI input card, National Instrument, Austin, TX, USA). A LabVIEW(r) program is specially developed for data acquisition. The sampling rate for the output and input cards are 800,000 S/s and 50,000 S/s, respectively. The photodetector signal passed through a high pass filter and then is subject to a fast Fourier transformed (FFT). The high pass filter filtered out the strong low frequency components close to the repetition frequency. The peak of the FFT, corresponding to the fundamental frequency of the scan over the regular pattern of holes, is then considered as the cost function of the optimization algorithm. The frequency is calculated as twice the frequency of the triangular signal times the number of holes scanned. The optimization algorithm is written in LabVIEW using MathScript. The optimization algorithm produces a curved triangular signal composed of \(n\) ramps. A slope is evaluated for each two samples to create a short ramp (in total \(n/2\) short lines). The short ramps with different slopes are connected to each other to build the curved triangular signal.