###### Abstract  
In this paper, a nonlinear PID (NLPID) controller is used to replace a traditional PID controller to overcome the influence of nonlinear factors in the computer numerical control (CNC) system. A particle swarm optimization based on a generalized opposition-based learning (G-PSO) algorithm is proposed to optimize the NLPID controller. The convergence speed and global optimization ability of the particle swarm optimization (PSO) algorithm are improved by introducing generalized opposition-based learning. The natural selection mutation is introduced into the G-PSO algorithm to further avoid the particles falling into local optimization. Different from the existing research, this paper designs a special fitness function according to the control objectives of improving system response speed and suppressing overshoot. By comparing the differential evolution (DE) algorithm, the ant lion optimizer (ALO) and the genetic algorithm (GA) through simulation, it is proven that the G-PSO algorithm has a faster convergence speed and better global optimization ability. Compared to Fuzzy PID and MRAC PID, G-PSO NLPID is shown to be more suitable for CNC systems. Additionally, it is proven through experiments that the rise time and settling time of the NLPID controller optimized by the G-PSO algorithm are 22.22% and 24.52% faster, respectively, than the traditional PID controller, and the system overshoot is successfully suppressed. opposition-based learning; particle swarm optimization; nonlinear PID controller; CNC system +
Footnote †: journal:  
because the convergence of heuristic algorithms can ensure that the parameters obtained are better [7; 8]. Reference [9] uses a genetic algorithm (GA) to tune the parameters of an NLPID controller in unmanned aerial vehicles system, references [10; 11] use an artificial bee colony (ABC) algorithm and a differential evolution (DE) algorithm, respectively, to tune the parameters of NLPID controller in continuous stirred tank reactor. Additionally, the ant lion optimizer (ALO) [12], monkey-multiagent algorithm [13], harmony search algorithm [14], boosting algorithm [15], and particle swarm optimization (PSO) algorithm have also been used for PID controller parameter tuning. The PSO algorithm is widely used in PID controller parameter tuning because of its advantages of fast convergence speed, good robustness, and easy-to-design fitness function. References [16; 17] prove that the PSO algorithm is better than the GA, ABC algorithm, and whale optimization algorithm in tuning PID controller parameters. Researchers use crossover and mutation operations, Hoo theory, and beetle antennae search, etc., to improve the PSO algorithm, and the improved algorithms are used to tune the PID controller parameters to obtain more ideal control parameters [18; 19; 20; 21; 22]. Reference [23] uses an adaptive PSO algorithm to tune the parameters of an NLPID controller. Compared to the PSO algorithm, this algorithm has more advantages in convergence speed and global optimization. Although different improvements have been carried out in these aforementioned studies, only the overshoot and the response speed are considered. For CNC systems that require high control accuracy and faster control speed in real-time, it is still desirable to have an improved PSO algorithm for controller optimization to accelerate the system response speed, suppress the overshoot, and obtain high steady-state accuracy. [PERSON] proposed opposition-based learning (OBL) in 2005 [24]. [PERSON] proved that the OBL-based intelligent optimization algorithm converges faster [25]. [PERSON] et al. proposed generalized opposition-based learning (GOBL) as an improvement to OBL [26]. Inspired by this characteristic of GOBL, a GOBL-based PSO (G-PSO) algorithm was proposed for controller parameter optimization. In the proposed method, GOBL and natural selection mutation are adopted to improve the convergence speed and global optimization ability.