Closed Loop Control of Melt Pool Width in Laser Directed Energy Deposition Process Based on PSO-LQR

A closed-loop controller was proposed to adjust the laser power to maintain melt pool stability based on the linear quadratic regulator (LQR) control theory. The melt pool width acquisition system was built based on complementary metal oxide semiconductor (CMOS), and the captured melt pool image was processed using an image processing algorithm to obtain the melt pool width. The laser power was used as the input variable and the melt pool width as the output variable. The state space spatial model was identified using the subspace method to identify the experimental data. The LQR controller was designed based on the state space equation, to improve the controller’s performance and reduce the hassle of selecting the weighting matrix ${Q}$ in LQR. A particle swarm optimization (PSO) algorithm was used to optimize the control weighting matrix globally, and the optimal control weighting matrix was obtained. The controller performance was evaluated by constant-width and variable-width thin-wall deposition samples, and the results showed that the algorithm is simple, efficient, and able to maintain the melt pool width stable in real-time. It can effectively reduce reliance on manual experience.


I. INTRODUCTION
Laser directed energy deposition (LDED) is a technique used to fabricate parts bottom-up layer-by-layer [1], [2], [3], widely used in metal molds, automotive, aerospace and other fields. LDED has numerous advantages, such as saving material and energy, short processing cycles and the ability to form complex structural parts compared to traditional manufacturing processes. This technology also has some limitations. The slight disturbance from the process parameters and deposition environment may cause changes in the melt pool characteristics, resulting in defects in the manufactured parts [4]. The defects' accumulation will seriously affect the parts' dimensional accuracy and mechanical properties if they do The associate editor coordinating the review of this manuscript and approving it for publication was Mauro Gaggero . not adjust the process parameters. Real-time monitoring and control of the deposition process can effectively solve these problems [5], [6].
Pyrometers and CMOS (CCD) cameras are widely used in online monitoring systems for LDED. The morphological characteristics of the melt pool significantly influence the deposition shape of the LDED process, and they are usually detected and controlled. Moralejo et al. [7] established a CMOS coaxial melt pool image acquisition system, utilizing OpenCV for image process. It can extract the melt width in real-time, with a processing efficiency of approximately 10 ms, providing data support for subsequent melt pool width control. Yang et al. [8] used the minimum external rectangle method to extract the melt pool width, which is less robust when the noise is considerable. Jeon et al. [9] developed a set of artificial neural networks for online prediction of the melt pool depth based on an infrared camera. The accuracy was 25.97 um, with an average error of 8.95% in multilayer multi-pass tests. However, due to the requirement of an infrared camera and a laser line scanner, this system has high equipment costs and low efficiency. Zhang et al. [10] proposed an edge-directed operator with high robustness in the actual welding environment, solving the problem of accurately extracting the melt pool's weak edges, with an algorithm frame rate of 15.7. Some scholars also monitored the melt pool's temperature characteristics. Höfflin et al. [11] obtained data on thermal processes in the melt pool and heat-affected regions through high-speed, high-resolution observation (± 2 pixels) of the melt pool by infrared thermography. Bernauer et al. [12] investigated the feasibility of combining a coaxial pyrometer with a wire feeding system. Nair et al. [13] designed two pyrometers connected in series to measure the melt pool's real-time cooling rate, with equipment monitoring at 1 kHz. The system is poorly integrated and not conducive to industrial applications. Wolff et al. [14] developed a high-speed X-ray imaging system, which can be used to monitor defects such as melt pool porosity. However, the system has poor real-time performance and high costs.
Regarding control algorithms, the main controllable process parameters are laser power, scanning speed, and powder feeding speed. The powder control is less real-time than the other two control methods because the powder conveying has an unavoidable delay [2]. Laser power is the most commonly used control parameter. Yang et al. [8] designed a PID controller to ensure the stability of the melt width, but no specific accuracy data were given. Ding et al. [15] introduced a feedforward compensation controller based on the PID controller to ensure the stability of the melt area by controlling the laser power. Devesse et al. [16] designed a PI controller using melt pool temperature as the control parameter and laser power as the output, achieving stable control of the melt width with and without powder. Shi et al. [17] established multiple PI controllers for controlling non-parallel surface deposition. The deposition of bent tubes and fan-shaped structures was achieved; other PI or PID controllers have been designed for control schemes of melt pool characteristics, such as [18], [19], [20], and [21]. Garmendi et al. [22] constructed part surface point cloud data based on structured light scanning. Then, the melt pool height was controlled by manually adjusting the process. A study on the cooperative control of multiple parameters has also been conducted. Tyralla et al. [18] studied cooperative control of control laser power and lateral lap rate, ultimately improving weld quality. Li et al. [23] showed that the controlled scanning speed could be economical and improve deposition efficiency compared to power control. Other cases where models and algorithms were used in the LDED field, such as data-driven feedback control method based on the part's physical data [24], [25] or simulation data [26], [27], [28]. Gan et al. [29] developed a novel data-driven approach based on multi-physics field modeling-experimental measurementdata mining, which achieved multi-objective quality-based optimization of the additive process and helped to realize the online tuning of the additive process.
Currently, the most used closed-loop control algorithms are PI, PID or improved algorithms based on them. The advantage of those algorithms is that their structure is simple, but the application process relies heavily on the engineer's experience, and the optimal parameters can be difficult to determine. The implementation of deep learning algorithms, such as neural networks, in the LDED field has also been proven feasible. However, this aspect of the algorithm is highly dependent on the quality and quantity of data and is currently only applied on the detection. To address the algorithmic problems mentioned above, this paper proposes a control method based on PSO-optimized LQR to reduce the reliance on manual experience and lower the application threshold for practitioners.
This paper consists of four sections. In Section II, experiment setup is introduced. Closed loop control system is designed in Section III. In Section IV, a step simulation and thin-wall test are conducted. Conclusions are given in Section V.

II. EXPERIMENT SETUP
The experiment setup is shown in Figure 1. The system includes a CNC machine (Siemens 420-D), a melt pool monitoring and control system, a laser (IPG YLR-2000-WC), and a printing head (RC ND-26). The laser is connected to the printing head by fiber optics and has a maximum output power of 2000 W. The powder is delivered to the powder tube by the powder feeder, and printing nozzle ring feeding powder. The melt pool image is monitored by a coaxially mounted CMOS camera (CAM013-10GM). The optical system is split into forward and backward by a 45 • mounted dichroic mirror. The forward can pass 1070 ± 10 nm laser, whereas the backward can pass 390 nm-780 nm visible light. The laser diameter through the collimating lens with a focal length of 100 mm is 20 mm during forward propagation, after which the focusing lens with a focal length of 250 mm focuses the beam above the substrate. The melting powder converges on the surface of the substrate and is melted by laser irradiation, forming the melt pool and reflecting ''process light.'' The ''process light'' is reflected to the camera by the reflector. A bandpass filter, with a wavelength of 540 ± 10 nm, and a neutral density filter with a transmittance of 5% are installed at the front of the camera. The bandpass filter reduces the influence of ambient and other interfering light. Meanwhile, the neutral density filter avoids light intensity beyond the dynamic acquisition range of the camera (73 dB).

III. CLOSED LOOP CONTROL SYSTEM DESIGN
The structure diagram of the LQR controller based on the PSO algorithm is illustrated in Figure 2. The controller mainly consists of three parts: 1) LQR controller: This controller performs closed-loop control on the plant.   2) PSO algorithm optimization module: This module optimizes the weighting matrix Q based on the system's operating state. 3) Image extraction and processing module: This module is responsible for detecting the weld pool image and extracting the melt pool width.

A. MELT POOL IMAGE PROCESSING
High efficiency and high accuracy extraction of melt pool width is the basis for online control. The data acquisition system was developed based on C++ and multi-threaded technology. It runs under Windows 10 and has an Intel Core i5-1135 CPU with 2.40 GHz speed and 16 GB RAM. The CMOS camera uses the Gige communication protocol with a maximum transfer rate of 1 GB/s and the image format Mono8, ensuring the stability of the image data transfer. The camera works at a fixed frame rate of 30 fps and the software takes about 20 ms to process each frame and the subsequent feedback algorithm. During the experiment, it was found that the background area of the melt pool was relatively large, leading to an increase in image processing time [30].
To improve the efficiency of image processing, the image was cropped with the melt pool as the center. The camera's maximum resolution was 1440 × 1080, and after cropping, the resolution was 200 × 200. The test uses Fe101 powder with a powder particle size of 20 um-53 um, and the substrate material is 316. The powder composition is shown in Table 1, and the process parameters are shown in Table 2. The spot diameter of the workpiece surface is 1.16 mm, located below the laser focus. The powder spot diameter is 1.12 mm-1.25 mm, and spot energy and spot concentration follow a Gaussian distribution. Two additional parameters need to be determined before melt width extraction. One is the physical size calibration of the pixel, which determines the actual physical size represented by a pixel. This paper is 5.5 × 10 −4 mm 2 /pixel. The second parameter is the threshold value in the image thresholding segmentation algorithm, which in this paper is set at 94. This value was determined by depositing a single melt test with melt pool widths and comparing extracted melt width data to the different threshold value binary images. Figure 3 shows the extraction process of the melt pool width from the original image. Figure 3 (a) displays a representative melt pool image acquired using the abovementioned   hardware. Firstly, a binary image of the melt pool was acquired using threshold segmentation, as shown in Figure 3 (b). Next, the Canny algorithm is used to extract the edges of the binary image, and the results are illustrated in Figure 3 (c). Figure 3(d) presents the calculation diagram of the melt pool width. Due to the low cooling rate at the end of the melt pool, the ''tailing'' phenomenon can occur, leading to irregular changes in the shape of the melt pool, and thus making it difficult to extract the actual melt pool width. Based on the hardware system analysis, the laser spot is round and has the highest temperature in processing. Therefore, the maximum inner tangent circle diameter (number of pixels) of the melt pool boundary serves as the width. The detection results are shown in Figure 3 (d). The actual melt pool width can be obtained by multiplying the number of pixels by the calibration value. The measured detection error is less than 0.15 mm.

B. SYSTEM IDENTIFICATION
The specific energy in the LDED process is defined as the energy delivered to the process by the laser: where P is the laser power, D is the laser spot diameter; and V is the travel speed. The specific energy plays a key role in determining the melt pool's size, temperature, and microstructure morphology. Variations in heat transfer mode (e.g., thermal build-up) and change in material properties (e.g., thermal conductivity) during processing make it challenging to ensure the stability of the LDED process.
Real-time adjustment of the specific energy is required to ensure process stability, and laser power directly impacts specific energy. This study, the laser power was selected as the adjustable variable (control output) that had a direct effect, and the melt pool width was selected as the control input.
To fully identify the response characteristics of the system, an experiment was conducted on the open loop system using a random binary analog signal. When the laser power is too high, problems such as humping and flowing may occur, whereas too low laser power may result in air holes, unfused material, and other defects. Based on preliminary tests, the final determination of the laser power range is 300 W-600 W, cladding speed is 10 mm/s, power feeding is 0.3 g/s and protective gas flow is 15 L/min. The controller sampling period is set at 0.05 s. For model identification, 50% of the sample data was selected, with the remaining 50% used for validation. The identification result is shown in Figure 4.
where T model is the predict width, T measured is the camera width, and n is the number of data. The data in Figure 4 was calculated and the average error was 3.01%. To further verify the validation of the model, a 400 W-500 W step power was selected for validation experiments, as shown in Figure 5, which showed an average error of 2.89%. It can be seen that the simulated data matches well with the measured data.
Melt pool data is identified based on the recursive subspace method. The system state space equation is calculated as order four by calculating the minimum residual variance. The state space model has the form oḟ where x is the system state vector, y is the system control output, u is the control input, A, B, C, and D are all state space model matrix parameters, and each matrix is calculated to be LQR control is to achieve adequate control of the target function with a small input. In the LDED process, the feedback control of laser power is used to reduce energy consumption whereas ensuring the forming quality, and the objective function is defined as where u is the control quantity, x is the state quantity, Q is a state quantity weighting matrix, which is usually set as a position semi-definite matrix. R is a control quantity weight matrix, which is usually set as a positive definite matrix.
LDED system is a single-input single-output system, so the R matrix parameter is 1. Therefore, the (4) can be written as The weighting matrices Q and R is defined as: The optimal feedback control law can be expressed as: Assume there exists a constant P matrix that can stabilize the system, which can be obtained as: where P is the Riccati equation solution: The parameters are determined initially by trial and error method Equation (8) shows that the performance of the LQR controller is mainly determined by the weight matrix. In engineering applications, the weight matrixes are primarily determined based on engineers' experience or extensive experiments, which wastes time and resources. It is also difficult to determine the optimal solution. PSO algorithm is used to iteratively find the optimal controller weight matrix, which reduces the number of tuning parameters and improves the controller performance.

D. PARTICLE SWARM OPTIMIZATION (PSO)
PSO algorithm mimics the principle of birds searching for food and is a population-based stochastic search algorithm. Particles represent solutions in space, and multiple particles form a population. The position of particles in each population changes according to the relative optimal solutions of the particles and their neighboring populations. The position and velocity of particles are iteratively formulated as (10): 78174 VOLUME 11, 2023 Authorized licensed use limited to the terms of the applicable license agreement with IEEE. Restrictions apply.  i,j is the position and velocity of particle i in the m-th dimension of the search space during the iteration. The optimal solution of particle i in the k-th iteration is denoted as pbest i,j . The optimal solution searched by the whole population is denoted as gbest i,j . c 1 and c 2 are non-negative acceleration constants, r 1 and r 2 are random numbers in the range of [0,1].

E. PSO-LQR CONTROLLER DESIGN
The parameter optimization process of the LQR controller based on PSO is shown in Figure 6. The bridge between the PSO and LQR algorithms lies in the LQR controller weight matrix and particle best adaptive value, and the parameter optimization process is as follows.
Step I: Population size, positions and velocities of particles, number of iterations, and size of search space are initialized.
Step II: The individual adaptation value of each particle is evaluated.
Step III: The current adaptation value of each particle is compared with the best adaptation value, and the merit is represented as p best . The current adaptation value of all particles is compared with the global best adaptation value, and the merit is represented as g best .
Step IV: The weight matrix, position and velocity are derived according to (4) and (10).
Step V: Steps II-IV are repeated, and the iteration is stopped when the results satisfy the convergence condition. Then, the results are output.
Step VI: Verify the optimal solution in the simulation model to verify whether the expected response and accuracy have been achieved.
The population size n is 100, the dimension of the search space m is 25, the number of iterations p is 50, and c 1 = c 2 = 1.5. After the convergence of the algorithm, the optimal value is obtained, as shown in Figure 7.
The matrix Q and R are as follows

A. STEP SIMULATION ANALYSIS
To analyze the performance of the two methods of control. A rectangular wave step signal with a frequency of 1 Hz and an amplitude of 1 mm is used as the step input. The simulation results are shown in Figure 8. It is evident that the PSO-LQR has a faster response and a smaller overshoot, with a maximum overshoot reduction of 0.19 mm and the time to steady-state is 0.23 s, a reduction of 0.4 s, similar to the 0.26 s of the literature [26]. Specifically, the response time is reduced by 50% and the maximum overshoot is reduced by 55.8% when using PSO-optimized LQR. It is clear that the results from using the PSO-LQR control system are significantly better than the results from using the LQR.

B. DEPOSITION OF THIN WALL STRUCTURES WITH AND WITHOUT CONTROL
In order to verify the actual control effect of the algorithm, a few thin wall samples were deposited based on the hardware system, and the scan plan is shown in Figure 9. Figure 9 (b) shows the schematic of scanning path. After fixing the substrate, the thin wall was generated by moving the machining head back and forth. The moving distance of a single layer was 40 mm, and the printing head decelerated to 0 when it reached the endpoint of the thin wall. Then, the Z-axis lifts upward by 0.3 mm. The Z-axis travel time was calculated to be less than 2 ms, so the deposition error during this time is negligible. The laser remains on the light throughout. The printing head was reversed and accelerated to the set speed when the target position was reached. The cycle exists for the entire period of thin-wall printing. The experiment includes constant power (constant initial power) open loop control and constant width closed loop (adjust power to ensure constant melt pool width) control. All experiments kept the same parameters except for the power, as shown in Table 2. The theoretical deposition layer height is 33 mm, total of 110 layers for the complete samples. Figure 10 shows the front view, enlarged view of the edge, side view and top view of the thin wall deposited within constant laser power mode. Figure 10 shows the effect of the sample part deposited in constant power mode. Figure 10 (b) shows a partial enlargement of the sample part. Figure 10 (c) and (d) show the side and top views of the sample. We observed from Figures 10 (b), 10 (c), 10 (d) that the part deposited in constant power mode exhibits significant dimensional fluctuations in the melt width and height direction. This phenomenon was caused by two serious problems.
The first problem because of the thermal build-up of temperature. At the beginning of the deposition stage, the substrate is at room temperature and the heat dissipation mode of the deposition part is 3D (both sides of the deposition layer and the substrate). It leads to the excellent heat dissipation ability of the deposition part. When printing starts, the processing head makes a reciprocating scanning motion, and the temperature of the deposition area increases rapidly. At the same time, the rise in the Z-axis changes the heat dissipation mode from 3D to 2D (both sides of the deposition layer). The combination of these factors leads to heat buildup. The melt pool width increases significantly in the first 40 layers, reaching 0.41 mm. From 40 to 60 layers, there is a slight increase of about 0.15 mm. After 60 layers, the melt pool temperature reaches thermal equilibrium and the melt width stabilizes, finally at 1.94 mm. The average width of the sample was 1.87 mm, with a maximum width of 3.19 mm and a minimum width of 1.45 mm. LDED deposited parts usually require post-processing to improve the surface finish. When the width of the deposited position is less than the average width, the post-processing of deposition sites with a width smaller than the average width can become difficult.
The second problem is that the processing head slows down before accelerating as it runs to the ends of the thin wall. The thin wall edges collect more energy and powder, whereas the cooling time is reduced, resulting in serious quality problems for the sample, reflected in the higher and thicker thin wall edges. This phenomenon is present throughout the deposition process, as shown in Figures 10 (d) and 11 (c). Although the melt pool width does not increase significantly after 60 layers, the effects caused by the accumulation of defects in the early stages are apparent, such as uneven deposition heights, increased deposition widths and collapsed edges, which seriously affect the quality of the molding. The average deposition height was 31.42 mm, less than the target of 1.58 mm. According to [31], it is known that when the substrate temperature increases, the deposition cross-sectional area remains constant under single-pass deposition conditions. The width of the melt pool increases whereas the height decreases, which explains why the average deposition height was lower than the target value. It is essential to maintain 78176 VOLUME 11, 2023 Authorized licensed use limited to the terms of the applicable license agreement with IEEE. Restrictions apply.    the relative height of the processing head to the substrate during the deposition process, and when the relative distance decreases or increases, it may lead to the failure of the process [32]. Figuers 12,14 show the deposited samples after the control intervention. The sample dimensions are uniform, and the melt pool width is stable throughout the deposition process. As shown in Figure 12 (b) and Figure 14 (b), the deposition starts with a low substrate temperature that dissipates heat quickly. In order to reach the preset melt pool width, the power rises quickly, and the highest power reached was 521 W, exceeding the constant power in the uncontrolled mode. The power gradually decreases because the heat dissipation of the sample gradually enters the saturation stage after reaching the peak power. The algorithm reduces heat accumulation by reducing the laser power.
In order to objectively analyze the effect of the intervention of the control algorithm, the extreme differences and variances in the direction of the deposited height and width of the samples in Figures 10, 12, and 14 were calculated. The results are shown in Table 3.
The polar and variance values reflect the deposition process's stability. As seen from Table 3, the PSO-LQRcontrolled deposited samples reduced the range by 69.48% and the variance by 92.82% in the height direction compared to those without control. The range was reduced   by 85%, and the variance was reduced by 15.87% in the width direction. All numerical improvements were better than the LQR-controlled, indicating that the PSO-LQR-controlled deposition samples have better deposition process stability. In addition, the average height of the deposited samples was 32.12 mm and 32.53 mm for the LQR and PSO-LQR algorithms, respectively. This indicates that controlling the size of the melt width is accompanied by a certain control of the melt pool temperature, which can help reduce interlayer errors. The minimum error was 0.47 mm, which may be caused by two factors. Firstly, the matching relationship between the interlayer lift and the single-layer deposition height might have changed after the power change. Secondly, the temperature of the melt pool of the same size may differ due to the change in heat dissipation conditions, resulting in uneven deposition height between layers. This paper did not carry out the measurement of melt pool temperature. It cannot provide specific temperature change data. Follow-up will be conducted in this area to address this limitation.
As shown in Figures 13 (c) and 15 (c), to avoid heat build-up at the edges, the laser power drops more significantly as the processing head scans the edges of the sample. The maximum power drops for the LQR and PSO-LQR algorithms were 60 W and 54 W, respectively. The maximum deviation in height is approximately 2.4% for the LQR algorithm and 0.6% for the PSO-LQR algorithm. Due to the short-lived massive build-up of powder, the swelling phenomenon at the deposition edge is improved but not completely eliminated.

C. PERFORMANCE VERIFICATION OF CONTROLLER
To verify the response characteristics of the PSO-LQR algorithm, a further variable width experiment was conducted. Closed loop control was applied throughout whereas the initial experimental parameters were kept constant. The initial target width was set at 1.9 mm and was changed to 1.7 mm when the deposition height reached 10 mm. The data in the middle 10 s was taken for analysis and presented in Figure 16.
As shown in Figure 16 (a), the sample exhibited an apparent delamination phenomenon. From Figure 16 (b), we observed that the power final fluctuation range was about 50 W, and the melt pool width fluctuation range was about 0.2 mm. The system steady-state response time was about 0.5 s.
We observed from the above experiments that the control method proposed in this paper can achieve stable control of melt pool width and improve processing accuracy. The optimized LQR algorithm has better molding stability and control accuracy. Theoretically, the LQR controller can also achieve the control effect of the PSO-LQR controller, but it may require parameter trial adjustments.
In the height direction, the melt pool size control can slightly weaken the influence of parameters such as powder and path on the quality of the formed parts, thereby improving the forming quality of the parts to some extent. However, it cannot solve the problem of reduced part geometric accuracy due to the use of complex processes. This indicates that melt pool height control, in addition to joint multi-parameter control based on melt pool width control, is necessary. According to research, there is no commercially available multi-parameter control method, which is a major limitation that this article aims to address. Table 4 summarizes the advantages and disadvantages of currently used closed-loop control algorithms. Due to differences in hardware equipment, processes used and control objectives, no relevant test data is available for the response time and control accuracy of some algorithms. In terms of the algorithm's response time and control accuracy, this paper's proposed algorithm has no significant improvements compared to existing melt width control algorithms. However, it has outstanding advantages in terms of controller design complexity and parameter trial tuning time, which can reduce the dependence on process experience. This advantage will be further enhanced with the integration and interface development of the identification algorithm and the parameter finding algorithm.
Future work in this paper will focus on the following aspects: Modeling the correlation between process parameters: Several process parameters, such as powder feeding amount and scanning speed, are predetermined before the experiment. However, these parameters may not be the optimal choice during the dynamic adjustment process, which may result in some quality problems. Therefore, simulation and modeling of the dynamic relationship between parameters and quality to obtain the dynamic range of process parameter matching will be part of future work.
Cooperative control of multiple process parameters: Based on melt pool width control, combined with detection and feedback control of melt pool height and melt temperature. The deposition quality is strongly coupled with the influence of process parameters. Establishing a decoupling controller based on the process parameter matching model is also a focus and challenge of future research.

V. CONCLUSION
Variations in processing conditions during the LDED process can lead to deposition quality problems. In this study, the recursive subspace identification method was used to identify the response relationship between laser power and melt pool width average error was less than 4%. Subsequently, the LQR control method was adopted to design the feedback controller, and the optimal control matrix of the controller was derived using the PSO algorithm. Furthermore, the response and effectiveness of the controller algorithm were verified through thin wall tests. The conclusions were as follows: 1) Quality problems such as wall thickness expansion and uncontrolled edge forming can occur during the processing of thin-walled parts.
2) The PSO-LQR algorithm designed in this study can form thin walls of uniform width, reduce defects such as wall thickness expansion and uncontrolled edge forming, and improve the flatness in the direction of deposition height. The test results indicate that the melt width control accuracy is 0.2 mm, and the system steady-state response time is about 0.5 s. 3) Simply controlling laser power cannot wholly solve the forming quality problems caused by multiple factors, and other process parameters need to be adjusted as well.
Therefore, the control method using system identification combined with PSO-LQR has high accuracy, fast response and good robustness, which can be considered an effective solution to melt width instability in the additive process. It has an equivalent referenced value in the application.