Laser Beam Jitter Control Based on a LabVIEW FPGA Control System

: The thermal blooming effect, platform jitter, and other effects of laser beam propagation cause serious deviation, which will have a negative impact on laser tracking systems. It is important to ensure that the laser beam does not deviate. Based on a fast steering mirror, a CMOS camera, and a Flex RIO system, a laser beam jitter control system is designed and implemented. The error is detected by camera and compensated for by the fast steering mirror (FSM), which is controlled by the Flex RIO device. By using LabVIEW and MATLAB, a closed loop model is realized. The results show that the system response is highly stabilized and has a short rise time, providing a reference for engineering applications.


Introduction
A series of propagation effects, such as the thermal blooming effect and platform jitter, will cause a negative impact on laser tracking systems, for example, high energy laser propagation [1], free-space optical communications [2,3], photolithography [4], and so on. Many works have described laser beam jitter implementation to combat these impacts but it remains a challenging task, especially under complex imaging environments.
In the past decade, researchers have generally focused on the method of using different algorithms or improving the mechanical structure in order to improve the accuracy of the control system [5]. In 2014, B. Canuel et al. [6] developed a beam-pointing control system for a large-scale gravitational wave interferometer and demonstrated its effectiveness through experiments. The results showed that the system could achieve tilt and shift corrections below 10 Hz, with 10 −8 rad and a shift control accuracy of 10 −7 m. The system uses a two-quadrant photodiode for beam tilt and shift detection and employs two piezoelectric actuators to drive the correction of the tilt mirror. In 2017, X. Zijun et al. [7] used a Michelson interferometer to precisely detect the optical angle error and compensated for it by using an FSM. Based on that, an electro-optical pointing system was presented, giving good accuracy. However, its structure needs to be implemented in engineering, and the Michelson interferometer limits the system's performance due to matrix computing. In 2019, N'Doye et al. [8] presented an improved PID controller algorithm based on an ultralocal model, named i-PID controller. This model is suited for implementation as it does not require an accurate model of the system; however, it may not be suitable for all systems and may require further modifications for nonlinear or highly disturbed systems. In 2019, Wei Zhu and Xiaoting Rui [9] realized the single-valued liner input-output relationship, which simplifies and convergence rate of the adaptive filter algorithm. The error is detected by a position sensing detector (PSD) then an adaptive lattice recursive least square filter controller is built to compensate for the error. The use of adaptive control methods can be complex and may require a significant amount of computation, which could be a drawback in some real-time applications. Furthermore, in 2020, H. Turan andŞ. N. Engınuses [10] used the PID controller to calculate the coefficients by solving the Riccati equation of a linear quadratic regulator (LQR). In 2021, S. H and A. B. R. A [11] designed an adaptive fuzzy logic controller in a field programmable gate array (FPAG) as a closed loop control configuration for mitigating the beam jitter.
Based on the above research, we can summarize that a laser beam jitter control system typically features complex configurations and a PSD is a widely used method for detecting the tilts. However, its sensitivity to environmental light and its limitations imposed by the data length of the analog-to-digital converter equipment limit its effectiveness. We propose a laser beam control implementation consisting of a CMOS camera, FSM, and a Flex RIO embedded control and acquisition system. We use an image-processing-based laser spot acquisition scheme, where both CMOS and CCD cameras can be used as detection elements to acquire spot images and thus calculate the spot position information. The image generation methods in CMOS and CCD cameras differ, as CMOS enlarges each pixel individually, while CCD enlarges the raw data of all pixels at a common endpoint. The difference results in a higher image quality in CCD cameras and a better definition in CMOS cameras. However, CMOS cameras are more cost-effective and have lower power consumption than CCD cameras. Therefore, we prefer CMOS cameras for industrial applications with high real-time processing requirements. The system as a whole exhibits outstanding robustness, stability, and a high level of integration density. Flex RIO is a reconfigurable embedded control and acquisition system, its elements are as follows: 1.
The controller is embedded running in LabVIEW Real-Time for control, data acquisition, and analysis; 2.
The industrial I/O modules contain built-in signal conditioning and isolation; 3.
The chassis contains the input-output modules, which are modules and a controller, and a high-performance FPGA chip.
Specialists have the capability to design, program, test, and customize the Flex RIO system through the National Instruments Flex RIO using LabVIEW FPGA and LabVIEW Real-Time software. The ease of graphical programming provided by these tools allows for a seamless connection between the FPGA chip and the I/O modules via the controller [12].

Proposed Solution
This paper presents a proposed application that demonstrates the principle of closedloop control of the FSM using the Flex RIO system. For our proposed application, we selected the following hardware configuration: a CMOS camera is used as the laser position detector by capturing the laser image; a FPGA (PXIe-7962R) chip processes the laser image and its centroid; an analogue signal output module (PXI-6723) is used to transmit the control signal to the FSM driver; and a data acquisition module (PXIe-5122) is utilized to acquire the voltage of the FSM driver. The compact embedded chassis (PXIe-1092) and the controller (PXIe-8861) provide a control system and connect the onboard modules. The voice coil motor FSM compensates for the tilts of the laser beam.
The CMOS camera serves as the acquisition device, capturing the laser spot image and transmitting it to the Flex RIO system. The image processing program includes the image filter, display, and calculation of the centroid. Except for the image processing program, the design of the FSM control module and the creation of the analog signal are accomplished within the Flex RIO system.
The image algorithm could be widely implemented, including on digital signal processors (DSP) [13], central processing units (CPU) [14], graphic processing units (GPU) [15], and field programmable gate arrays (FPGA) [16,17]. Typically, the system onboard chip (SoC) structure is complex and challenging to exploit or maintain. This study aims to propose a Flex RIO system solution to implement a laser beam jitter control system that is highly integrated. In addition, LabVIEW is far more convenient than C or VHDL programming languages. The components of our control system are shown in Figure 1a, while Figure 1b describes the data transformation design within the control system. Once the camera captures an image of the laser spot, the image is processed by the FPGA and the coordinate of the laser spot centroid is calculated. The program receives this coordinate in the host and then calculates the horizontal axis and vertical axis position voltages. Then, the voltage will be the process variables submitted to the LabVIEW PID controller, which can calculate the error between the destination variable and the process variable and output a control voltage to the analog signal generation module to control the FSM and restrain the laser beam jitter.
The voice coil motor operates based on an RC circuit, its circuit equilibrium and counter-electromotive equations are presented as follows: where U a is the two-terminal voltage of armature of the voice coil motor; R a is the armature circuit resistance of the voice coil motor; I a is the armature loop current of the voice coil motor; L a is the armature loop inductance of the voice coil motor; U e is the back electromotive force; and K b is the back EMF coefficient of the voice coil motor. The equilibrium of moments equation of the voice coil motor and its loading is shown as follows: where M is the motor output torque; C m is the equivalent viscous friction coefficient of the motor; I a is the armature loop current of the voice coil motor; M J is the motor rotational torque; J is the total moment of inertia; M F is the mechanical damper torque; and f is the viscous friction coefficient. θ is the angle of deflection; M K is the elastic torque of the spring; K is the equivalent spring stiffness coefficient from the motor end to the load end; and θ a is the mirror angular displacement.
The transfer function of the FSM can be obtained by the inverse Laplace transform of Equations (1) and (2) .
where T e is the time constant; w n is the system natural frequency; ξ is the damping ratio of the system; k is the open loop gain; and τ is the time delay constant. The transfer function of the FSM is comprised of a first-order inertial component and a second-order oscillatory component. It also contains a delayed link due to the sampling and processing delay of the sensor and other components.

Image Processing
Image processing is an integral part of the control system. To enable subsequent image processing, the host must transfer pre-processed images to the FPGA, which will then return completed spot images with their center of mass coordinates to the host. Communication between the host and the FPGA board is a crucial aspect of system design. Due to the large image data volume, the image resolution being 320*240 @30 fps, and the pixel depth being 8 bit, the host must send 18.432 Mbps of image data to the FPGA per second. We have utilized the DMA FIFO (Direct Memory Access First In First Out, DMA FIFO) to facilitate the transmission of images between the FPGA and the host in this study. The FIFO memory is a dual-port cache that functions on a first-in-first-out basis, with one port acting as the input and the other as the output. The FIFO mechanism allows for communication of data within the FPGA, between individual FPGA modules, and between the FPGA module and the host controller. Due to the need for direct access to the FIFO, the communication between the host controller and the FPGA is referred to as DMA FIFO. The system's image processing is divided into two parts: preprocessing of the host computer and the related processing and calculation on the FPGA side. The specific process is shown in Figure 2. The Flex RIO system provides a very convenient platform for connecting various modules. The corresponding functions can be realized through the selection of onboard modules, and the communication between them can be facilitated through the use of the embedded control chassis (PXIe-1092), significantly simplifying the design process of the system. The laser spot center of gravity algorithm, known for its ease of deployment and high accuracy, is widely used in industry. However, it is sensitive to the values of pixels outside the peak in grayscale images and requires pre-processing of the spot image for optimal results. Image acquisition and transmission are shown in Figure 3a below. Initially, the open camera.vi in LabVIEW's Vision and Motion is used to select the camera and retrieve its image properties, which are then transmitted to the FPGA. Next, the camera is opened through its index to capture the spot image. The captured U32 RGB image is then converted to a U32 HSL image. This process requires substantial RAM resources; thus, it is performed on the HOST side. The pre-processing procedure is shown in Figure 3a. Then, the brightness of the U32 HSL image is extracted and the grayscale image in U8 format is obtained after processing. Finally, the U8 image is sent to the FPGA module to use the rich digital operation module of the FPGA chip for subsequent image processing operations.
After receiving the image from the FIFO, the FPGA terminal performs image processing, including filtering out stray light and extracting the complete spot, followed by a center-ofmass operation. The calculated spot center-of-mass is then sent back to the host for subsequent control. The accuracy of the center-of-mass calculation is critical to the beam position information measurement task, and directly affects the accuracy of the beam control system. The laser light is a Gaussian beam, and the light intensity distribution follows a Gaussian curve. Therefore, Gaussian filtering of the spot image improves the accuracy of the center-of-mass calculation. After retrieving the pixel data and the number of rows from the FIFO, the image undergoes several processing steps, including binarization to filter out obvious stray light by selecting a higher threshold due to the large grayscale difference between the spot and ambient light. Format conversion is then performed to convert the pixel values of the binarized image into grayscale values in the U8 format for subsequent pixel processing. The image is then subjected to low-pass filtering to remove high-brightness noise and Gaussian filtering to restore the complete spot. Finally, the spot quality center is calculated, resulting in the final calculation and output of the spot center of mass.
At the same time, the host side filters stray light interference through a preliminary coarse adjustment using a threshold, and the host side can observe the effect of threshold adjustment. Figure 3b shows the main program of image processing. An essential advan-tage of LabVIEW FPGA is using integrated IP core libraries for image processing. LabVIEW FPGA can encapsulate reusable modules written in C, assembly language, etc., in vi format and store them in the corresponding libraries. The program is mainly concerned with the design of the DMA FIFO and the related image processing sub-vi programs. The image processing process is as follows: 1.
The image is binarized and then low-pass filtered to remove high-frequency noise.

2.
The laser spot is extracted in its entirety by Gaussian filtering, where the template used for Gaussian filtering is G = 1 16   1 2 1 2 4 2 1 2 1   .

3.
The laser spot is filtered and denoised, and the centroid of the light spot, that is, the gray center of gravity of the light spot, is calculated as follows: In Equation (4), X centroid and Y centroid are the horizontal and vertical center-of-mass coordinates of the laser spot image, respectively. I(i,j) is the grayscale value of the current coordinate.

System Identification
System modeling is critical to the design of control systems, and, in general, there are ways to model control systems based on physical laws and system identification. However, many uncertainties in the system's structure, such as time-varying and nonlinear parameters of higher-order systems, make it challenging to model systems based on physical laws. The mathematical modeling of dynamical systems with complex structures is complicated. In particular, the mathematical modeling of complex dynamic systems by means of physical laws is undoubtedly difficult and time-consuming. MATLAB software's System Identification Toolbox can determine the system parameters by inputting the input and output data of the present system, resulting in the acquisition of the system's transfer function and state equation. The system modeling problem can be solved more easily by way of system identification.
Firstly, the waveforms with randomly varying amplitudes and frequencies are output via LabVIEW, while the input and output voltages are acquired [18]. Secondly, the acquired control voltages are imported into MATLAB's System Identification Toolbox to obtain the transfer function of the fast mirror control system. Since the two axes are similar, we will present the following analysis through one axis. The transfer function of the longitudinal axis of the fast reflector is obtained by the MATLAB System Identification Toolbox as follows: G(s) = 20.73s + 0.9685 s 2 + 21.1s + 0.004262 (5) The obtained results are fed into Simulink to obtain the system model. Then, the PI controller is simulated by MATLAB. The PID controller of LabVIEW is a discretization of the input signal, so the input and output of the final system model are imported into the identification tool to obtain the transfer function of the discrete system as follows: A linear system analysis of the system transfer function is performed to obtain the frequency response and the Bode diagram of the system as follows. The frequency domain expression for the input-output relationship of the PID controller in Simulink is: where U o (s) is the output signal; k p , k i are the proportional and integral parameters, respectively; b is the setpoint weight; r is the setpoint; and y is the process variable. Based on the response of the PID controller in MATLAB, k p = 0.984, k i = 113.58, k d = 0, and b = 0.07932. The step response and the phase frequency and amplitude-frequency characteristics of the system are obtained from the linear system analysis with the above parameters, as shown in Figure 4b. The rise time of the system is 46 ms and the overshoot is 25%. The phase margin is 30°at a system frequency of 91.7 rad/s, and the amplitude response at this frequency is −9.6 dB.

Experiment Results and Discussion
The experimental design based on the above analysis is shown in the figure below. The Flex RIO system is the main controller, consisting of a PXIe-1092 chassis, a PXIe-8861 controller, and main function boards to meet the needs of the system analog output, I/O interface, FPGA chips, and other onboard resources.
FSMs are widely used in laser precision tracking systems. As the main response terminal, they consist of a mirror and its driver. The voice coil motor driver has a higher response speed, better speed regulation, and a smaller drive voltage than the piezoelectric ceramic FSM. In this paper, the FSM has a diameter of 37 mm, a response bandwidth of 750 Hz, and a rotation range of ±1.5°, with a minimum rise time of 0.9 ms Figure 5.
The laser emitted from the light source is reflected by the FSM and captured behind the receiving screen. Then, the camera takes a spot image after the image processing system, and the control system sends out a control signal to control the FSM for deflection to complete the stable pointing control of the light beam. The results of the imaging system processing stage are shown in Figure 6. The laser spot image is processed as described in Section 3, and the system's cycle time is 35 ms in LabVIEW's spot acquisition loop, i.e., 35 ms to acquire a frame of spot image to obtain the spot position information. The effect of each stage of the image algorithm processing is shown in Figure 6, and the completed image of the light spot, free from background noise, is obtained after these processing steps. Firstly, the camera acquires images through the USB interface of the Flex RIO system and then performs image grayscale extraction while displaying the grayscale distribution of the images. The spot image collected by the camera is shown in Figure 6a, and the pre-processing effect of the host system after the luminance extraction is shown in Figure 6b. Then, the pre-processed image is sent to the FPGA module through DMA FIFO. After binarization in the FPGA (the effect is shown in Figure 6c), the complete extraction of the laser spot is completed by low-pass filtering to remove high-frequency noise, and the spot is then extracted by a 3rd order Gaussian filter. Figure 6d shows the final laser spot extraction results. Figure 6e shows the gray value distribution of the spot image taken by the initial camera and Figure 6f shows the gray value distribution after the completion of the image processing process. Finally, the center of gravity method calculates the image's centroid, and the obtained center of gravity coordinates are sent back to the host system for subsequent control processing.
The transformation of the laser centroid pixel coordinates into equivalent position voltages will occur in the host system's main program after receipt. The target position voltage and the spot position voltage are input into the PID controller of LabVIEW to generate the output voltage and output through the PXI-6723 board. The beam deflection is controlled by the voice coil motor driving the mirror, which is actuated by the control voltage received by the FSM controller.
The step signal poses a greater challenge to the control system, and the FSM's step response reflects the actual performance of the control system in practical applications. Therefore, the step response is often used in engineering to measure the control system's performance. The step response of the laser beam control system is shown in Figure 7. The horizontal axis indicates the sampling point of the system and the vertical axis is the coordinate position of the center of mass of the optical spot. The distance between the camera and the receiver screen is set to 27 cm, the deflection range of the spot is less than 1 cm, and the deflection range on the spot image is about 20 pixels. In Figure 7a,c show the step response for the horizontal center of mass ranges of 146-165 and 100-122, respectively, and (b) and (d) show the step response for the vertical coordinate ranges of 115-131 and 130-150, respectively. The sampling rate of the camera is 30 ms, so the rise time of the system is 240 ms, and the steady state is reached in 0.75 s. As it shown in Figure 7, the system stability is good and the higher frame rate industrial camera can reach a steady state faster. The system determines the deviation of the beam by comparing the difference in coordinates between the artificially designated laser centroid and the current laser centroid. Figure 8 shows the control system's user interface in LabVIEW. The accuracy error of the x-axis is 0.08 pixels, that of the y-axis is 0.11 pixels, and the corresponding angle error is 1.047 mrad for the a-axis and 8.68 mrad for the y-axis.

Conclusions
In this paper, we propose an integrated structure based on the Flex RIO system to develop a beam control system and verify its feasibility by experiment. The LabVIEW development language facilitates the development and maintenance and reduces the development costs.
This paper investigates the design of a LabVIEW-FPGA-based control system to achieve stable control of a laser beam with an FSM. Experimental data establish the FSM system model, and the methods of identifying the system model from experimental data and obtaining the PID parameters using MATLAB are introduced. Based on the above design, beam control experiments are conducted. The results show that the system has good robustness, high integration, and can achieve fast and stable beam control to develop a new solution for beam stability control research. The loop time of the image processing program is 35 ms, which is determined by the camera's frame rate of 30 fps and the onboard clock of the FPGA operating at 100 MHz. The feasibility of the system was verified through experiments using a camera with a low frame rate, and the theoretical maximum processing capacity is within the nanosecond range. Future efforts should enhance the system's functionality by selecting a high-frame-rate camera and an FSM appropriate for specific application scenarios. Additionally, the system's performance can be improved by upgrading the spot extraction algorithm, for instance, by incorporating masking to enhance extraction speed or utilizing a correlation calculation to improve accuracy. In this system, a single FSM is used to regulate the beam dithering, resulting in limited control over the beam shift. To address this limitation, future developments should focus on incorporating a dual FSM control system, thereby increasing the control system's degrees of freedom and maintaining the same FSM control principle as in the single FSM setup.
Author Contributions: Conceptualization, methodology, software, validation, formal analysis, investigation, data curation, writing-original draft preparation, writing-review and editing, Y.X. and D.Z.; resources, J.C. and Y.X.; visualization, D.Z.; supervision, Y.X.; project administration, J.C. and Y.X.; funding acquisition, J.C. and Y.X. All authors have read and agreed to the published version of the manuscript.