An adaptive PID laser control algorithm of LSTM neural network

The adaptive PID laser control algorithm based on LSTM neural network solves the problem that traditional PID control cannot adaptively adjust in laser systems, achieving high-precision coordinated control of laser power and temperature, and improving the detection stability and reliability of the flow cytometry analyzer.

CN122159045APending Publication Date: 2026-06-05JIAXING QUEST LIFE SCI +1

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
JIAXING QUEST LIFE SCI
Filing Date
2026-04-28
Publication Date
2026-06-05

AI Technical Summary

Technical Problem

Traditional PID control methods are difficult to achieve the requirements of high precision, high stability and multivariable coupling in laser control. In particular, they cannot effectively adapt to external disturbances and dynamic changes in the system, and cannot meet the requirements of high environmental adaptability of flow cytometry analyzers.

Method used

An adaptive PID laser control algorithm based on LSTM neural network is adopted. The parameters of the PID controller are adjusted online by running the LSTM neural network predictor on the host computer. Combined with intelligent step size adjustment, bias adaptation and high temperature power correction mechanism, the coordinated adaptive control of laser power and temperature is realized.

Benefits of technology

It significantly improves the control precision and adaptability of the laser, increases the long-term power stability to within 0.5%, and controls temperature fluctuations to below 0.1℃, thereby enhancing the control performance of the laser in dynamic environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122159045A_ABST
    Figure CN122159045A_ABST
Patent Text Reader

Abstract

The application belongs to the technical field of laser control method of flow fluorescence analysis, and particularly relates to an adaptive PID laser control algorithm of LSTM neural network, wherein an upper computer is used for adjusting parameters of a PID controller on line according to historical state data of a laser; a lower computer receives a control instruction of the upper computer, and collects power and temperature data of the laser in real time; a laser execution subsystem; an LSTM neural network predictor dynamically predicts and outputs PID control parameters according to a historical error, an integral term and a differential term sequence; and the method comprises the following steps: S1, collecting real-time power and temperature data of the laser; S2, inputting the historical error, the integral term and the differential term into the LSTM neural network predictor; S3, outputting adaptive PID parameters by the LSTM predictor; S4, adjusting an output of a power and temperature controller according to the parameters; and S5, driving the laser and a thermoelectric cooler to execute the control instruction through the lower computer.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the technical field of laser control methods for flow cytometry fluorescence analysis, specifically relating to an adaptive PID laser control algorithm based on an LSTM neural network. Background Technology

[0002] In in vitro diagnostics (IVD) and flow cytometry, lasers serve as core light sources, widely used in crucial tasks such as cell analysis, molecular detection, and disease diagnosis. The output power and wavelength stability of a laser directly determine the sensitivity, accuracy, and reliability of the detection system. Particularly in flow cytometry, tumor marker detection, and immunological research, the stability of the laser source is critical to the accuracy of experimental results. The inherent characteristics of lasers make them nonlinear, multivariable coupled, and time-varying systems. Laser performance is significantly affected by changes in temperature, current, and the external environment. In particular, the operating temperature and current of semiconductor laser diodes (LDs) directly affect their optical output efficiency and wavelength stability. With prolonged laser operation, rising temperatures, laser aging, and environmental fluctuations make it difficult to control the laser's output power and stability. Therefore, achieving precise laser control under these complex operating conditions has become a challenge in current laser control system design.

[0003] Traditional PID control methods have achieved considerable success in many industrial applications. However, when faced with the high precision, high stability, and multivariable coupling requirements of laser control, traditional PID control exhibits significant limitations. The traditional control method suffers from the following drawbacks: First, traditional PID controllers use fixed gain values ​​to adjust the system's control parameters, which often results in an inability to effectively adapt to external disturbances and dynamic changes in the system. Second, the nonlinear characteristics of the laser system make it difficult for traditional PID controllers to precisely control power and temperature during the adjustment process.

[0004] Flow cytometry analyzers typically rely on multiple wavelength laser sources to simultaneously excite different fluorescent dyes. Traditional laser control methods, such as constant current sources and analog PID control, can no longer meet the demands of modern laboratories for high precision, high stability, and high environmental adaptability.

[0005] To address the problems of slow steady-state establishment, weak anti-interference ability, and complex parameter tuning in traditional PID control when dealing with complex operating conditions involving multiple coupled parameters such as laser aging and temperature fluctuations, this invention aims to provide an adaptive PID laser control algorithm based on LSTM neural network. Summary of the Invention

[0006] The purpose of this invention is to provide an adaptive PID laser control algorithm based on an LSTM neural network to solve the problems mentioned in the background art.

[0007] To achieve the above objectives, the present invention provides the following technical solution: An adaptive PID laser control algorithm based on an LSTM neural network includes a host computer and a slave computer. The host computer runs an LSTM neural network predictor to adjust the parameters of the PID controller online based on the historical state data of the laser. The slave computer receives control commands from the host computer and collects power and temperature data of the laser in real time. The laser execution subsystem includes a laser diode, a thermoelectric cooler, and monitoring sensors. The LSTM neural network predictor dynamically predicts and outputs PID control parameters based on historical errors, integral terms, and derivative term sequences, thereby achieving coordinated adaptive control of the laser power and temperature. Includes the following steps: S1. Collect real-time power and temperature data of the laser; S2. Input the historical error, integral term, and differential term into the LSTM neural network predictor; S3.LSTM predictor outputs adaptive PID parameters; S4. Adjust the output of the power and temperature controllers according to the parameters; S5. Control commands are executed by driving the laser and thermoelectric cooler through the lower-level computer.

[0008] Preferably, the PID controller includes a power PID controller and a temperature PID controller; the power PID controller is used to adjust the laser diode drive current according to the power error; the temperature PID controller is used to adjust the thermoelectric cooler drive current according to the temperature error, and the LSTM neural network predictor provides independent parameter adjustments for the two PID controllers respectively.

[0009] Preferably, the LSTM neural network predictor includes: an input layer, an LSTM layer, a fully connected layer, and an output layer; the input layer receives a feature matrix composed of error, integral term, and differential term for consecutive time steps; the LSTM layer is used to extract temporal features; the fully connected layer maps the LSTM output to PID parameters; and the output layer outputs positive proportional, integral, and differential coefficients through the Softplus function.

[0010] Preferably, the training loss function of the LSTM neural network predictor is calculated as follows: a. Input parameters: predicted change (pred), actual change (ture), and the controller's feature matrix (feat); b. Extract current features: ;

[0011] c. Calculate the predictive control variable: ; d. Calculate the mean square error: .

[0012] As a preferred option, an intelligent step size adjustment mechanism is also included, which divides the control into a large error zone, a medium error zone, a small error zone, and a dead zone according to the power error, and adopts strategies of dynamic step size, fixed step size, minimum step size, and maintaining the previous control quantity, respectively.

[0013] As a preferred option, a high-temperature power correction mechanism is also included, which determines the operating environment temperature based on the bias value of the temperature controller and corrects the output of the power controller in real time to compensate for power drift caused by high temperature.

[0014] Preferably, a bias adaptive mechanism is also included, which initializes the bias of the temperature controller according to the ambient temperature and dynamically updates the bias value under steady-state conditions to maintain thermal balance.

[0015] Compared with the prior art, the beneficial effects of the present invention are: (1) The present invention provides an adaptive PID laser control algorithm based on LSTM neural network. The algorithm constructs a collaborative control architecture of intelligent decision-making by the host computer and real-time execution by the slave computer. It dynamically learns the timing characteristics of the system through LSTM network, adjusts the PID parameters of the power and temperature controllers online, and introduces intelligent stepping, bias adaptation and high temperature power correction mechanisms to enhance the robustness of the system. (2) The adaptive PID laser control algorithm based on LSTM neural network provided by the present invention improves the long-term power stability to within 0.5% and the temperature fluctuation to below 0.1℃, which significantly improves the control accuracy and adaptability of the laser in dynamic environment. (3) The present invention provides an adaptive PID laser control algorithm based on LSTM neural network, and designs a hybrid intelligent control architecture that integrates classical PID control and LSTM neural network, realizing online dynamic optimization of PID parameters. Attached Figure Description

[0016] Figure 1 This is a schematic diagram of flow cytometry fluorescence analysis; Figure 2 The structure of the NN-PID laser control algorithm; Figure 3 It is an NN-PID LSTM cell structure; Figure 4 It is an NN full-layer structure; Figure 5 The state update process for the NN-PID controller module; Figure 6 Diagram of high-temperature power correction mechanism; Figure 7 The initialization and update process for the bias; Figure 8 This is a component of the laser control system; Figure 9 For the host computer software program architecture; Figure 10 This is a schematic diagram of the measuring device; Figure 11 The output power of the laser at different temperatures; Figure 12 A heatmap comparing the normalized statistical data of two control algorithms at different temperatures; Figure 13 The temperature data curve of NN-PID under constant temperature chamber conditions of 40℃ and 55% relative humidity; Figure 14 The graph shows the power data curves of NN-PID under constant temperature chamber conditions of 40℃ and 55% relative humidity. Figure 15 Comparison of output power curves for two control methods under constant temperature chamber conditions of 40℃ and 55% relative humidity; Figure 16 A scatter plot of temperature data from an NN-PID test conducted for 8 hours in a constant temperature chamber at RH=55% and dynamic temperature. Figure 17 Power data curves for NN-PID tested in a constant temperature chamber at RH=55% and dynamic temperature for 8 hours; Figure 18 The power data curve of NN-PID is obtained by testing in a constant temperature chamber with RH=55% and dynamic temperature turned off for 8 hours. Detailed Implementation

[0017] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0018] In the fields of in vitro diagnostics and flow cytometry, lasers serve as the core light source, widely used in important tasks such as cell analysis, molecular detection, and disease diagnosis. The output power and wavelength stability of the laser directly determine the sensitivity, accuracy, and reliability of the detection system. Particularly in flow cytometry analysis, tumor marker detection, and immunological research, the stability of the laser source is crucial to the accuracy of experimental results. Flow cytometry analyzers typically rely on multiple laser sources of different wavelengths to simultaneously excite different fluorescent dyes. Traditional laser control methods, such as constant current sources and analog PID control, can no longer meet the demands of modern laboratories for high precision, high stability, and high environmental adaptability.

[0019] However, the inherent characteristics of lasers make them nonlinear, multivariable coupled, and time-varying systems. Laser performance is significantly affected by changes in temperature, current, and the external environment. In particular, the operating temperature and current of semiconductor laser diodes (LDs) directly impact their optical output efficiency and wavelength stability. With prolonged laser operation, rising temperatures, laser aging, and environmental fluctuations make it difficult to control the laser's output power and stability. Therefore, achieving precise laser control under these complex operating conditions has become a challenge in current laser control system design.

[0020] Traditional PID control methods have achieved considerable success in many industrial applications. However, when faced with the high precision, high stability, and multivariable coupling requirements of laser control, traditional PID control exhibits significant limitations. First, traditional PID controllers use fixed gain values ​​to adjust the system's control parameters, which often results in an inability to effectively adapt to external disturbances and dynamic changes in the system. Second, the nonlinear characteristics of laser systems make it difficult for traditional PID controllers to precisely control power and temperature during the adjustment process.

[0021] In recent years, intelligent control algorithms in laser control have received widespread attention, with increasing research focusing on AI-based intelligent control algorithms, particularly neural network-based PID control (NN-PID), to address the challenges in laser control. Compared to traditional PID control, NN-PID automatically learns system dynamics through neural networks and adjusts control parameters in real time, thus adapting to nonlinear changes in the laser, temperature fluctuations, and other environmental factors. Specifically, by learning from system input and output data, neural networks can effectively capture complex nonlinear relationships in laser control systems, overcoming challenges that traditional PID cannot handle. For example, the neural network-based PID control method proposed by Reutov et al. can effectively suppress system errors and significantly improve the output stability of lasers under uncertain environments.

[0022] Meanwhile, LSTM, as a recurrent neural network with long-term memory, exhibits unique advantages in processing time-series data and predicting system dynamics. LSTM can effectively learn the temporal characteristics of laser systems and predict system responses in advance, thereby optimizing the controller's adjustment process. Furthermore, using the LSTM (Long Short-Term Memory) structure as the core of the control algorithm can leverage its ability to memorize time-series data, further improving the control system's adaptability to long-term dynamic changes in the laser. For example, J Yan and his team proposed a model predictive control method for self-focusing of a piezoelectric motion platform based on LSTM. Based on this LSTM model, a model predictive control method was developed that can successfully find the optimal focusing position using a series of focusing measurements from a series of images. Experiments verified that the proposed method can reduce autofocus time by at least 30%.

[0023] Based on this, this paper proposes an adaptive PID control algorithm (NN-PID) based on an LSTM neural network to address the precise control requirements of the laser source in flow cytometry analyzers. The main contributions of this paper include: (1). A hybrid intelligent control architecture integrating classical PID control and LSTM neural network was designed, realizing online dynamic optimization of PID parameters; (2). A collaborative control system of upper computer (running intelligent algorithm) and lower computer (executing control instructions) was constructed, and a special loss function and targeted control mechanism (such as intelligent stepping, bias adaptation, etc.) were designed to improve the overall performance of the system; (3) A complete experimental platform was built. The control performance of the proposed algorithm was systematically verified under static, dynamic and extreme temperature environments. It was also compared and analyzed with traditional PID control. The results proved the superiority and engineering application value of the proposed algorithm.

[0024] Analysis of Laser Control Issues in Flow Cytometry Analyzer The performance of a flow cytometer is highly dependent on the stability and accuracy of its core component—the laser. The laser's output power, wavelength stability, and anti-interference capability directly determine the quality of the fluorescence signal and the reliability of the detection results. With increasingly stringent requirements for lasers in the IVD (in vitro diagnostics) field, designing and controlling a high-performance, stable laser system has become one of the key technologies for precision detection in flow cytometers. This chapter will analyze in detail the control requirements of the laser in a flow cytometer, reveal the main challenges it faces, and provide theoretical support for subsequent control system design.

[0025] Based on the application characteristics of lasers in flow cytometry analysis, this paper analyzes the specific requirements of flow cytometry analyzers for lasers: Laser power stability and consistency: The output power of the laser is a key factor affecting the intensity and stability of the fluorescence signal. The sensitivity of the fluorescence signal is closely related to the laser power. If the laser power fluctuates significantly, it may lead to differences in the detection signal of the same sample at different times, thus affecting the reliability of the detection results. To ensure accurate detection, the laser needs to maintain a stable output power during long-term operation and should not exhibit significant power drift under changes in ambient temperature.

[0026] Temperature Control and Thermal Effects: Lasers, especially semiconductor lasers, are extremely sensitive to temperature. Temperature changes can cause the laser's operating wavelength to drift and even reduce its output power. Therefore, lasers require an effective temperature control system to maintain temperature stability and keep temperature fluctuations within a very small range to ensure stable operation.

[0027] Aging and Stability: As lasers are used over time, their performance degrades, especially after long-term operation, affecting both output power and wavelength stability. Therefore, the laser control system needs to adapt to this degradation and maintain stable laser output through intelligent adjustments.

[0028] The above analysis shows that the performance requirements of the laser in a flow cytometry analyzer are reflected in wavelength stability, output power stability, temperature control, and noise level. The laser must maintain its key performance indicators under different working environments and long-term use. Table 1 shows the performance requirements of the laser control system for the flow cytometry analyzer after analysis: Table 1. Specifications of Laser Control System

[0029] While lasers greatly improve the performance of flow cytometry analysis equipment and play an important role, the application scenarios of flow cytometry analyzers also bring many technical challenges to the performance requirements of lasers: (1) Nonlinearity and multi-parameter coupling problem. The working state of a laser is determined by the driving current, but its current-power characteristics are affected by temperature and device aging. Especially in high-frequency operating environments, the performance of lasers will change significantly due to temperature changes and current fluctuations, resulting in unstable output power. Therefore, how to accurately control the output power and wavelength of lasers under multi-parameter coupling has become a major challenge for control systems. (2) Accuracy and response speed of temperature control. The wavelength and power of lasers are greatly affected by temperature, especially semiconductor lasers, whose output characteristics are very sensitive to temperature changes. Temperature control systems not only need to have high-precision temperature control capabilities, but also need to respond quickly so as to adjust in time when the temperature fluctuates greatly and maintain the stability of the laser. (3) Aging and long-term stability. Lasers will age during long-term use, resulting in problems such as decreased output power and wavelength drift. Traditional PID control systems are difficult to cope with the nonlinear changes caused by laser aging. Therefore, designing a control system that can adapt to laser aging is key to improving the long-term stability and reliability of lasers. (4) Adaptability to environmental changes. The performance of lasers is easily affected by factors such as ambient temperature, humidity, and electromagnetic interference. Especially in flow cytometry analyzers, since the instruments are often used in complex environments, this places higher demands on the laser control system. How to ensure the stability and accuracy of laser output under changing environmental conditions is still an urgent problem to be solved. (5) Demand for intelligent and adaptive control. With the increasing requirements for laser control accuracy and stability, traditional fixed-parameter PID control can no longer meet the needs. Intelligent control algorithms, such as neural network PID (NN-PID) algorithms, can adjust control parameters according to the real-time feedback of the laser through data-driven adaptive control, solving the shortcomings of traditional PID control in nonlinear systems. However, how to design efficient and reliable intelligent control algorithms and ensure their stable operation in practical applications remains a challenge.

[0030] By analyzing the main requirements of the laser in a flow cytometry analyzer, we clarified the technical requirements of the laser control system in terms of wavelength stability, power stability, and temperature control, and discussed the challenges faced in laser control. The stability of the laser directly affects the performance of the flow cytometry analyzer; therefore, designing a precise, efficient, and intelligent laser control system is crucial for achieving a high-performance flow cytometry analyzer. The next chapter will delve into the application and design of a neural network-based adaptive PID control algorithm in laser control.

[0031] NN-PID control algorithm design Building upon the analysis of laser control in a flow cytometry analysis system, this chapter focuses on the detailed design of intelligent control algorithms. A neural network-based adaptive PID control algorithm (NN-PID) is proposed to fully meet the requirements of the flow cytometry analysis system for the laser, enabling real-time intelligent control of the laser. This algorithm integrates the theoretical advantages of classical PID control with the adaptive capabilities of neural networks, aiming to improve the system's control performance under nonlinear and time-varying conditions.

[0032] This algorithm employs a hybrid control architecture, combining a PID adaptive controller, an LSTM neural network predictor, and multiple control mechanisms to form an intelligent control system that combines stability and adaptability. Based on traditional PID control, this architecture introduces an LSTM neural network predictor, which analyzes historical data from the PID controller to update PID parameters in real time, and incorporates multiple control mechanisms to enhance the system's robustness and steady-state accuracy.

[0033] The overall structure of the algorithm is as follows Figure 2 As shown, during the algorithm startup phase, the program sets initial parameters (including proportional coefficient Kp, integral coefficient Ki, and derivative coefficient Kd) and control target values ​​(temperature and power setpoints) for two PID controllers (responsible for power and temperature control respectively). These initial parameters remain unchanged during the control process. The two PID controllers, as the core computing units of the system, are responsible for processing real-time data and generating control outputs, forming a complete data stream. The LSTM neural network predictor and control mechanism extract key information from the data stream, without directly participating in control calculations. Instead, they indirectly optimize the control effect by dynamically adjusting the controller's state.

[0034] This algorithm incorporates two independent PID controllers, one for power control and the other for temperature control, each equipped with independent initial parameters and control objectives. The corresponding two LSTM neural network predictors use historical error sequences as input and undergo online learning through a dedicated loss function to adjust the PID controller parameters in real time. Furthermore, the algorithm designs different control mechanisms to address the different characteristics of power control and temperature control. These mechanisms, based on real-time information from the data stream, further enhance control performance by adjusting the internal parameters or output strategies of the PID controllers.

[0035] 1. NN-PID Predictor refer to Figure 3The NN-PID predictor is the intelligent core of this control algorithm. Essentially, it's a deep learning-based time-series modeler that dynamically predicts the optimal PID control parameters based on the historical state data of the laser system, enabling the controller to learn and adapt online. Through the initialization of the PID controller, the program directly creates the temperature controller and power controller, and initializes their parameters using configuration definitions.

[0036] The PID Predictor neural network model defined by the algorithm has a hybrid architecture consisting of an LSTM layer and a fully connected layer (composed of multiple linear layers and activation functions). Following the forward propagation process, i.e., the process by which the network processes the input data and generates prediction results, the input layer of the neural network is:

[0037] The feature matrix input to the network is a three-dimensional tensor. Where B is the batch size, L is the sequence length, and D is the feature dimension. The feature dimension includes the following time series features: The error is t. Let be the integral term at time t. This is the differential term at time t. The characteristic matrix contains the controller states for 20 consecutive time steps.

[0038] The first layer of the neural network is an LSTM layer. LSTM layers are specifically designed for processing time series data, effectively capturing the dynamic patterns of error, integral, and derivative changes, and extracting time-series features. This layer processes the input sequence step by step. Its input, calculation process for each time t, and output can be represented as:

[0039] After 20 iterations, only the hidden state of the last time step, which contains the hidden state of the entire sequence information, is taken. As output, that is:

[0040] refer to Figure 4 The last two layers are fully connected networks (FC), consisting of two layers in total. The first layer is a linear transformation that maps the H (hiddensize, default 64) dimensional features to 32 dimensions, using ReLU (corrected linear unit) as the activation function. This layer compresses the features, reducing the 64-dimensional LSTM output to 32 dimensions, which is used to extract the most relevant control features.

[0041]

[0042] The second layer is also a linear transformation, mapping the 32-dimensional features to the output dimension Dout (output_size, default is 4). Softplus is used as the activation function. The Softplus function ensures the output is positive because PID parameters (proportional, integral, and derivative coefficients) should generally be positive; the program handles positive and negative correlations by setting the direction, avoiding negative coefficients. This layer implements the final parameter mapping, mapping the high-level features to the PID parameter space, outputting a three-dimensional vector. .

[0043]

[0044] Backpropagation updates and optimizes the network weights by calculating the gradient of the loss function with respect to the network parameters and using the gradient descent algorithm. Based on the defined loss function Loss (detailed below), the gradient of the function with respect to the parameters of each layer is calculated using the chain rule: Gradient of fully connected layer:

[0045] LSTM layer gradients are calculated by backpropagating along time to obtain the gradients of the LSTM parameters.

[0046] Meanwhile, to prevent the PID neural network parameters from becoming too large compared to their pre-update values ​​due to gradient explosion, which could cause severe system oscillations, a gradient pruning method was used to minimize the gradient change amplitude.

[0047] And update the parameters using stochastic gradient descent:

[0048] refer to Figure 5 This network architecture balances expressive power and computational efficiency. The LSTM layer captures temporal dynamics, the fully connected layer enables efficient parameter prediction, and the Softplus output layer ensures physical constraints. It will operate according to the process of initialization, state update, and online training. (1) Initialization: The neural network PID controller module implements the functions of configuring the LSTM neural network, initializing PID parameters, and setting the historical data buffer during the initialization phase; (2) State Update: The state update process of the neural network PID controller module is as follows: Figure 5 As shown; (3) Online Training: Once the neural network PID controller module has collected enough data (200 sets), it will start training. It will prepare 20 sets of data from the historical sequence of the PID controller (t-20 to t-1) to construct a feature matrix, calculate the loss, and perform backpropagation. Simultaneously, it will limit the gradient obtained from backpropagation to prevent significant changes in the final PID parameters from interfering with control. This constitutes one training cycle. The module will continuously collect control data during the control process, repeating this training process without stopping, thus achieving the function of updating the PID controller parameters in real time based on the current control data.

[0049] Through the network structure and training mechanism designed above, the NN-PID predictor can continuously learn system characteristics during laser operation and adjust PID parameters in real time, effectively coping with complex operating conditions such as laser aging and changes in ambient temperature, significantly improving the adaptive capability and robustness of the control system. This mechanism of learning while controlling enables the control system to continuously optimize its performance and adapt to various changes during long-term operation.

[0050] 2. Loss Function In the training process of neural networks, the loss function is a core indicator for optimizing model parameters. It guides the model to update weights to achieve optimal performance by quantifying the difference between the predicted and the true values. In the NN-PID control algorithm, the design of the loss function not only needs to consider the basic characteristics of traditional PID controllers: proportional (P), integral (I), and derivative (D), but must also be able to reflect the controller's dynamic response capability to errors.

[0051] Therefore, the algorithm designs a dedicated loss function based on the current error, integral term, and derivative term, aiming to directly evaluate the performance of the PID controller by learning the optimal PID parameters through the network, thereby achieving precise adjustment of the laser control. The constructed loss function is calculated as follows: Input parameters: predicted change (pred), actual change (ture), and the controller's feature matrix (feat).

[0052] The predicted change is derived from the real-time forward propagation output of the LSTM neural network, with a matrix dimension of [1,3]. It is a three-dimensional vector output by the neural network mapping high-level features to the PID parameter space. The true change is a single-valued scalar derived from the execution record of the actual hardware system, representing the control increment actually applied to the actuator (such as LD current or TEC current) in the previous control cycle. The feature matrix `feat` is derived from the historical data points of the control system, concatenating the error (e), error integral, and error derivative into a feature matrix with a matrix dimension of [1, 20, 3]. Specifically, it represents [batch size, sequence length, feature dimension]. The batch size defaults to 1 and can be changed according to the actual application. The time series length defaults to 20 and can be changed according to the actual application. The feature dimension is 3, containing the error `e`, the integral term `I`, and the derivative term `D`.

[0053] Extract current features: ; Calculate the predictive control variable: ; Calculate the mean square error:

[0054] In the formula, N is the number of samples. In the calculation of the loss function, it is reflected in the batch size. As described above, the batch size is 1 by default and can be changed according to the actual application. The proportional, integral, and derivative coefficients calculated in real time by the neural network correspond to the first column and first row of the predicted change matrix `pred`, which are `pred[:, 0]`, `pred[:, 1]`, and `pred[:, 2]`, respectively. In the formula, `e`, `I`, and `D` represent the current state feature error, and the integral and derivative correspond to `feat[:, -1, 0]`, `feat[:, -1, 1]`, and `feat[:, -1, 2]`, respectively. The data from the last time step (i.e., the latest moment) in the time-series feature matrix is ​​extracted. Actual control quantity changes. The change in the system's actual output in the previous step serves as the benchmark value for supervised learning, calculated from the control output execution records of the actual hardware system. This algorithm combines the powerful learning capability of neural networks with the fine-tuning mechanism of PID controllers. Therefore, the design of the loss function ensures that it can fully reflect the essential characteristics of PID controllers, namely, accurately adjusting errors, gradually eliminating deviations, and quickly responding to error changes.

[0055] 3. Control Mechanism After completing the above design, the algorithm is capable of calculating the laser drive output based on the laser's feedback parameters. However, some problems remain that cannot be instantly solved by relying solely on a neural network trained with collected data: for example, oscillations in the PID control itself, output power drift caused by high-temperature operation of the laser hardware, and differences in the laser's thermal equilibrium at different temperatures. Therefore, to address these issues, the algorithm incorporates control mechanisms to specifically improve the laser's accuracy and stability.

[0056] 4. Intelligent step size adjustment mechanism The underlying principle of PID control leads to oscillations in control as long as the error is not zero. To address this, this algorithm employs a compensation adjustment mechanism to partition the error and determine the maximum control limit. Because the PD feedback current is small and consistently positive, the power controller uses a special step-size adjustment mechanism to divide the control into four regions based on the error magnitude: Large error region: The step size is dynamically calculated and the control direction is determined by the error sign, which determines the large step response, quickly eliminates large deviations, and shortens the response time.

[0057] Medium error range: Fixed step size adjustment, smooth transition phase, to prevent overshoot.

[0058] Small error range: Minimum step size adjustment, high precision to approach the target value.

[0059] Dead zone: Keep the previous control value unchanged to avoid oscillation, establish a steady state, and reduce power consumption.

[0060] The adjustment mechanism adopted is as follows:

[0061] 5. High-temperature power correction mechanism When a laser operates at high ambient temperatures (>32°C), the internal optical, mechanical, and electrical hardware undergoes thermal changes, altering the laser's output state. Typically, increased ambient temperature leads to an increase in laser output power. This increase is not reflected in the laser's PD feedback current or the internal temperature sensor, meaning it cannot be monitored internally. However, it can be measured externally. For example, at 35°C, the laser's output power increases by approximately 0.5% compared to normal temperatures (10°C-30°C), and this phenomenon is reflected in multiple measurement results as an increase in the average output over a period of time. Therefore, it is necessary to calibrate the laser's power at high temperatures to stabilize its output under various temperature conditions.

[0062] Based on the experimental phenomena and the execution mechanism of the program described above, it can be seen that the effects of high-temperature environments are not reflected in the PD current and temperature sensor, but can be reflected by the working state of the laser's temperature control actuator, i.e., the TEC. The temperature PID controller reflects the heat dissipation efficiency parameter, or the mechanism is the bias value of the temperature controller. This will be mentioned later. Currently, it can be understood that the magnitude of this value directly reflects the heat dissipation efficiency of the laser's current temperature. The smaller this value, the lower the heat dissipation intensity of the laser. Even if it is negative, it means that the laser needs to add extra heat to maintain the target operating temperature. The higher this value, the greater the heat dissipation per unit time required for the laser to maintain the target operating temperature. Therefore, the magnitude of the temperature controller's bias value (hereinafter referred to as bias) can be used to measure the magnitude of the current operating temperature environment of the laser.

[0063] The high-temperature power correction mechanism is set according to the laser's bias value, referencing Figure 6 .

[0064] The purpose of the correction method is to adjust the PD current-laser output power calculation method of the power PID controller in real time according to the operating temperature environment, so as to prevent the laser from outputting different power at different operating temperatures with the same PD current due to internal deviations in the system, thereby improving the stability and consistency of power control.

[0065] 6. Bias Adaptive Mechanism Because the heat generation rate of a laser varies under different ambient temperatures, operating durations, and power levels, the heat dissipation rate required to achieve thermal equilibrium also differs. Therefore, the bias term in the temperature control algorithm needs to be adjusted in real time to adapt to the current laser operating conditions. Thus, we introduced a temperature controller bias adaptive mechanism to accurately maintain thermal equilibrium in steady state, avoid over-driving, and update the bias during the initialization phase and throughout the control process. For the bias initialization and update process, please refer to [reference needed]. Figure 7 .

[0066] The initialization and update process of the bias is detailed below: Initialization: The bias is initialized by assigning initial values ​​to the temperature control PID according to the mapping relationship between the initial temperature and the bias. The mapping relationship is as follows:

[0067] The mapping relationship is obtained by calibration at a constant temperature in the constant temperature chamber. The temperature controller obtains the ambient temperature in the initial stage using the three-sample averaging method. That is, the average value of the first three temperature sensor readings after the lower-level machine starts communicating with the upper-level machine is the initial temperature determined by the algorithm, and the initial bias of the temperature controller is obtained accordingly.

[0068] Steady-state detection: After initialization, bias updates will only be triggered under steady-state conditions. The criterion for determining steady state is that when the error between the temperature sensor's measured value and the target temperature is less than the set temperature difference threshold for a certain period of time, the system determines that the temperature is in steady state, and bias updates can be enabled at this time.

[0069] Bias update processing: When the algorithm detects a steady-state temperature and the bias is not within the lockout time, it will update the current bias. That is, first, the integral term of the controller is cleared to zero, then the difference between the current output and the first three terms of the PID controller is taken (essentially, the integral term and the previous bias term are used as the new bias), and finally, a smoothing process is performed to obtain the new bias.

[0070] Bias lockout: Since changes in bias can cause brief fluctuations in the output of the temperature PID controller, and temperature transmission has a certain hysteresis, a steady-state lockout mechanism is adopted to prevent temperature oscillation and over-adjustment. That is, after the bias initialization update or after the steady-state update is reached, the steady state cannot be updated again within a set fixed lockout time, and the current bias remains unchanged until the lockout time ends.

[0071] System architecture and algorithm deployment The NN-PID algorithm requires a stable laser physical system. In this chapter, we designed a 638nm diode red laser for the laser equipment commonly used in flow cytometry analyzers. The laser's electrical control system converts the input 12V power supply into two 5V channels through two switching power supplies via an external interface. One channel powers the TEC bidirectional drive circuit, which uses a dedicated chip MAX1968 to provide bidirectional constant current control. The other channel powers the control circuit and the laser drive circuit, which uses a constant current circuit. The laser output power is obtained through the PD inside the laser tube. The temperature sensor is an NTC temperature sensor, and external communication is via RS485.

[0072] Based on this hardware platform and the designed NN-PID laser intelligent control algorithm, a three-part laser system was constructed: a host computer intelligent control subsystem, a slave computer data acquisition and execution subsystem, and a laser execution subsystem. The core of the host computer intelligent control subsystem is a PC, capable of running a neural network PID predictor to achieve adaptive parameter adjustment. It includes dual controllers: a power PID controller (processing PD monitoring data) and a temperature PID controller (processing temperature sensor data), and is responsible for data storage and analysis. The slave computer data acquisition and execution subsystem parses the host computer instructions and drives the actuators: outputting the LD drive current to the laser diode via a constant current source; outputting the TEC drive current to the thermoelectric cooler via a dedicated circuit; and simultaneously acquiring the PD monitoring current in real time through an external amplifier circuit and obtaining temperature sensor data through the ADC2 channel. The laser execution subsystem has built-in monitoring sensors. It can monitor the actual output power by monitoring the PD photodiode; monitor the internal operating temperature of the laser through a temperature sensor; receive drive current from the power execution unit (LD) to generate laser output; and receive drive current from the temperature control unit (TEC) to raise or lower its own temperature. (The laser control system composition is referenced.) Figure 8 .

[0073] In the entire experimental system, the host computer software serves as the runtime environment for the NN-PID intelligent control algorithm and is also the core component for data acquisition and processing. Its main tasks include three aspects: first, calling and running the NN-PID algorithm to calculate control commands based on real-time power and temperature data; second, interacting with the slave computer via serial communication to upload data and issue commands; and third, storing and processing experimental data to provide a foundation for subsequent analysis.

[0074] The host computer software adopts a functionally differentiated structure, mainly comprising three parts: algorithm calculation, communication, and data processing. The algorithm calculation function runs the NN-PID control algorithm, receives data input (power, temperature) from the slave computer, executes the algorithm calculation, and outputs the corresponding control quantities (drive current correction value, temperature control adjustment value, etc.). The communication function is based on a serial port protocol, enabling real-time exchange of data and instructions. This layer is responsible for encapsulating, sending, and receiving data frames, and using checksums to determine communication integrity. The data processing function mainly records and performs basic analysis of raw data, supports storage in text or tabular format, and can export to CSV format for subsequent statistical processing.

[0075] This design, which differentiates based on function, ensures the independence of each functional module, giving the software good stability and scalability during operation.

[0076] The host computer and the slave computer communicate bidirectionally via a serial port. The communication content mainly includes: Data upload: The lower-level computer sends the collected laser power, temperature, drive current and other parameters to the upper-level computer at fixed time intervals; Command issuance: Based on the calculation results of the NN-PID algorithm, the host computer issues control parameters (such as target power setpoint and TEC adjustment value) to the slave computer for execution. To ensure transmission reliability, the communication protocol uses a fixed frame header and check bit to quickly locate and detect errors at the data receiving end.

[0077] The host computer stores the collected data in real time. Each experiment generates an independent data file, including a timestamp, experiment number, and set parameters, ensuring traceability for subsequent analysis. The host computer software is deployed on a regular PC workstation, running on a Windows system. The primary development language is Python, with some communication interfaces implemented in C / C++ to ensure stability and speed. Experimental verification shows that the software can maintain stable operation during continuous data acquisition for over 8 hours, without significant delays or data loss, meeting the requirements of NN-PID control experiments.

[0078] Since the algorithm only performs calculations and cannot directly transmit data or send control signals as data and control instructions within the system, it needs to be embedded in the host computer software application. To connect the algorithm's input and output terminals, interconnect with the lower-level machine, and realize the overall transmission and processing of data and control signals, the host computer application adopts a modular, layered architecture design, mainly divided into four layers: (1). Application Management Layer: Located at the top layer, this layer is responsible for system initialization and configuration, real-time control of loop scheduling, logging, and status monitoring. This layer directly faces the user, providing functions such as setting control targets and displaying alarms. (2). Control Algorithm Layer: The core logic of the neural network PID controller includes dynamic adjustment of PID parameters, online learning, and bias adaptive mechanisms. This layer receives system state information from the data processing layer and outputs control inputs. (3) Data Processing Layer: This layer is responsible for parsing the raw data reported by the lower-level machine, performing feature engineering (such as calculating errors, integrals, and differential terms), safety monitoring (such as temperature limit alarms), and data preprocessing (standardization, etc.). This layer provides the processed data to the control algorithm layer. (4). Communication Layer: Located at the lowest layer, this layer is responsible for communication with the lower-level hardware. It comprises two parts: an external driver layer and a hardware abstraction layer. It uses a serial port protocol for bidirectional data exchange, implementing data frame parsing and generation. This layer hides the underlying communication details, providing a unified data interface for the upper layers. For the upper-level software architecture, refer to [reference needed]. Figure 9 .

[0079] The program adopts an object-oriented design, with major modules achieving high cohesion and low coupling through classes. The overall architecture is as follows: Figure 9 The communication layer of this program is... Figures 2-8 The hardware abstraction layer and external driver layer are combined, but only for serial communication between the upper and lower computers. It does not involve the hardware part of the MCU and laser execution and monitoring, because in this system, this part is not controlled by the upper computer software layer, but by the lower computer software running on the MCU.

[0080] Overall, the host computer software achieves real-time execution of the NN-PID algorithm through a simple and efficient architecture, and provides a reliable platform for the acquisition, storage, and processing of experimental data. Although the functional modules are relatively basic, they fully meet the needs of laser control experiments and provide flexible interface support for subsequent algorithm optimization and functional expansion.

[0081] The overall workflow of the laser control system begins with the startup command from the host computer. During the system initialization phase, the host computer sends initial control signals and sets the initial bias current based on the ambient temperature sample automatically collected by the slave computer. Subsequently, it enters the real-time control loop: the slave computer continuously collects data from the PD monitoring current and temperature sensor, and transmits it to the host computer via serial port.

[0082] On the host computer, the power PID controller and the temperature PID controller process the incoming data in parallel. The neural network PID predictor stores and analyzes the data stream in real time, dynamically adjusting the operating parameters of the two controllers. The control commands generated by the controllers are sent to the slave computer to drive the constant current source to adjust the LD power, while simultaneously controlling the TEC drive circuit to adjust the temperature, thereby achieving a stable output of laser power.

[0083] The system triggers an online learning mechanism at fixed data volume intervals, and the neural network predictor automatically optimizes controller parameters based on the collected controller data. Throughout the process, sensor data and drive command data are continuously recorded, forming a complete operation log. This closed-loop control system ensures stable laser operation in dynamic environments through an intelligent adaptive mechanism.

[0084] Control Implementation and Experimental Verification This chapter will test the laser system equipped with the NN-PID algorithm to determine the actual effect of the algorithm on laser control.

[0085] 1. Experimental system composition and analysis methods To verify the feasibility and effectiveness of the proposed NN-PID intelligent control algorithm in a flow cytometry laser, a laser control system, consisting of both hardware and software platforms, was constructed as described above. This system enables real-time deployment and operation of the algorithm in the experimental environment, and also facilitates the acquisition and analysis of multiple parameters such as power and temperature, providing comprehensive support for subsequent performance comparisons and data verification. The laser system under NN-PID control will then be experimentally tested.

[0086] To simulate real-world application environments as closely as possible and ensure the controllability of experimental conditions, a constant temperature and humidity chamber (WEISSTECH WSHW-150A) was used as the experimental environment control device. This device can provide static and dynamic temperature change scenarios, enabling the laser to operate within an environmental range of 10℃–40℃, thereby verifying the stability and robustness of the control algorithm under different temperature and humidity conditions. Simultaneously, some tests were also conducted in common environmental conditions such as an electronics laboratory (T∈25°, 27°, RH∈40%, 50%). (See schematic diagram of the measurement device for reference.) Figure 10 .

[0087] In the optical measurement section, a high-precision optical power meter (Ophir PD10-C) and a photodetector (Thorlabs PDA36A) were used to continuously monitor the laser power. To ensure data accuracy, the power meter probe was fixed using an optical platform and a light shield to avoid external light interference; a cooling fan was also added to the measurement optical path to reduce the impact of ambient temperature fluctuations on measurement accuracy. Temperature measurement relied on a high-resolution temperature sensor integrated inside the laser, combined with environmental monitoring from a constant temperature chamber, forming a dual temperature measurement system.

[0088] The acquisition and transmission of experimental data relies on the combined operation of the output light and photoelectric sensors, oscilloscope, and communication interface module. Power meter signals are converted and transmitted to the host computer via an Ophir Juno converter, while temperature and current signals are acquired by the slave computer's ADC and then uploaded to the host computer. Simultaneously, a Keysight U1620A high-bandwidth oscilloscope is used to sample and verify some dynamic signals for noise and transient response analysis.

[0089] The communication component is implemented based on a serial port protocol, supporting real-time data reporting, command issuance, and anomaly detection. To ensure reliable data transmission, the system incorporates a two-way handshake mechanism and a verification mechanism, and automatically caches critical data when communication is interrupted, resuming transmission upon recovery.

[0090] The host computer serves as the core platform for the operation and experimental control of the NN-PID algorithm. Its main functions include algorithm calculation, experimental process control, data storage, and visualization analysis. The host computer uses a high-performance workstation (ThinkPad T series) and runs a customized software framework, which consists of a control module, a monitoring module, an analysis module, and a logging module.

[0091] The control module is responsible for calling the NN-PID model to generate and issue control commands; the monitoring module displays the curves of key parameters such as power, temperature, and current in real time, making it easy to observe the control effect; the analysis module can automatically process the collected data and calculate performance indicators such as average value, standard deviation, range, CV value, and long-term stability; the log module automatically saves experimental data and operating status, and generates reports when anomalies occur, ensuring that the experimental process is traceable.

[0092] Table 2 Experimental Equipment

[0093] From a data processing perspective, performance evaluation metrics for control systems include: mean, standard deviation, extreme values, range (the difference between the maximum and minimum values) over a period of time, the CV (conversion factor) of data over a period of time, and long-term stability over that period. The mean is the arithmetic average of all data points, representing the typical value of the data over that period; it is the most important indicator describing the central tendency of the data. The standard deviation measures the average difference between each data point and the mean. A larger standard deviation indicates a more dispersed distribution of data points around the mean, with greater volatility; a smaller standard deviation indicates a more concentrated distribution of data points, with a more stable process. The maximum and minimum values ​​directly show the upper and lower limits that the data can reach during the observation period, representing potential outliers (such as extremely high or low values) and understanding the actual output capability range of the process. The range is the difference between the maximum and minimum values; it is the simplest and most intuitive measure of dispersion, representing the overall span of the data. However, its disadvantage is that it is easily affected by extreme outliers and cannot reflect the internal distribution of the data. The CV is the ratio of the standard deviation to the mean (usually expressed as a percentage), allowing us to compare the volatility of datasets of different units and magnitudes. Long-term stability, similar to the CV value, is also a relative indicator. However, it uses the range (total range) instead of the standard deviation (average fluctuation), representing the percentage of the maximum possible variation in the data relative to the average level over the entire observation period. The lower this percentage, the more stable the long-term performance and the smaller the relative magnitude of variation. To fully understand a process, these indicators need to be considered together: First, look at the average value to understand the central position of the process. Then look at the standard deviation and range to understand the absolute fluctuation of the process. Finally, use the CV value or long-term stability index to determine whether this level of fluctuation is acceptable and to compare it horizontally with other processes. An ideal state is where the average value reaches the target, while the standard deviation, CV value, and long-term stability index are all as small as possible. Our tests typically focus on two monitored quantities, namely power and temperature. Therefore, under each test condition, we collect both types of data for the above data processing to demonstrate the quantitative effect of NN-PID control.

[0094] 2. Experimental Tests and Results We conducted the experiment under the conditions described above. Power data of the laser was collected continuously for 8 hours after power-on stabilization at settings of 10, 15, 20, and 25 mW. The laser power and output power data were collected at a frequency of 15 data points per second, generating a total of 43,200 data points over 8 hours. Temperature data was collected from the laser's internal temperature sensor at a frequency of 2 data points per second, generating a total of 57,600 data points over 8 hours. The analysis involved calculating the average, standard deviation, maximum, and minimum values ​​of the 8-hour data points to determine the range, CV value, and long-term stability data.

[0095] Table 3. Power data statistics for different output powers under the NN-PID control algorithm.

[0096] Table 4. Statistical table of temperature data collected at the same time under different output powers by the NN-PID control algorithm.

[0097] The test data shows that the laser can achieve the corresponding output power at different output power levels, meaning it can achieve the function of laser output power adjustment. Furthermore, the long-term stability of the laser is within the 2% requirement of the system specifications, and significantly better than this requirement. The laser's temperature control function can achieve internal temperature fluctuations of less than 1℃. Figure 11 The output power of the laser is given at different temperatures.

[0098] Meanwhile, it is worth noting that at lower output power, the superior resolution compared to the system output results in a lower limit for output power fluctuations. This is reflected in long-term stability, making the laser's long-term stability in low-power output mode relatively worse than in high-power output mode. It is also noted that at low output power settings of 10mW and high output power settings of 25mW, the coefficient of variation (CV) of the laser output is larger than in the medium-power output mode, meaning the output fluctuations are more severe. Observing the temperature control data, it can be seen that the average temperature at different power levels is very close to the preset temperature control target value of 25℃, and the range, CV, and long-term stability data are roughly similar, indicating that the set target power does not affect the operating results of the temperature controller.

[0099] Based on the operating temperature requirements of the LD inside the laser and the possible operating temperature of the laser, we set six typical temperature points of 10℃, 15℃, 20℃, 25℃, 30℃ and 35℃ for testing. We recorded the power and temperature data of the laser at the static operating point using a laser power meter that is not coupled to the laser and a temperature sensor inside the laser.

[0100] Table 5 Power data of NN-PID tested in a constant temperature chamber at RH=55% for 8 hours under different static temperatures.

[0101] Table 6. Temperature data of NN-PID tested in a constant temperature chamber for 8 hours at RH=55% and different static temperatures.

[0102] The power and temperature data show that the system meets the requirements of long-term stability <2% and temperature fluctuation <1℃ at all 6 static temperature points, with sufficient margin.

[0103] Based on the power data, it can be observed that the CV and long-term stability fluctuate within a certain range at different static temperature points, and are not correlated with the temperature change trend. At different static temperature points, the 8-hour average power of the laser can be stabilized within a very small fluctuation range (≈0.15%), which is smaller than the value of long-term stability. This indicates that the difference in the working environment temperature will not affect the average output power of the laser, mainly due to the combined effect of laser temperature control and high-temperature power correction strategy.

[0104] Based on the temperature data, it can be observed that the CV values ​​of the LOG temperature data after 8 hours of operation are roughly similar under different operating temperature conditions. This value reflects the control characteristics of the temperature PID controller itself, and the change in the operating environment temperature has minimal impact on this characteristic. Under different operating temperatures, the extreme temperature values ​​are sometimes equal. This is because the ADC output digital signal of the laser lower-level machine has a resolution of 0.021℃, which results in discontinuous data.

[0105] The article mentioned above states that the NN-PID control algorithm running on the host computer is an upgrade of the PID algorithm running on the slave computer, and its performance should be superior to the slave computer PID control algorithm. To verify this, we set up the same test environment, equipment, and methods for the slave computer PID control algorithm. The test results were analyzed using the difference between the 8-hour average power at each temperature and the total average power at all temperatures (Avg Power Deviation), Range, CV 8h, and Long-term Stability. Normalized values ​​were used to characterize the performance of the two control algorithms at different temperatures. The normalization calculation method is as follows:

[0106] After all data has been statistically processed, for reference Figure 12 .

[0107] A comparison of power data from the two control algorithms clearly demonstrates that the host computer-based NN-PID algorithm significantly outperforms the slave computer-based PID algorithm in terms of long-term system stability, exhibiting stronger output power stability under extreme temperature conditions of 10℃ and 35℃. It can be noted that the average power of the laser using the PID algorithm is significantly affected by the ambient temperature, showing a positive correlation with temperature changes, while the average power of the laser using the NN-PID algorithm is less affected by temperature, remaining relatively stable within this operating temperature range.

[0108] After testing at six static temperature points, one noteworthy issue is that the power stability output statistics collected at 35℃ are slightly worse than those at other temperature points. For the abnormally high temperature of 40℃, we set up the same test conditions, equipment, and methods, and conducted an 8-hour test using the host computer NN-PID control method. We collected and analyzed the power and temperature data generated during the test. For specific data, please refer to [reference needed]. Figure 13 , Figure 14 .

[0109] At a static temperature of 40℃, the power data shows that its average output power is about 0.15mW higher than the average of the other six static temperature points, and its power CV and long-term stability are worse than the data from the other six static temperature points. The temperature data also indicates that temperature control has essentially failed; the average temperature of the laser during operation is 30.4℃ instead of the set temperature control target of 25℃, and the temperature fluctuates significantly.

[0110] By examining the LOG data generated during laser operation, it can be seen that at an ambient temperature of 40℃, the current sent from the laser's lower-level machine to the TEC (Transducer Control Unit) increases rapidly and then remains at its maximum current (2.2mA). This current is the maximum operating current that the laser hardware can supply to the TEC. Therefore, it can be concluded that even at its maximum cooling efficiency, the laser cannot achieve the temperature control target of maintaining the internal LD's operating temperature at 25℃ at an ambient temperature of 40℃. This is a limitation inherent to the laser hardware actuator itself.

[0111] Knowing that the host computer's NN-PID control program could not achieve the target temperature control of 25°C for a laser operating in a 40°C environment, resulting in significant fluctuations in the laser's output power, we repeated the above experiment with the slave computer's PID control to compare the laser output performance under relatively extreme operating conditions. The test results are referenced below. Figure 15 .

[0112] Table 7 Comparison of Output Power Data under Constant Temperature Chamber Conditions of 40℃ and 55% Relative Humidity

[0113] Our comparison revealed that both control algorithms maintained a long-term output power stability of less than 2% at an ambient temperature of 40℃. However, the lower-level PID algorithm exhibited worse control stability than the upper-level NN-PID algorithm, characterized by a higher coefficient of variation (CV) and poorer long-term stability. We also noted a significant difference in the 8-hour average output power between the two algorithms, highlighting the differences in their temperature control mechanisms at high temperatures.

[0114] After testing at a static temperature point, it has been proven that the laser under the control of the host computer's NN-PID algorithm program has a stable output power. Therefore, when placed under a dynamic ambient temperature—that is, when the ambient temperature of the laser's operating environment changes—it is necessary to determine whether the laser's output remains stable, and simultaneously assess the stability of the laser's system parameters. Next, we will conduct dynamic temperature experiments, referring to... Figure 16 , Figure 17 .

[0115] Table 8 Power data of NN-PID tested in a constant temperature chamber at RH=55% and dynamic temperature for 8 hours.

[0116] The power and temperature data show that, under dynamic temperature operating conditions, the long-term stability of the laser's output power and the temperature fluctuation range still meet the system requirements and have a good margin. This is reflected in the data, which are not significantly different from the laser data at the static temperature point. It can be considered that reasonable temperature changes have almost no impact on the laser's output.

[0117] Tests at static temperatures have demonstrated that the laser's output power becomes unstable in the power test mode of the NN-PID algorithm program on the host computer, i.e., with temperature control off. This proves the necessity of the temperature controller in the algorithm. In practical applications of lasers, the ambient temperature often varies. Therefore, it is necessary to conduct tests with temperature control off in a changing ambient temperature environment to verify the necessity of temperature control in the NN-PID algorithm program.

[0118] Figure 18 The power data curve of NN-PID is obtained by testing in a constant temperature chamber with RH=55% and dynamic temperature turned off for 8 hours.

[0119] Inside the constant temperature and humidity chamber, a program is set to control the working status of the chamber. The program has 80 working states, starting from 30℃ and decreasing by 0.5℃ every 6 minutes until it reaches 10℃. Then, it increases by 0.5℃ every 6 minutes until it reaches 29.5℃. This process takes a total of 8 hours and will be repeated. The relative humidity is set to 55%.

[0120] Table 9 Power data of NN-PID tested for 8 hours in a constant temperature chamber with RH=55% and dynamic temperature control off.

[0121] It is evident that without temperature control, the long-term stability of the laser output power does not meet the system specification requirement of <2%, and the temperature variation range of the laser also does not meet the system specification requirement of less than 0.1℃. However, we can observe that when the temperature changes, the change in the LD drive current calculated by the control algorithm is almost synchronous. This is because the effect of temperature change on PD photocurrent is real-time, but its effect on output power is asynchronous; the impact of temperature change on output power has a significant lag on the time scale.

[0122] Results and Discussion In this study, we propose an adaptive PID control algorithm based on an LSTM neural network (NN-PID) and apply it to the control of a laser in a flow cytometry analyzer. Experimental results show that, compared with traditional PID control, the NN-PID algorithm has significant advantages in maintaining the laser's output power and temperature stability. By dynamically adjusting the PID controller parameters, NN-PID can effectively cope with the laser's nonlinear characteristics, temperature fluctuations, and performance degradation caused by long-term operation, significantly improving the laser's long-term stability and adaptability, and meeting the requirements of the IVD (in vitro diagnostics) field for high-precision and high-stability laser control.

[0123] This study also demonstrates the potential of LSTM neural networks in laser control. The timing prediction capability of LSTM enables more precise adjustment of PID parameters, avoiding the limitations of fixed parameters in traditional PID methods. Furthermore, intelligent step size adjustment, high-temperature power correction, and bias adaptive mechanisms further enhance the system's robustness and response speed, ensuring stable laser output across different temperature and power ranges.

[0124] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.

Claims

1. An adaptive PID laser control algorithm based on LSTM neural network, characterized in that: The system includes a host computer and a slave computer. The host computer runs an LSTM neural network predictor to adjust the parameters of the PID controller online based on the historical state data of the laser. The slave computer receives control commands from the host computer and collects power and temperature data of the laser in real time. The laser execution subsystem includes a laser diode, a thermoelectric cooler, and monitoring sensors. The LSTM neural network predictor dynamically predicts and outputs PID control parameters based on historical errors, integral terms, and derivative terms, thereby achieving coordinated adaptive control of the laser power and temperature. The PID controller includes a power PID controller and a temperature PID controller; the power PID controller is used to adjust the laser diode drive current according to the power error; the temperature PID controller is used to adjust the thermoelectric cooler drive current according to the temperature error; the LSTM neural network predictor provides independent parameter adjustments for the two PID controllers respectively. The LSTM neural network predictor includes: an input layer, an LSTM layer, a fully connected layer, and an output layer; the input layer receives a feature matrix composed of error, integral term, and differential term for consecutive time steps; the LSTM layer is used to extract temporal features; the fully connected layer maps the LSTM output to PID parameters; the output layer outputs positive proportional, integral, and differential coefficients through the Softplus function. Includes the following steps: S1. Collect real-time power and temperature data of the laser; S2. Input the historical error, integral term, and differential term into the LSTM neural network predictor; S3.LSTM predictor outputs adaptive PID parameters; S4. Adjust the output of the power and temperature controllers according to the parameters; S5. Control commands are executed by driving the laser and thermoelectric cooler through the lower-level computer.

2. The adaptive PID laser control algorithm based on LSTM neural network according to claim 1, characterized in that, The training loss function of the LSTM neural network predictor is calculated as follows: a. Input parameters: predicted change perd, actual change true, and the controller's feature matrix feat; b. Extract current features: ; c. Calculate the predictive control variable: ; d. Calculate the mean square error: 。 3. The adaptive PID laser control algorithm based on LSTM neural network according to claim 1, characterized in that: It also includes an intelligent step size adjustment mechanism, which divides the control into large error zone, medium error zone, small error zone and dead zone according to the power error, and adopts dynamic step size, fixed step size, minimum step size and maintain the previous control quantity strategy respectively.

4. The adaptive PID laser control algorithm based on LSTM neural network according to claim 1, characterized in that: It also includes a high-temperature power correction mechanism, which determines the operating environment temperature based on the bias value of the temperature controller and corrects the output of the power controller in real time to compensate for power drift caused by high temperature.

5. The adaptive PID laser control algorithm based on LSTM neural network according to claim 1, characterized in that: It also includes a bias adaptive mechanism, which initializes the bias of the temperature controller according to the ambient temperature and dynamically updates the bias value under steady-state conditions to maintain thermal balance.