#### Abstract

In order to improve the production quality of the lipstick-filling machines and the performance of the equipment, the structure of a turntable lipstick-filling machine was designed and the servo control was optimized, considering the known production defects. First, based on the lipstick-filling process, the structure of the turntable lipstick-filling machine was designed. Regarding the bubble problem in lipstick filling, an elastic connecting rod vibration device was designed. Based on the principle of PMSM and a position servo system, a mathematical model of the lipstick-filling servo system was established, the system transfer function was calculated and its dynamic performance was analyzed. Combined with the transfer function, the lipstick-filling servo system PID control and particle swarm optimization PID control simulation models were built. The system adjustment time *t*_{s} was 0.7 s under particle swarm optimization. Finally, a prototype was built to verify the simulation optimization results. The experimental results demonstrate that the qualified rate of lipstick filling, under the particle swarm optimization PID control implementation, is 97%, indicating that the particle swarm algorithm is quite applicable and has an economic impact by improving the accuracy and stability of the lipstick-filling servo system.

#### 1. Introduction

The filling machine is a generic type of mechanical equipment used to quantitatively inject liquid material into containers and repack finished products. The rapid development of the global economy raises people’s demand for products that can improve the quality of life, setting high requirements for more stable control and precise positioning of filling equipment to achieve the production purpose of excellence [1, 2]. Therefore, the design level of the position servo system becomes the key to establishing whether the filling machine is advanced or not.

Due to the development of new control theory and digital technology, the application of servo control systems in displacement control grows more mature. Traditional management has been gradually replaced and the basis of modern industrial control has been established. It is widely used in elevator control, tank turret displacement control, missile angular displacement control, etc [3]. For example, the UK’s Renishaw XR20-W wireless rotary shaft calibration device can achieve a resolution of 0.1 angle/s and ultra-high measurement accuracy of ±one angle/s. A 19-bit assembled three-stage induction has been developed by the Shenyang Institute of Automation, at the Chinese Academy of Sciences. Experiments show that the maximum division interval error of the zero position is ±0.75 angle/s, while the encoder’s resolution is ±0.3 angle/s [4]. In view of the research in the servo system displacement control optimization strategy domain, Hu of the Harbin University of Technology adds a diagonal recurrent neural network algorithm to the traditional PID control. This algorithm is executable online, making it possible to adjust the PID controller parameters in real-time [5, 6].

Wu et al. [7] used the particle swarm optimization algorithm to optimize the PID controller parameters of battery charging. The experimental results show that the battery charging efficiency is significantly improved. Chen and Huang [8] used the particle swarm optimization algorithm to obtain the global solution of the optimization problem, thus addressing the PID controller parameter tuning issue.

Aiming at the problems of low production quality, poor stability, substandard filling accuracy, rough modeling, and insufficient intelligence of filling equipment, this paper focuses on the structural design and optimization of the lipstick-filling machine, the servo control system, and control algorithm optimization. An elastic connecting rod vibration device is proposed to solve the problem of lipstick-filling bubbles. Aiming at the demand for high precision and fast response, the mathematical model of the filling servo system is built based on PMSM as the main control object. In view of the shortcomings of traditional PID parameter tuning, the particle swarm optimization algorithm is introduced, to optimize the PID controller parameters in an effort to achieve better results. Experiments show that the particle swarm optimization control strategy can improve the stability and filling accuracy of the lipstick-filling system.

#### 2. Structure Design and Optimization of Turntable Lipstick-Filling Machine

##### 2.1. Production Process in a Lipstick-Filling System

This system serves the goal of lipstick quantitative filling production, which combined with the lipstick filling principle and filling process puts forward a design scheme of a highly efficient turntable lipstick filling machine (Figure 1).

The structure of the turntable lipstick filling machine includes a silica mold turntable, mold conveying device, pipe clamping device, barrel, filling valve, pretemperature return device, cooling tank, rotating cover device, and a lifting mechanism, which cooperates with various cylinders and motors to complete the full-automatic lipstick-filling task.

Compared to the traditional lipstick filling machine, the proposed improvement on its operation is mainly as follows: the processes of a complete sequence, such as preheating, injection, cooling, rewarming, cooling, and demolding of the die for lipstick production, are distributed along a circle to make the structure more compact. Moreover, the filling valve can fill four lipsticks at a time, while the silica supply mode of the filling system is rotary and continuous. In addition, the production of lipstick of different specifications can be achieved by simply changing the mold. Manual removal is replaced by the robotic manipulator, while the whole machine is controlled and managed by pneumatic logic controller, combined with a human-computer interface [9]. Compared to the traditional filling machines, the proposed equipment shows some improvement in flexibility, production efficiency, and intelligence.

##### 2.2. Structure Design of Turntable Lipstick-Filling Machine

The production process, along with the overall structure of the new turntable lipstick-filling machine is shown in Figure 2.

The production process of the turntable lipstick filling machine is divided into three modules: filling, demolding, and capping. The preheating, injection, and return temperature systems are part of the filling module; the central turntable and pipe clamping system belong to the demolding module, while the capping system belongs to the capping module. If the turntable lipstick-filling machine is divided into modules, the transmission and control systems, the body structure and the aforementioned three working modules together constitute the complete structure of the lipstick-filling machine [10].

##### 2.3. Design of Vibration Device for Turntable Lipstick-Filling Machine

###### 2.3.1. Analysis of the Bubble Problem

In the actual filling production process of lipstick, a small number of pits are formed on the surface after cooling and forming. This occurs because bubbles are mixed in during filling, while the remaining bubbles cannot be discharged resulting in remaining gas holes after the lipstick cools, contributing to an unattractive final product. The main reason is usually due to improper setting of material temperature or excessive filling speed. In the actual production process, the preheating and the material temperature are usually increased, in order to reduce the bubbles occurrence. However, many lipsticks on the market contain active ingredients, which cannot be heated up blindly. The way to quickly determine the optimal temperature depends heavily on the working experience of the operator.

Considering that the bubble is attached to the inner wall of the silica mold, this study uses the fast vibration method to force the drop to detach from the inner wall and float up to the liquid surface under the effect of the density difference. Thus, the problem of the gas hole is solved, saving the temperature debugging link and significantly improving the economy and work efficiency.

###### 2.3.2. Elastic Connecting Rod Vibration Device

According to the bubble solution, a vibrating body is used, embracing the silica mold and generating high-speed micro amplitude vibration. The vibration displacement is controlled within 2.4 mm and the vibration frequency is about 60 Hz, in order to ensure a good defoaming effect. The structure of the elastic connecting rod-type vibration device is shown in Figure 3. It is a double-mass vibration device, which is mainly composed of the excitation device, the working mass, the balance mass, the main vibration spring, the frame, and the swing bar [2, 11].

The model is imported into Adams, where constraints, loads, and drives are added. The rotational speed of the movement is 20000 d/s, the simulation time is 0.5 s, and the number of steps is 250. Τhe working mass is forced to vibrate under the simple harmonic excitation with a vibration period of 0.018 s, causing a displacement, as shown in Figure 4. The simulation results show that the displacement difference in the *X* direction is 2.125 mm, while in the *Y* direction is 1.1 mm. The vibration displacement of the working mass is described in the following equation, proving to be less than 2.4 mm, while the periodic vibration is stable and reliable meeting the design requirements:

**(a)**

**(b)**

#### 3. The Characteristic Analysis of Lipstick-Filling Servo System Based on PMSM

##### 3.1. Servo Motor Selection

Information about the parameters of the lipstick-filling servo system is listed in Table 1 based on the structure and investigation of the designed lipstick-filling machine.

According to Table 1, the servo motor HG-KN43J-S100 is a suitable candidate, while the servo driver MR-JE-40B can be used to realize high-precision filling control.

##### 3.2. Theoretical Analysis of PMSM

In order to describe the steady and dynamic performance of the PMSM system, the DQ axis rotation coordinates system is introduced [12] (fixed to rotor).

The voltage equation of PMSM, defined in the DQ axis rotation coordinates system is as follows:

PMSM electromagnetic torque current and motion equation are as follows:

The PMSM mathematical model is composed of voltage equations (2) and (3), the electromagnetic torque equation (4), and the motion equation (5). The mathematical model contains the product term of the mechanical angular velocity and the current components and , which indicates that there is a mutual interference and coupling between variables, so the model is nonlinear meaning the electromagnetic torque cannot realize the linearization control. It cannot achieve a high-performance control effect [13].

According to the analysis of the PMSM mathematical model, the control of motor output torque is ultimately attributed to the management of *d* and *q* current components, realized by voltage control. The aforementioned high-performance control requirements are achieved by using the current feedback vector decoupling control to disengage the and components.

By default, the air gap magnetic field of PMSM is uniformly distributed, that is *L*_{d} = *L*_{q} = *L*_{a}, so the torque equation is as follows:

According to (6), the electromagnetic torque has a positive linear correlation with the *q*-axis current component but is independent of the *d*-axis current component. The copper loss will rise with the existence of *d* axis current component, so the current control method of is adopted [14].

In the servo system, it is necessary to quickly and accurately control the torque of the servo motor, so the feedback control of the current is quite essential. The given input command current and feedback current are subtracted by the voltage type inverter, while the difference is the input to the current controller . The voltage components in the *DQ* coordinates system are obtained as follows:

Combining equations (7) with (2) and (3), the current feedback decoupling control block diagram is derived, as shown in Figure 5. The control scheme can learn the approximate decoupling control of PMSM, in dynamic and static states so as to realize fast and high-precision torque control.

##### 3.3. Mathematical Model of Lipstick-Filling Servo System

In the case where the vector direction in the armature current vector control is the same as the *q*-axis direction (), the voltage and torque equations are sorted out again as follows:

Laplace transforms the current in (9) as follows:where, is the PMSM electrical time constant and is reciprocal of the armature winding resistance.

Substituting the electromagnetic torque equation into the motor motion equation yields the following:

Let (PMSM EMF constant). By simplifying equation (11) and using Laplace transformation on , the following relation is derived:

Substituting into equation (12) can derive the transfer function between induced electromotive force and current (excluding viscous friction damping coefficient).

Based on equation (13), the dynamic structure diagram of PMSM is shown in Figure 6.

The open-loop transfer function can be obtained from the graph in Figure 6.where, , , and are all known quantities.

Based on the servo system structure, the structure diagram of the lipstick-filling servo system, with PMSM acting as the actuator, is established, as shown in Figure 7.

The transfer function of each link of the lipstick-filling servo system is approximately obtained, while their integration leads to the transfer function of the whole system [15].where, , is the transfer function of the power conversion link and is the transmission function of the screw drive link. Combining the parameters of the servo motor and servo driver, the values *T*_{a} = 0.25 and *K*_{M} = 0.08 can be obtained. The specific transfer function is approximately obtained by analyzing the actual working conditions.

##### 3.4. Dynamic Performance Analysis of the Servo System

In order to analyze the performance of the lipstick-filling servo system and determine whether it can meet the needs of the subsequent simulation, the dynamic performance of the transfer function is analyzed. Considering the step signal of the system as the input, the Simulink module of MATLAB is used to build the simulation model of the step response of the system, producing the system response curve, as shown in Figure 8. It is evident that the step response is a curve starting at the initial value of 0, followed by an initial oscillation and converging to a constant value. The steady-state error is 0, the transient process is steady, and the regulating time is 3 s. Overall analysis shows that the system is stable exhibiting high accuracy and quick response.

#### 4. PID Control of the Lipstick-Filling Servo System Based on PSO

##### 4.1. Traditional PID Control Strategy

PID controller is widely used in generic industrial control scenarios because of its advantages of simple reliability and strong robustness [16]. In this study, closed-loop feedback control is adopted, while the control structure diagram of its servo system is shown in Figure 9. The controller compares the expected setting value to the actual measured displacement feedback value of the grating ruler, deriving a deviation , which acts as the basis for the PID controller to adjust the PMSM actuator to realize the precise control of the piston rod displacement and control the filling amount of lipstick material.

##### 4.2. PID Control Strategy Based on PSO

PID parameter optimization is to set and adjust the parameters , , and in each sampling period. From the optimization point of view, based on PSO-PID parameter optimization, each particle corresponds to a group of PID parameters, whereas the most appropriate PID parameter value is found through iteration within the range of this group of parameters so that the control system can meet the design requirements [17, 18]. Based on the basic particle swarm optimization algorithm [19], the inertia weight *ω* is introduced, to obtain the velocity update formula of the standard particle swarm optimization algorithm as follows:

represents the influence of particle velocity at time “*t*” on particle velocity at time (*t* + 1), which is the inheritance of previous particle velocity; is positively correlated with particle global search ability and negatively correlated with particle local search ability [20].

The structure diagram of PSO-PID parameter optimization control is illustrated in Figure 10.

The system performance evaluation index is input, acting as the fitness function of the PSO algorithm. In every iteration, the fitness values, corresponding to all particles, are calculated, while the individual optimal and optimal global particles are determined and selected. At the end of the iteration, the position of the optimal global particle is taken as the optimal PID parameter [21].

The aforementioned system performance evaluation index (fitness function value) adopts the ITAE performance index as the fitness function in this paper.

The smaller the *J* value is, the closer the corresponding particles are to the global optimal solution position, so the fitness function gradually decreases, as the number of iterations progresses. The widely used PID parameters, obtained from the easy-to-implement ITAE evaluation index, can ensure that the system shows good stability, rapid response and small overshoot.

The PSO-PID parameter optimization process is shown in Figure 11.

##### 4.3. Analysis of Simulation Results

In order to verify the effectiveness of the PSO-PID control strategy in improving the performance of the lipstick filling servo system, a PID control system simulation model is built in the Simulink simulation environment as shown in Figure 12. Considering the transfer function of the lipstick-filling servo system as the controlled object, the PSO realization program is designed, based on MATLAB, and the PID control system simulation model is built, based on Simulink, with the step signal of the system as the input, the sampling period at 0.001 s, while the PID parameter optimization simulation operation is realized by combining the PSO program.

The traditional PID controller adopts the engineering tuning method to determine the parameters. The unit step response of the system as illustrated in Figure 13 shows that under the traditional PID control, the system regulation time is about 2.2 s, and the maximum overshoot is 58%, which inhibits the effective tracking of the system.

The parameter settings of PSO-PID are as follows: particle swarm size is initialized at 100; search space range between , , and is 0, 10; the dimension of space is 3, maxIter = 100, learning factors = = 1.5, = 1, = −1, minFit = 0.01.

After 100 iterations, PSO-PID parameters , and are 4.2, 10, and 0.284, respectively. Its performance index ITAE convergence curve is shown in Figure 14, while the adaptive value is 0.048. PSO-PID controller shows good searchability and convergence speed. The unit step response curve, obtained after PSO-PID parameters calculation, is illustrated in Figure 15. PSO-PID control strategy reduces the system regulation time to 0.7 s, while the maximum overshoot is 35%, which shows that the particle swarm optimization strategy leads to a faster system response and better control quality than the traditional PID control. It meets the control requirements of fast, accurate, and stable, while it improves the stability and filling accuracy of the lipstick-filling system.

#### 5. Prototype Experiment of Lipstick-Filling Machine

The prototype of the filling servo system is shown in Figure 16.

In this experiment, at 22°C constant room temperature, with no electromagnetic interference and no dust, the lipstick-filling task, under the traditional PID control and the PSO-PID control strategy is realized using the rotary table type lipstick-filling prototype. The whole production process of lipstick from material heating, filling, cooling, demolding, and capping to finished product is completed, while the filling effect is characterized by the weight of the sample material body and whether the detected filling accuracy meets the error limit requirement of [22].

The traditional PID control strategy is adopted in the filling experiment of the prototype. After 30 minutes of stable operation, 12 unformed lipstick samples of 3 g, 4.5 g, and 5 g lipstick-filling specifications are randomly sampled for testing. Figure 17 shows the lipstick samples to be tested. The experimental results are listed in Table 2.

According to the experimental data in Table 2, in 3 filling volume cases, the maximum error value of filling the net content of 36 lipstick casings is 160 mg, while the qualified rate is only 89%.

Under the same experimental conditions, the lipstick-filling experiment was carried out under the PSO-PID control strategy. Then, 12 samples were randomly checked, regarding lipstick filling specifications of 3 g, 4.5 g, and 5 g, producing the experimental results listed in Table 3.

According to the experimental data in Table 3, in 3 filling volume cases, the filling qualification rate of 36 lipsticks is 97%, basically meeting the net content error requirement of product quality inspection.

#### 6. Conclusion

According to the strict requirements of modern filling production for precision and stability and based on the advanced lipstick production process, a turntable lipstick-filling machine is designed and a solution for the bubble effect, featuring an elastic connecting rod type vibration device, is presented. According to the simulation results, the vibration displacement of the working mass is 2.39 mm, which meets the design requirements. Based on PMSM, the mathematical model of the lipstick-filling servo system is built, the transfer function of the lipstick-filling servo system is obtained, while the simulation model of the system step response is made, showing adjustment time at 3 s. The Simulink simulation model is built under the control strategy of traditional PID and PSO-PID. The simulation results show that the system regulation time is about 2.2 s, and the maximum overshoot is 58% under the traditional PID. Under the PSO-PID control, is 0.7 s and the maximum overshoot is 35%. This result shows a faster system response than one of the traditional PID control schemes. In the experiment on lipstick-filling, the qualified rate of the traditional PID control is only 89%, whereas the respective rate of the PSO-PID control is 97%. The turntable lipstick-filling machine, based on particle swarm optimization, can meet the production requirements of high precision and high stability.

#### Data Availability

The data used to support the findings of this study are included within the article.

#### Conflicts of Interest

The authors declare that they have no conflicts of interest.

#### Acknowledgments

The author wishes to acknowledge the study and training Project of Excellent Young Backbone Talents in Colleges and Universities in Anhui Province (gxgwfx2020055), School-level Scientific Research Project of Anhui Polytechnic University (Xjky2020006), Industrial Collaborative Innovation Special Fund Project of Anhui Polytechnic University - Jiujiang District (2021cyxtb10), Practice and Innovation Project of Graduate Students in Anhui Polytechnic University (Y412021022/Y412021003), and Key University Science Research Project of Anhui Province (KJ2021A0489).