A Compound Control System for FR4-Based Electromagnetic Scanning Micrograting

This paper presents a compound control system for precise control of the flame-retardant 4 (FR4)-based electromagnetic scanning micrograting. It mainly consists of a frequency controller and an angle controller. A dual closed-loop structure consisting of a current loop and an angle loop was designed in the angle controller. In addition, the incremental proportional–integral–derivative (PID) control algorithm was designed in the current loop, and the fuzzy-PID control algorithm was employed in the angle loop. From the experimental results, the frequency controller can effectively track the real-time resonant frequency of the scanning micrograting with a tracking accuracy of 0.1 Hz. The overshoot of the scanning micrograting is eliminated. Compared to an open-loop control system, the control system presented in this work reduces the steady-state error of the scanning micrograting from 1.122% to 0.243%. The control accuracy of the compound control system is 0.02°. The anti-interference recovery time of the scanning micrograting was reduced from 550 ms to 181 ms, and the long-term stability was increased from 2.94% to 0.12%. In the compound control system presented in this paper, the crucial parameters of the FR4-based electromagnetic scanning micrograting, including motion accuracy, anti-interference ability, and long-term stability, were effectively improved.


Introduction
A near infrared (NIR) spectrometer has been widely used in environmental monitoring [1], agriculture [2,3], food safety [4][5][6], oil production [7], and other fields for its ability to detect the composition and content of substances quickly and nondestructively. Most of the conventional NIR spectrometers have a common structure of using a fixed diffraction grating and an InGaAs detector array. With the development of the microelectromechanical system (MEMS) and micro-optical electromechanical system (MOEMS) technology, researchers have proposed the use of a combination of a scanning micrograting and a single tube detector to replace the conventional optical structure, which can reduce the size and cost of the instrument [8].
In recent years, most of the scanning micrograting has been developed and fabricated using MEMS technology. The actuation mechanisms can be mainly divided into four categories: electrostatic [9], electrothermal [10,11], electromagnetic [12][13][14][15], and piezoelectric [16]. The electromagnetic actuation mechanism is widely used for its large driving torque, linear mechanical properties, and low driving voltage. Electromagnetic coils are more suitable for integration into the flame-retardant 4 (FR4)-based

Overview of the FR4-Based Electromagnetic Scanning Micrograting
The compound control system is based on the FR4-based electromagnetic scanning micrograting we previously developed [15]. The photograph of the scanning micrograting is shown in Figure 1a. The FR4-based electromagnetic scanning micrograting includes a movable MEMS blazed grating, a pair of serpentine beams, driving coil and angle sensing coils, electrode pads, coverplate and baseplate, and a pair of NdFeB permanent magnets. The 7 × 7 mm MEMS blazed grating is bonded to the FR4 platform. The 12 × 12 mm platform with integrated driving coil and angle sensing coils is suspended by a pair of serpentine beams. Two NdFeB permanent magnets are assembled in parallel so that a nearly uniform magnetic field is formed near the FR4 platform [14]. Figure 1b,c shows the schematic of the top and bottom layouts of the scanning micrograting. The driving coil and differential angle sensing coils are connected to pads on the FR4 substrate by leads. Thus, the micrograting will be actuated to scan around the serpentine beams by the Lorentz force when the current flows through the driving coil. At the same time, the electromotive force related to the scanning angle is induced in the angle sensing coils.

Overview of the FR4-Based Electromagnetic Scanning Micrograting
The compound control system is based on the FR4-based electromagnetic scanning micrograting we previously developed [15]. The photograph of the scanning micrograting is shown in Figure 1a. The FR4-based electromagnetic scanning micrograting includes a movable MEMS blazed grating, a pair of serpentine beams, driving coil and angle sensing coils, electrode pads, coverplate and baseplate, and a pair of NdFeB permanent magnets. The 7 × 7 mm MEMS blazed grating is bonded to the FR4 platform. The 12 × 12 mm platform with integrated driving coil and angle sensing coils is suspended by a pair of serpentine beams. Two NdFeB permanent magnets are assembled in parallel so that a nearly uniform magnetic field is formed near the FR4 platform [14]. Figure 1b,c shows the schematic of the top and bottom layouts of the scanning micrograting. The driving coil and differential angle sensing coils are connected to pads on the FR4 substrate by leads. Thus, the micrograting will be actuated to scan around the serpentine beams by the Lorentz force when the current flows through the driving coil. At the same time, the electromotive force related to the scanning angle is induced in the angle sensing coils. The motion of the scanning micrograting can be approximated as a forced oscillating system. Thus, the motion (mechanical half angle, θ ) can be expressed by the following dynamical equation: where m J , m C , m K , and EM T represent the moment of inertia of the system, the damping coefficient, the torsional stiffness of the system, and the total electromagnetic driving torque, respectively. The mechanical scanning half angle of the scanning micrograting in the resonant state can be expressed as follows: is the quality factor and ξ represents the damping ratio. The moment of inertia of the system is mainly composed of the rotational inertia of the FR4 center platform, the integrated double-layer coil, and the silicon grating. Thus, the moment of inertia of the system can be expressed by the following equation: The motion of the scanning micrograting can be approximated as a forced oscillating system. Thus, the motion (mechanical half angle, θ) can be expressed by the following dynamical equation: where J m , C m , K m , and T EM represent the moment of inertia of the system, the damping coefficient, the torsional stiffness of the system, and the total electromagnetic driving torque, respectively. The mechanical scanning half angle of the scanning micrograting in the resonant state can be expressed as follows: where Q m = 1/(2ξ m ) is the quality factor and ξ represents the damping ratio. The moment of inertia of the system is mainly composed of the rotational inertia of the FR4 center platform, the integrated double-layer coil, and the silicon grating. Thus, the moment of inertia of the system can be expressed by the following equation: where J F , J Coil , and J Si represent the rotational inertia of the FR4 center platform, the integrated double-layer coil, and the silicon grating, respectively. The torsional stiffness of the system can be calculated by the following equation: where K sθ represents the torsional stiffness of a single serpentine beam. The calculation of K sθ can be expressed as: where E, G, I yo , J p , l o , l p , and w s represent the Young's modulus of FR4 substrate, the shear modulus of FR4 substrate, the moment of inertia of the section of the serpentine beam to the y-axis, the torsion factor of the section, the length and width of the serpentine beam, and the cross-sectional width of the serpentine beam, respectively. The force that drives the scanning micrograting to scan is primarily provided by the Lorentz force experienced by the energized coil in the magnetic field. The total driving torque generated after the driving coil is energized is mainly composed of the torque generated by the top driving coil and the bottom driving coil. The total driving torque generated can be recorded as: where T t and T b represent the driving torque generated by the top driving coil and the bottom driving coil. The driving torque generated by the top driving coil can be expressed by the following equation: where I d , B x d , ∆y d , x d , N d , dt, and n represent the driving current, the magnetic flux density at a distance x d from the coil to the torsion axis, the length of the coil, the distance from the coil to the torsion axis, the total number of turns of the driving coil, the top driving coil, and the driving coil number from inside to outside, respectively. Similarly, the driving torque generated by the bottom driving coil can be written as: where a, b, and db represent the width of the driving coil, the distance between adjacent coils, and the bottom driving coil. When a sinusoidal driving voltage signal with the angular frequency of ω is applied in the driving coil, the scanning micrograting performs a sinusoidal torsional motion. The total electromotive force generated by the differential-angle-sensing coil can be expressed as: where U sA and U sB represent the electromotive force generated by sensing coil A and the electromotive force generated by sensing coil B. Evidently, the electromotive forces generated by the differential sensing coils are opposite in phase. The design of the differential angle sensor can effectively eliminate common mode interference and improve the signal-to-noise ratio (SNR) of the sensing signal. The total electromotive force generated by sensing coil A is composed of the electromotive force generated by the top and bottom coil, which can be expressed by the following equation: where U t sA and U b sA represent the electromotive force generated by the top and bottom sensing coil. In our previous work [14], when the scanning micrograting works in resonance, the phase difference between the driving voltage and the sensor output voltage is close to 0 • . In addition, the coupling voltage in the sensing coil coupled from the driving signal is so small that it can be ignored. The major structural parameters of the FR4-based electromagnetic scanning micrograting are listed in Table 1.  Figure 2a shows the frequency response characteristics of the FR4-based electromagnetic scanning micrograting when the mechanical half angle is 4.1 • . In addition, the phase-frequency curve in Figure 2a shows that the phase difference between the driving voltage and the sensor output voltage will change if the scanning micrograting oscillates outside the resonance. Figure 2b shows the resolution of the integrated angle sensor after going through a differential amplifier with a magnification of 500 and a sixth-order band-pass filter. From the test results, the integrated angle sensor has an effective resolution of 0.01 • . According to Figure 2c, we can see a clear linear relationship between the integrated sensor output voltage and the mechanical half angle of the scanning micrograting. The correlation coefficient r can reach 0.99997. The sensitivity of the integrated sensor can be determined as 0.94769 V p / • . In the working process, the amplitude of the swing of the FR4-based electromagnetic scanning micrograting will change because of the thermal effects and other environmental influences. Thus, the closed-loop control system must be added to ensure the amplitude of the swing of the scanning micrograting constantly. The good resolution and linearity of the integrated sensor provide advantages for a closed-loop control system.

Hardware Design of the System
The hardware of the compound control system consists of a digital signal processor (DSP, TMS320F28335, Texas Instruments, Dallas, TX, USA) as the master chip and the corresponding peripheral circuits. The hardware block diagram of the compound control system is given in Figure  3a. As the block diagram illustrates, the output signal of the integrated angle sensor is sampled and converted to a digital signal related to the scanning angle after going through the differential amplifier, the band-pass filter, and the analog-to-digital converter (ADC, AD7606, Analog Devices, Norwood, MA, USA). In parallel, the amplified output signal of the integrated angle sensor goes through the phase shifting circuit and enters the phase detector simultaneously with the driving signal of the scanning micrograting. The real-time driving current value is obtained after the driving signal goes through the current detection circuit. After receiving the angle sensor signal, the phase difference signal, and the driving current signal, the control values are processed by DSP and transmitted to the direct digital synthesizer (DDS, AD9833, Analog Devices, Norwood, MA, USA) and the digital-to-analog converter (DAC, DAC8563, Texas Instruments, Dallas, TX, USA). The output signals of the DDS and DAC are combined by a four-quadrant multiplier. Then, the composite signal is applied to the scanning micrograting after going through the power amplifier to form a complete closed loop.

Hardware Design of the System
The hardware of the compound control system consists of a digital signal processor (DSP, TMS320F28335, Texas Instruments, Dallas, TX, USA) as the master chip and the corresponding peripheral circuits. The hardware block diagram of the compound control system is given in Figure 3a. As the block diagram illustrates, the output signal of the integrated angle sensor is sampled and converted to a digital signal related to the scanning angle after going through the differential amplifier, the band-pass filter, and the analog-to-digital converter (ADC, AD7606, Analog Devices, Norwood, MA, USA). In parallel, the amplified output signal of the integrated angle sensor goes through the phase shifting circuit and enters the phase detector simultaneously with the driving signal of the scanning micrograting. The real-time driving current value is obtained after the driving signal goes through the current detection circuit. After receiving the angle sensor signal, the phase difference signal, and the driving current signal, the control values are processed by DSP and transmitted to the direct digital synthesizer (DDS, AD9833, Analog Devices, Norwood, MA, USA) and the digital-to-analog converter (DAC, DAC8563, Texas Instruments, Dallas, TX, USA). The output signals of the DDS and DAC are combined by a four-quadrant multiplier. Then, the composite signal is applied to the scanning micrograting after going through the power amplifier to form a complete closed loop. Based on the construction and characteristics of the integrated angle sensor described in Section 2, a dedicated acquisition module for the angle sensor output signal was designed. As shown in Figure 4, the acquisition module consists of a differential instrumentation amplifier (AD8429, Analog Devices, Norwood, MA, USA), a sixth-order Butterworth band-pass filter, and an output buffer. The magnification of the differential instrumentation amplifier can be calculated as: where G R represents the resistance of the resistor connected to the G R pin of the differential instrumentation amplifier. The magnification of the instrumentation amplifier is set to 500 times in this module.  Figure 5 shows the structure of the phase detector circuit and the current detection circuit. According to Figure 5a, the angle sensor signal amplified by the differential instrumentation amplifier shown in Figure 4 first goes through the 90° phase shifter and then enters the phase detector (AD8302, Analog Devices, Norwood, MA, USA) with the driving signal of the scanning micrograting. An active low-pass filter is used in the last stage of the circuit in order to eliminate the alternating Based on the construction and characteristics of the integrated angle sensor described in Section 2, a dedicated acquisition module for the angle sensor output signal was designed. As shown in Figure 4, the acquisition module consists of a differential instrumentation amplifier (AD8429, Analog Devices, Norwood, MA, USA), a sixth-order Butterworth band-pass filter, and an output buffer. The magnification of the differential instrumentation amplifier can be calculated as: where R G represents the resistance of the resistor connected to the R G pin of the differential instrumentation amplifier. The magnification of the instrumentation amplifier is set to 500 times in this module.  Based on the construction and characteristics of the integrated angle sensor described in Section 2, a dedicated acquisition module for the angle sensor output signal was designed. As shown in Figure 4, the acquisition module consists of a differential instrumentation amplifier (AD8429, Analog Devices, Norwood, MA, USA), a sixth-order Butterworth band-pass filter, and an output buffer. The magnification of the differential instrumentation amplifier can be calculated as: where G R represents the resistance of the resistor connected to the G R pin of the differential instrumentation amplifier. The magnification of the instrumentation amplifier is set to 500 times in this module.  Figure 5 shows the structure of the phase detector circuit and the current detection circuit. According to Figure 5a, the angle sensor signal amplified by the differential instrumentation amplifier shown in Figure 4 first goes through the 90° phase shifter and then enters the phase detector (AD8302, Analog Devices, Norwood, MA, USA) with the driving signal of the scanning micrograting. An active low-pass filter is used in the last stage of the circuit in order to eliminate the alternating  low-pass filter is used in the last stage of the circuit in order to eliminate the alternating current (AC) component in the output signal of the phase detector. The accuracy of the phase detector (AD8302) is 1 • . In the current detection circuit shown in Figure 5b, the driving current signal of the scanning micrograting is converted into a voltage signal by a power metal film resistor with a resistance of 0.01 Ω. Then, the weak voltage signal is amplified to a detectable value by the differential instrumentation amplifier with a magnification of 1000. An active low pass filter is used in order to eliminate high-frequency interference in the amplified signal.  Figure 5b, the driving current signal of the scanning micrograting is converted into a voltage signal by a power metal film resistor with a resistance of 0.01 Ω . Then, the weak voltage signal is amplified to a detectable value by the differential instrumentation amplifier with a magnification of 1000. An active low pass filter is used in order to eliminate high-frequency interference in the amplified signal.  Figure 3b shows the photograph of the control circuit board. The power module on the circuit board consisting of the direct-current to direct-current (DC-DC) converter chips and the low dropout regulator (LDO) chips is designed to meet the power requirements of different chips on the control circuit board. The DSP runs the control algorithm to determine the frequency transmitted to the DDS and the amplitude value transmitted to the DAC after the signal of the integrated angle sensor, the signal of the driving current, and the signal of the phase difference are acquired by the ADC.

Control Algorithm Design of the System
The compound control algorithm of the system consists of the frequency modulation algorithm and the amplitude modulation algorithm. The purpose of the frequency modulation algorithm is to track the resonant frequency of the scanning micrograting after the amplitude control fails. Thus, the long-term stability of the system is improved by adding the frequency modulation algorithm. The steady-state error of the scanning angle is controlled within a controllable range through the precise control of the scanning micrograting by the amplitude modulation algorithm.
The block diagram of the compound control algorithm is shown in Figure 6. From Figure 6, the driving frequency of the scanning grating is controlled by the frequency controller, and the amplitude of the driving signal is controlled by the amplitude controller. The frequency controller determines whether the scanning micrograting is in the resonance state by comparing the set phase difference ( P ) with the actual phase difference output from the phase detector, as shown in Figure 5a. The amplified angle sensor signal is phase shifted by 90° before entering the phase detector, so that the scanning micrograting can be considered to be in resonance when the phase difference between the driving signal and the angle sensor signal is 90°. From Figure 2a, the scanning micrograting can be considered to be in resonance when the phase difference between the angle sensor signal and the driving signal is within the range of 5 ±°. Thus, when the error ( p E ) between the output of the phase detector and the set 90° phase difference ( P ) is within the range of 5 ±°, the frequency controller maintains the original output frequency. The frequency controller considers that the scanning  Figure 3b shows the photograph of the control circuit board. The power module on the circuit board consisting of the direct-current to direct-current (DC-DC) converter chips and the low dropout regulator (LDO) chips is designed to meet the power requirements of different chips on the control circuit board. The DSP runs the control algorithm to determine the frequency transmitted to the DDS and the amplitude value transmitted to the DAC after the signal of the integrated angle sensor, the signal of the driving current, and the signal of the phase difference are acquired by the ADC.

Control Algorithm Design of the System
The compound control algorithm of the system consists of the frequency modulation algorithm and the amplitude modulation algorithm. The purpose of the frequency modulation algorithm is to track the resonant frequency of the scanning micrograting after the amplitude control fails. Thus, the long-term stability of the system is improved by adding the frequency modulation algorithm. The steady-state error of the scanning angle is controlled within a controllable range through the precise control of the scanning micrograting by the amplitude modulation algorithm.
The block diagram of the compound control algorithm is shown in Figure 6. From Figure 6, the driving frequency of the scanning grating is controlled by the frequency controller, and the amplitude of the driving signal is controlled by the amplitude controller. The frequency controller determines whether the scanning micrograting is in the resonance state by comparing the set phase difference (P) with the actual phase difference output from the phase detector, as shown in Figure 5a. The amplified angle sensor signal is phase shifted by 90 • before entering the phase detector, so that the scanning micrograting can be considered to be in resonance when the phase difference between the driving signal and the angle sensor signal is 90 • . From Figure 2a, the scanning micrograting can be considered to be in resonance when the phase difference between the angle sensor signal and the driving signal is within the range of ±5 • . Thus, when the error (E p ) between the output of the phase detector and the set 90 • phase difference (P) is within the range of ±5 • , the frequency controller maintains the original output frequency. The frequency controller considers that the scanning micrograting is far from the resonant state and starts to work when the error value exceeds ±5 • and the amplitude controller fails. The frequency controller first increases the output frequency in steps of 0.1 Hz and then determines whether the error E p has decreased after the frequency increases. If the error E p is not decreased, it means that the direction of adjustment is wrong, in which case, the frequency controller reduces the output frequency in steps of 0.1 Hz until the error returns to the range of ±5 • . The number of adjustments is grouped five times. At the third time, the controller will judge whether the adjustment direction is correct by judging whether the error E p is decreased. The frequency controller will adjust in the opposite direction immediately if the adjustment direction is wrong. micrograting is far from the resonant state and starts to work when the error value exceeds 5 ±° and the amplitude controller fails. The frequency controller first increases the output frequency in steps of 0.1 Hz and then determines whether the error p E has decreased after the frequency increases. If the error p E is not decreased, it means that the direction of adjustment is wrong, in which case, the frequency controller reduces the output frequency in steps of 0.1 Hz until the error returns to the range of 5 ±°. The number of adjustments is grouped five times. At the third time, the controller will judge whether the adjustment direction is correct by judging whether the error p E is decreased. The frequency controller will adjust in the opposite direction immediately if the adjustment direction is wrong. A dual closed-loop structure was designed in the amplitude controller to enhance the stability of the compound control system. The inner loop of the amplitude controller is the current loop. The running of the current loop was based on the error between the actual driving current obtained by the circuit shown in Figure 5b and the control value of the outer loop. In this way, the inner loop is enhanced in response to the control input from the outer loop. In addition, the current loop also monitors the driving current in real time to prevent the driving current from being too strong and damaging the scanning micrograting. The outer loop is the angle loop, which is the main channel for the angle feedback control of the scanning micrograting. Overshoot should not occur in the inner and outer loop in order to improve the stability and smoothness of the compound control system. From Figure 6, the driving current signal is sampled by the ADC after going through the current detection circuit, and then obtained by going through the moving average filter. The incremental proportional-integral-derivative (PID) control algorithm was designed in the current loop. The PID is a linear controller that runs based on the error e between the output of the angle loop and the actual driving current. The output of the continuous PID control algorithm can be expressed by the following equation: where PI K , (t) e , I T , and D T represent the proportion coefficient, the error, the integration time constant, and the differential time constant, respectively. In the compound control system, the input and output of the DSP are both digital signals. The discretization of the algorithm can be expressed as: A dual closed-loop structure was designed in the amplitude controller to enhance the stability of the compound control system. The inner loop of the amplitude controller is the current loop. The running of the current loop was based on the error between the actual driving current obtained by the circuit shown in Figure 5b and the control value of the outer loop. In this way, the inner loop is enhanced in response to the control input from the outer loop. In addition, the current loop also monitors the driving current in real time to prevent the driving current from being too strong and damaging the scanning micrograting. The outer loop is the angle loop, which is the main channel for the angle feedback control of the scanning micrograting. Overshoot should not occur in the inner and outer loop in order to improve the stability and smoothness of the compound control system. From Figure 6, the driving current signal is sampled by the ADC after going through the current detection circuit, and then obtained by going through the moving average filter. The incremental proportional-integral-derivative (PID) control algorithm was designed in the current loop. The PID is a linear controller that runs based on the error e between the output of the angle loop and the actual driving current. The output of the continuous PID control algorithm can be expressed by the following equation: where K PI , e(t), T I , and T D represent the proportion coefficient, the error, the integration time constant, and the differential time constant, respectively.
In the compound control system, the input and output of the DSP are both digital signals. The discretization of the algorithm can be expressed as: where T, k, e(k), and e(k − 1) represent the sampling period, the sampling number, the current error at the time instant k, and the current error at the at the previous time instant k, respectively. If e(kT) is simplified and represented as e(k), the digital PID control algorithm can be expressed as: where K II = K PI T T I and K DI = K PI T D T represent the integration coefficient and the differential coefficient of the digital PID control algorithm in the current loop, respectively. Equation (14) is the positional PID control algorithm. The incremental PID control algorithm is used in the current loop to solve the problem of integral saturation, large adjustment jitter, and large memory usage of the positional PID control algorithm. The output of the positional PID control algorithm at the moment before can be calculated from Equation (14): Then, the incremental PID control algorithm can be expressed as: The motion of the scanning micrograting is nonlinear due to environmental changes and external disturbances. Thus, the fuzzy-PID control algorithm is used in the angle loop in order to improve the anti-interference ability, robustness, and long-term stability of the compound control system. From Figure 6, the inputs of the fuzzy controller are the error E between the set scanning angle and the actual scanning angle and the variation of the error E c . The outputs of the fuzzy controller are the correction quantities (∆K p , ∆K i , ∆K d ) of the incremental PID control algorithm in the angle loop. Thus, the coefficients of the incremental PID control algorithm are determined by the following equation: where K P , K I , K D , K P0 , K I0 , and K D0 represent the coefficients of the incremental PID control algorithm used in the angle loop and the initial coefficients obtained by the experiments. Thus, a two-input and three-output fuzzy controller is used in the angle loop. The actual variation range of the error E and the variation of the error E c is [−0.05 • , 0. Therefore, the domain transformation can be expressed as: where ε, ε, n, a, and b represent the fuzzy variable, the input variable, the length of the basic domain, and the minimum and maximum values of the actual range, respectively. The triangular membership function is designed in the fuzzy controller because of its high computational accuracy, simple form, and high computational efficiency. The triangular membership function can be expressed as: where m, n, and p represent the distribution parameters of the triangular membership function. The weighted average method was used in the defuzzification of the fuzzy controller due to its wide adaptability, smooth and stable output, and high flexibility. The weighted average method can be expressed by the following equation: where y i and µ C i (y i ) represent the centroid of the membership function and the output value of the membership function. The rules of the fuzzy controller obtained from the actual motion of the scanning micrograting are listed in Table 2. The fuzzy controller will adjust the coefficients (K P , K I , and K D ) of the incremental PID control algorithm in real time during the operation of the compound control system. Thus, the adaptive ability of the control system is enhanced.  Figure 7a shows the schematic drawing of the measurement setup of the compound control system. The scan angle is controlled by the control circuit and can be calculated according to the length of the laser scan line and the distance between the optical screen and the scanning micrograting. The length of the laser scan line can be measured accurately using a position-sensitive detector (PSD). The digital multimeter is used to accurately measure the driving current. The signal generator is used for the open-loop test of the scanning micrograting and generating the interference signal. The photograph of the measurement setup is shown in Figure 7b. system. The scan angle is controlled by the control circuit and can be calculated according to the length of the laser scan line and the distance between the optical screen and the scanning micrograting. The length of the laser scan line can be measured accurately using a position-sensitive detector (PSD). The digital multimeter is used to accurately measure the driving current. The signal generator is used for the open-loop test of the scanning micrograting and generating the interference signal. The photograph of the measurement setup is shown in Figure 7b.  Figure 8 shows the test results of the acquisition module for the angle sensor output signal. In order to simulate the use of the scanning micrograting in the micro-NIR spectrometer [8], the mechanical half angle of the scanning micrograting is set to 4.1°, and the driving frequency is set at the resonant frequency (282.3 Hz). From Figure 8a, the phase difference between the driving signal and the output signal of the integrated angle sensor amplified 500 times is 2.5°, and the amplitude of the amplified sensor signal reaches an intensity that can be detected by the oscilloscope and the ADC. The SNR of the sensor signal after going through the module is shown in Figure 8b. The SNR of the sensor signal is 77.69 dB, which is strong for the compound control system.    Figure 8 shows the test results of the acquisition module for the angle sensor output signal. In order to simulate the use of the scanning micrograting in the micro-NIR spectrometer [8], the mechanical half angle of the scanning micrograting is set to 4.1 • , and the driving frequency is set at the resonant frequency (282.3 Hz). From Figure 8a, the phase difference between the driving signal and the output signal of the integrated angle sensor amplified 500 times is 2.5 • , and the amplitude of the amplified sensor signal reaches an intensity that can be detected by the oscilloscope and the ADC. The SNR of the sensor signal after going through the module is shown in Figure 8b. The SNR of the sensor signal is 77.69 dB, which is strong for the compound control system. system. The scan angle is controlled by the control circuit and can be calculated according to the length of the laser scan line and the distance between the optical screen and the scanning micrograting. The length of the laser scan line can be measured accurately using a position-sensitive detector (PSD). The digital multimeter is used to accurately measure the driving current. The signal generator is used for the open-loop test of the scanning micrograting and generating the interference signal. The photograph of the measurement setup is shown in Figure 7b.  Figure 8 shows the test results of the acquisition module for the angle sensor output signal. In order to simulate the use of the scanning micrograting in the micro-NIR spectrometer [8], the mechanical half angle of the scanning micrograting is set to 4.1°, and the driving frequency is set at the resonant frequency (282.3 Hz). From Figure 8a, the phase difference between the driving signal and the output signal of the integrated angle sensor amplified 500 times is 2.5°, and the amplitude of the amplified sensor signal reaches an intensity that can be detected by the oscilloscope and the ADC. The SNR of the sensor signal after going through the module is shown in Figure 8b. The SNR of the sensor signal is 77.69 dB, which is strong for the compound control system.     Figure 9, when the mechanical half angle is set to 4.1 • , the 90% rise time of the scanning micrograting is 192 ms, and the steady-state error is 1.122%; however, there is an overshoot of 2.23%. 90% rise time of the scanning micrograting is 192 ms, and the steady-state error is 1.122%; however, there is an overshoot of 2.23%. The test results of the frequency modulation algorithm are shown in Figure 10. During the test process, the amplitude of the drive signal is kept constant. Figure 10a shows the adjustment process of the frequency modulation algorithm when the initial driving frequency is lower than the resonant frequency of the scanning micrograting. From Figure 10a, the frequency is increased in steps of 0.1 Hz until the phase difference between the driving signal and the phase-shifted sensor signal is in the range of [85°, 95°]. Figure 10b shows the adjustment process of the frequency modulation algorithm when the initial driving frequency is higher than the resonant frequency. The control system initially increases the driving frequency. At the third time, the system determines that the adjustment direction is incorrect, so the system reduces the driving frequency until the phase difference returns to the correct range. As the test results show in Figure 10, the frequency modulation algorithm can effectively track the actual resonant frequency of the scanning micrograting with a tracking accuracy of 0.1 Hz. Therefore, the amplitude controller can work effectively and improve the long-term stability of the compound control system. Figure 10. Test results of the frequency modulation algorithm. (a) Initial frequency is lower than the resonant frequency; (b) initial frequency is higher than the resonant frequency. The test results of the frequency modulation algorithm are shown in Figure 10. During the test process, the amplitude of the drive signal is kept constant. Figure 10a shows the adjustment process of the frequency modulation algorithm when the initial driving frequency is lower than the resonant frequency of the scanning micrograting. From Figure 10a, the frequency is increased in steps of 0.1 Hz until the phase difference between the driving signal and the phase-shifted sensor signal is in the range of [85 • , 95 • ]. Figure 10b shows the adjustment process of the frequency modulation algorithm when the initial driving frequency is higher than the resonant frequency. The control system initially increases the driving frequency. At the third time, the system determines that the adjustment direction is incorrect, so the system reduces the driving frequency until the phase difference returns to the correct range. As the test results show in Figure 10, the frequency modulation algorithm can effectively track the actual resonant frequency of the scanning micrograting with a tracking accuracy of 0.1 Hz. Therefore, the amplitude controller can work effectively and improve the long-term stability of the compound control system. 90% rise time of the scanning micrograting is 192 ms, and the steady-state error is 1.122%; however, there is an overshoot of 2.23%. The test results of the frequency modulation algorithm are shown in Figure 10. During the test process, the amplitude of the drive signal is kept constant. Figure 10a shows the adjustment process of the frequency modulation algorithm when the initial driving frequency is lower than the resonant frequency of the scanning micrograting. From Figure 10a, the frequency is increased in steps of 0.1 Hz until the phase difference between the driving signal and the phase-shifted sensor signal is in the range of [85°, 95°]. Figure 10b shows the adjustment process of the frequency modulation algorithm when the initial driving frequency is higher than the resonant frequency. The control system initially increases the driving frequency. At the third time, the system determines that the adjustment direction is incorrect, so the system reduces the driving frequency until the phase difference returns to the correct range. As the test results show in Figure 10, the frequency modulation algorithm can effectively track the actual resonant frequency of the scanning micrograting with a tracking accuracy of 0.1 Hz. Therefore, the amplitude controller can work effectively and improve the long-term stability of the compound control system.   Section 3.2, the fuzzy controller starts to work when the error E and the variation of the error E c enter the design range. Therefore, the correction quantities are always 0 before E and E c entering the range. From Figure 11, the correction quantities are constantly changing while the compound control system is in operation. The range of variation of ∆K p is [−0.0039, 0.0041], the range of ∆K i is [−0.00095, 0.00067], and the range of ∆K d is [−0.0098, 0.0066]. The trend in the variation of the correction quantities is the same as the design, which indicates that the fuzzy controller can adjust the correction quantities in real time according to the motion of the scanning micrograting. of the fuzzy controller during the operation of the compound control system. According to the design in Section 3.2, the fuzzy controller starts to work when the error E and the variation of the error c E enter the design range. Therefore, the correction quantities are always 0 before E and c E entering the range. From Figure 11, the correction quantities are constantly changing while the compound control system is in operation. The range of variation of  The step response test results of the compound control system when the target mechanical half angle is set to 2.1°, 3.1°, and 4.1° are shown in Figure 12a correspondingly. From the test results, the 90% rise time of the compound control system is less than 781 ms. The steady-state error of the compound control system is better than 0.243% when the mechanical half angle is 4.1°. Figure 12b shows the step response of the scanning micrograting under different conditions. From Figure 12b, the compound control system eliminates the overshoot of the scanning micrograting. When the target mechanical half angle is set to 4.1°, the steady-state error of the compound control system is significantly lower than that of the open loop, and the control system only uses an incremental PID control algorithm in the angle loop. The single loop control system uses the same PID coefficients (  The step response test results of the compound control system when the target mechanical half angle is set to 2.1 • , 3.1 • , and 4.1 • are shown in Figure 12a correspondingly. From the test results, the 90% rise time of the compound control system is less than 781 ms. The steady-state error of the compound control system is better than 0.243% when the mechanical half angle is 4.1 • . Figure 12b shows the step response of the scanning micrograting under different conditions. From Figure 12b, the compound control system eliminates the overshoot of the scanning micrograting. When the target mechanical half angle is set to 4.1 • , the steady-state error of the compound control system is significantly lower than that of the open loop, and the control system only uses an incremental PID control algorithm in the angle loop. The single loop control system uses the same PID coefficients (K P = 0.015, K I = 0.0095, K D = 0.025) as the angle loop in the compound control system. The scanning stability of the scanning micrograting has been significantly improved, and the steady-state error has been reduced from 1.122% to 0.243% compared to the open-loop system.  Figure 13 shows the result of the control accuracy test of the compound control system. The mechanical half angle of the scanning micrograting is increased in steps of 0.02° by the compound control system, and the actual mechanical half angle is obtained by the PSD. The mechanical half angle resolution of the test system shown in Figure 7b is 0.001°. From Figure 13, the control accuracy of the compound control system can effectively reach 0.02°. In order to test the anti-interference ability of the compound control system, a reverse pulse generated by the signal generator was applied to the control system. Figure 14 shows the comparison of the recovery time with different systems after an equal amplitude pulse interference. From Figure  14, the recovery time of the scanning micrograting is reduced from 550 ms without closed-loop control to 181 ms with the compound control system, and the overshoot is reduced by 11.68% compared to the single-loop incremental PID control.  Figure 13 shows the result of the control accuracy test of the compound control system. The mechanical half angle of the scanning micrograting is increased in steps of 0.02 • by the compound control system, and the actual mechanical half angle is obtained by the PSD. The mechanical half angle resolution of the test system shown in Figure 7b is 0.001 • . From Figure 13, the control accuracy of the compound control system can effectively reach 0.02 • .  Figure 13 shows the result of the control accuracy test of the compound control system. The mechanical half angle of the scanning micrograting is increased in steps of 0.02° by the compound control system, and the actual mechanical half angle is obtained by the PSD. The mechanical half angle resolution of the test system shown in Figure 7b is 0.001°. From Figure 13, the control accuracy of the compound control system can effectively reach 0.02°. In order to test the anti-interference ability of the compound control system, a reverse pulse generated by the signal generator was applied to the control system. Figure 14 shows the comparison of the recovery time with different systems after an equal amplitude pulse interference. From Figure  14, the recovery time of the scanning micrograting is reduced from 550 ms without closed-loop control to 181 ms with the compound control system, and the overshoot is reduced by 11.68% compared to the single-loop incremental PID control. In order to test the anti-interference ability of the compound control system, a reverse pulse generated by the signal generator was applied to the control system. Figure 14 shows the comparison of the recovery time with different systems after an equal amplitude pulse interference. From Figure 14, the recovery time of the scanning micrograting is reduced from 550 ms without closed-loop control to 181 ms with the compound control system, and the overshoot is reduced by 11.68% compared to the single-loop incremental PID control. Finally, long-term stability tests were operated continuously for 14 h. The experiment was repeated using different control systems, including an open-loop condition. Figure 15 shows the test results. The maximum variations of the mechanical half angle were 0.12%, 0.99%, and 2.94%, respectively. Based on the results given in Figure 15, the long-term stability of the scanning micrograting was significantly enhanced due to the addition of closed-loop control systems. The fuzzy controller in the amplitude modulation algorithm can adaptively adjust the correction quantities according to the environment, and this together with the double closed-loop structure used in the amplitude modulation algorithm and the addition of the frequency modulation algorithm all significantly enhance the long-term stability of the scanning micrograting.

Conclusions
In this work, a compound control system was proposed to realize the precise control of the FR4based electromagnetic scanning micrograting. The hardware circuit and control algorithm of the compound control system were designed and discussed. The compound control system consists of a frequency controller and an angle controller. A frequency controller that can track the real-time resonant frequency of the FR4-based electromagnetic scanning micrograting is proposed. A dual Finally, long-term stability tests were operated continuously for 14 h. The experiment was repeated using different control systems, including an open-loop condition. Figure 15 shows the test results. The maximum variations of the mechanical half angle were 0.12%, 0.99%, and 2.94%, respectively. Based on the results given in Figure 15, the long-term stability of the scanning micrograting was significantly enhanced due to the addition of closed-loop control systems. The fuzzy controller in the amplitude modulation algorithm can adaptively adjust the correction quantities according to the environment, and this together with the double closed-loop structure used in the amplitude modulation algorithm and the addition of the frequency modulation algorithm all significantly enhance the long-term stability of the scanning micrograting. Finally, long-term stability tests were operated continuously for 14 h. The experiment was repeated using different control systems, including an open-loop condition. Figure 15 shows the test results. The maximum variations of the mechanical half angle were 0.12%, 0.99%, and 2.94%, respectively. Based on the results given in Figure 15, the long-term stability of the scanning micrograting was significantly enhanced due to the addition of closed-loop control systems. The fuzzy controller in the amplitude modulation algorithm can adaptively adjust the correction quantities according to the environment, and this together with the double closed-loop structure used in the amplitude modulation algorithm and the addition of the frequency modulation algorithm all significantly enhance the long-term stability of the scanning micrograting.

Conclusions
In this work, a compound control system was proposed to realize the precise control of the FR4based electromagnetic scanning micrograting. The hardware circuit and control algorithm of the compound control system were designed and discussed. The compound control system consists of a frequency controller and an angle controller. A frequency controller that can track the real-time resonant frequency of the FR4-based electromagnetic scanning micrograting is proposed. A dual

Conclusions
In this work, a compound control system was proposed to realize the precise control of the FR4-based electromagnetic scanning micrograting. The hardware circuit and control algorithm of the compound control system were designed and discussed. The compound control system consists of a frequency controller and an angle controller. A frequency controller that can track the real-time resonant frequency of the FR4-based electromagnetic scanning micrograting is proposed. A dual closed-loop structure consisting of a current loop and an angle loop was designed in the angle controller. The experimental results showed that the compound control system can effectively track the real-time resonant frequency of the scanning micrograting. By using the compound control system presented, the overshoot of the scanning micrograting is eliminated. The steady-state error is reduced from 1.122% to 0.243% when the mechanical half angle is set to 4.1 • . In addition, the control accuracy of the compound control system is also tested. The control accuracy of the compound control system can reach 0.02 • . The anti-interference recovery time is reduced from 550 ms to 181 ms. The long-term stability is also increased from 2.94% to 0.12% with the help of the presented compound control system. According to the experimental results, the compound control system has significantly improved the motion accuracy, long-term stability, and anti-interference ability of the FR4-based electromagnetic scanning micrograting, which greatly increases its potential for use as an alternative for a silicon-based MEMS scanning micrograting.
Author Contributions: F.Y., Q.W., and Z.W. designed the hardware and control algorithms of the compound control system. H.L. studied the motion mechanism of the scanning micrograting and the characteristics of the integrated angle sensor. Z.W. provided advice on the design of the compound control system. F.Y., H.L. and L.H. tested the system and analyzed the test data. F.Y. and Q.W. wrote and revised the paper respectively.