An optimization algorithm for a better PID controller

A controller of a manipulator has studied and discussed for many years. However, many problems in controlling the precise position of the end effector are still continuing to be studied. To solve the precision of the Robot, two problems are attended. The first thing is to find the accuracy model of dynamics. The second thing is a controller for control law. However, it is so difficult to find an accurate model or differential equations of motion which is similar to the true manipulator. In addition, some unknown influences on the manipulator will make the accurate differential equations unworthy. Thus, a control algorithm will be introduced with PID controller which coefficients Kp, Kd, Ki are compensated by compensator found from optimization algorithm. With the new algorithm, the results have proved the stability and precision are better.

In the recent years, the control of manipulators with high stability and precision is required highly.The reason for this requirement is that the industrial market needs higher precision products.
To control accurately the manipulator, an exact dynamic equation must be shown.However, due to factors such as friction, saturation of actuators, and highly varying loads, the manipulator model becomes uncertain.Many approaches have proposed to solve the problems of control the manipulator with the uncertain nature of tracking.
In [1], adaptive controllers assume that the unknown nonlinear dynamics of the system is linearly parameterized.Therefore, there are some errors in the controller that makes the tracking little inaccuracy.To solve this problem, some approaches [2], [3] have ideas to linearize in certain intervals.In each interval, they will use technics such as neural network, Fuzzy, etc. to choose the Kp, Ki, Kd so that the Robot arm will track the reference line accurately.In [4], the authors use the robust controller to control the Robot arms.In this research, a compensator is used to compensate the lag into the robust controller.As a result, the tracking errors decrease when it is compared with (to?) the traditional robust controller.The approaches above have same the purpose that they change the controller to adapt the change of external environment.In these cases, the Robot models are not accurate.In [5], the exact robot model is found by Genetic Algorithm (GA).It is shown that GAs are able to find robot parameters effectively even if the robot has low resolution position encoders.With approaches showed, they will go 2 ways to obtain the good tracking.In the first way, parameters consisting of mass, centroid, mass moment of inertia, etc. will be determined.Based on the parameters, the controller will be designed.This way will is only good for simulation because some factors pre-unknown can appear in reality.In the second way, the controller will be designed to track the trajectory well.It does not mean a robust controller.That is the controller will change due to external factors.The changes will be controlled by some algorithms such as fuzzy, neuron.
In this paper, we will introduce a method to control a manipulator with 6 degrees of freedom.This is an old manipulator and restored for gluing the shoe sole.Thus, the robot parameters are not pre-known exactly.This method still uses a traditional PID controller, and then we use the optimization algorithm to obtain a better controller to track the trajectory.The paper will be divided into 6 sections.The next section will introduce how to find the state equation of the manipulator.The optimization algorithm is then shown and after that the experiments with real manipulator are done.The last section is discussions and conclusions of this study.

2.PARAMETERS OF THE MANIPULATOR
In a general case, the Lagrange dynamic equation of a manipulator can be written as follows.
where q is n  1 vector of joint position, ̇ is n  1 vector of joint velocity, () is inertia matrix.

Figure 1. Robot MOTOMAN -SV3X
Because the manipulator is a secondhand one, the control driver and the motor have been changed.From [6,7], the dynamics of the controlled motors via gears is shown in Eq. ( 2).
Where i are vectors of armature current, u are vectors of applied armature voltage.R, L and   are matrices of armature assistance, armature inductance and counter-electromotive force (EMF) constant of motor, respectively.The motor torque at each motor shaft is given by: There is set of gear in each joint and the relation between motor shaft position and joint position is as follows: where N is the matrix of gear ratio.Similarly, the relation between the motor torque and the applied torque at the joint is given by: From Eq. ( 1) to (4), we can obtain a new equation: where   = (  ) −1 ,   = (  ) −1 and   =   .Then, insert Eq. ( 6) into Eq.( 1), the combination becomes:

3.CONTROLLING ROBOT ARM
The mission is to control a manipulator to follow a tracking pre-defined.The tracking curve is closed one.The curve is divided into several small parts with starting point and ending point.
The control algorithm will control the robot arm from starting point to the ending point of each part and then the robot arm continue to move to the next part with a new starting point and ending point.With each part, we will have tracking error  ̃ which is defined as follows: where   is position of ending point of each part in generalized coordinate.From Eq. ( 7) and ( 8), the state vector can be written as Eq. ( 9).
The Eq. ( 7) can be rewritten as follows: This is an equation of linear feedback with parameters known.However, the function M() and D() are estimated.Assume that M() and D() are replaced by  0 () and  0 (), repectively.
Following the study in [6], the control law  will be given: where  0 +  0   (3) is linear terms.Terms  1 ,  2 and  3 are diagonal matrix that be designed to adapt with differences between true and nominal system. 0 is an auxiliary control signal to reduce the effect of the differences.
Making it simpler, Eq. ( 14) can be re-written: where From Eq. ( 15), we must design u 0 so that the effect of unknown plant f and disturbance d is minimized.In this case, we will choose u 0 as follows where u e is output of the simulating controller that parameters are from Motoman Robot manufacturer.  is a compensator which is found by optimization algorithm.

4.OPTIMIZATION ALGORITHM
In this section, algorithm will find an optimal   .With an optimal   , effects of f and d to the system are minimized.To find an optimal   , we will measure the output of the simulating manipulator and then that of real one.The difference between the two outputs will be used to train   by optimization algorithm.

In a typical optimization problem, procedures include 3 parts [8] as follows:
The part one is to define an optimization or mathematical programing problem.It can be expressed as follows.
which minimizes the function where X is n dimensional vector called the design vector.F(X) is the objective function The part one will help the designer understand which the objective is prioritized.Sometime, they have more than one objective function.In this case, to construct an overall objective function as a linear combination of the conflicting multiple objective functions.
Part 2 concerns the design of constraint.Here, restrictions must be satisfied to produce an acceptable design.In illustration, the constraints are expressed as inequalities or equations as follows.
g j (X) ≤ 0 with j = 1,2, … , m and h k (X) = Part 3 is to solve the objective function F(X) to find the design values X make F(X) optimal with the constraints given.
In the optimization problem to find the optimal   , we assigned   in position of X, the difference of two output called   was in position of F(X).
The constraints in this problem are unnecessary.
To minimize the effect of f and d, we must minimize function   .The algorithm to do this work is shown in Fig. 2.

Calculate the difference between real and simulating output f e
Define the vector The first work of the algorithm is to assign   a certain value.In our experiment,   is assigned the value of   , where   is output of simulating controller with PID.Next, we run the robot and record the output from encoder, then calculate   .
If   >> 0, we change vector   with two ways positive and negative direction.With each direction, we make the experiment and simulation and then make the difference   .Which   makes   smaller will be chosen for next step.The loop will stop when   ≈ 0. When the loop stops, the optimal   is achieved.

5.EXPERIMENTAL RESULTS
As described in section 4, experiment includes test on the real manipulator and simulation with parameters of the real manipulator too.The real manipulator is shown in Fig. 3.  4 is the result of simulation (Fig. 5) with same PID controller.The maximum difference between two outputs is assigned   .
Because   ≫ 0, the loop will start.This time, the controller of the real manipulator is assigned PID and a compensator   as Eq. ( 17) and the controller of simulating manipulating is not changed.In this case,   is found by the optimization algorithm in section 4.After each loop, the output result of real manipulator will be recorded and compare with that of simulating manipulator using PID.The results of experiment will be shown in Fig. 6a to 6d.After each loop, we change vector   to the optimal direction.Value   is from 2.2 mm in first experiment (Fig. 4) to 0.1 mm in the last experiment (Fig. 6d).With this result, we can almost obtain the controller for a manipulator with an output same as simulation.

6.CONCLUSION
This paper introduces an algorithm to find a better controller from the traditional PID controller.The new controller considers a compensation for PID controller.The new controller will decrease the effect of unknown facts.From the experiment to control a manipulator, the output due to new controller is almost same as the simulation result.When all curves are applied to the new controller, the compensator for each part of the curve is maybe different.Thus, we must make the experiment for each part to find the best compensator.

Figure 2 .
Figure 2. Flowchart of finding the u f by using optimization algorithm

Figure 3 .
Figure 3. Real Robot and tracking line

Figure 4 .
Figure 4. Output from simulation and real robot