## 3 The Data-Driven Adaptive Control Strategy
### Adaptive Controller Design  
The proposed adaptive controller is implemented with a multitasking architecture, as illustrated in Figure 3. Three main tasks are executed concurrently during the DED process, i.e., the melt pool monitoring unit, the autotuning unit, and the digital PID unit. Each of them contains subtasks performing different functions automatically and continuously. Data transmission within the controller is indicated by the dotted lines in Figure 3, and the controller parameter update routine is highlighted by the blue line. Details of the above three units are given below. In the melt pool monitoring unit, the \"camera driver\" subtask reads the raw melt pool image captured by the co-axial CCD camera, and the \"image processing\" subtask performs the masking, binarization, and ellipse fitting procedures as described in Section 2. The minor axis length of the fitted  
Figure 2: Block diagram of the conventional closed-loop control system for the direct energy deposition (DED) process. ellipse, measured in the number of pixels, is published as the MPW data. The MPW data are received by both the digital PID unit and the autotuning unit. The digital PID unit calculates the output laser voltage based on the MPW feedback using the standard formulations in Equations (1) and (2). However, instead of using predetermined and user-specified constant controller parameters, this PID unit accepts the adaptive parameters \(\left(K_{p},\ K_{i},\ K_{d}\right)\) calculated in situ by the autotuning unit. System identification by experimental trials-and-errors is removed from the controller design procedure, and the prior knowledge of a plant model is no longer required. The output laser voltage is sent to the laser source as an analog signal, and at the same time it is subscribed by the autotuning unit as an input to update the \(K_{p}\), \(K_{i}\), and \(K_{d}\) parameters. The autotuning unit has two responsibilities, i.e., (1) collecting the process data generated by the other two units and (2) using the process data to update the controller parameters repeatedly and automatically, thus achieving the data-driven adaptive control capability. The autotuning unit consists of a temporary data buffer, a timer function, and a VRFT function. The MPW and laser voltage are recorded in each time frame as the system input and output (I/O) data, respectively. The I/O data collected within a periodic time interval are stored in the temporary buffer before they are extracted by the VRFT function. The timer function launches the VRFT function when the timeout signal is issued. The VRFT function computes the optimal controller parameters using the I/O data in the buffer and sends the updated \(K_{p}\), \(K_{i}\), and \(K_{d}\) values back to the digital PID unit. The timer is reset upon completion of the VRFT routine, and the temporary buffer is flushed. The PID unit with the updated parameters adjusts the laser voltage in the next time interval while the new sets of I/O data are being collected by the buffer. Periodically, the controller parameters are reoptimized at the end of each timer cycle using the updated I/O data until the end of the DED process. Figure 4 shows the block diagram of the proposed adaptive controller. In addition to the error feedback in the conventional PID controller (Figure 2), the autotuning unit forms the second feedback loop that updates the \(K_{p}\), \(K_{i}\), and \(K_{d}\) parameters automatically. The reference model, denoted by \(T_{d}(s)\)  
Figure 3: The multitasking architecture of the proposed data-driven adaptive controller. is an s-domain transfer function representing the desired closed-loop system behavior (e.g., desired settling time and desired response speed) [20], and it can be written as follows:  
\[T_{d}(s)=\frac{e^{-s\tau}}{\left(1+0.2t_{s}s\right)^{n}} \tag{6}\]  
where the settling time \(t_{s}=0.01\) s, the response delay time \(\tau=0\), and \(n=1\) are specified for the stable steady-state tracking purpose [20].