• 沒有找到結果。

IPS Controlled by HNN Controller Trained by Nonlinear Reference

Chapter 3 Control of Inverted Pendulum System (IPS)

3.4 Simulation Result

3.4.4 IPS Controlled by HNN Controller Trained by Nonlinear Reference

To examine the ability of HNN controller to mimic the nonlinear reference controller, we use the following equation as the nonlinear reference controller of IPS:

)

Let the IPS initial angle=20 degree and initial angular speed=20 degree/sec, and the simulation time=20 sec. We can get the following three figures of IPS controlled by the nonlinear reference controller:

Fig-3.30. The control force of the nonlinear reference controller

Fig-3.31. The output angle of IPS controlled by the nonlinear reference controller

Fig-3.32. The output angular speed of IPS controlled by the nonlinear reference controller

We use the same parameters of HNN controller: the resistor=1(ohm), the capacitor=0.01(Farr), the amplification constant=-30, the learning rate=0.001, and 10 epochs for training, and we show the training process as the following two figures:

Fig-3.33. The total error Jt(epo) and the last epoch error J(k,10)

Fig-3.34. The last epoch training iteration process ofw11,w12,w21 and w22 By the simulation, we find the values ofw11,w12,w21 and w22, and we write it down as(w11,w12,w21,w22)=(0.1846,0.1876,0.1846,0.1876).Then, we show the following four figures as simulation result of IPS controlled by trained HNN controller:

Fig-3.35. The control forces of IPS: nonlinear reference controller (dash line) and

HNN controller (solid line)

Fig-3.36. The output angles of IPS: reference controller (dash line) and HNN controller (solid line)

Fig-3.37. The output angular speeds of IPS: reference controller (dash line) and HNN controller (solid line)

Fig-3.38. The node 1 (2) voltage v1 (v2) of the HNN circuit

3.4.5 IPS Controlled by HNN Controller Trained by Nonlinear Reference Controller with Different Initial State

We use the following examples to examine the abilities of HNN controllers to control IPS with initial state different from the initial state of training the HNN controller by the nonlinear reference controller. We let the values ofw11,w12,w21 and w22 be the same with section 3.4.4, so (w11,w12,w21,w22)=(0.1846,0.1876,0.1846,0.1876) is fixed for the initial state of IPS: the initial angle=20 (degree) and initial angular speed=20 (degree/sec) in the training phase. And then, we will examine the following pairs (initial angle (degree), initial angular speed (degree/sec)) of the initial state of IPS: (30, 30), and (10, 10) in the working phase as the following figures:

Fig-3.39. The control forces of IPS with initial angle=30 degree, initial angular speed=30 degree/sec: the nonlinear reference controller (dash line) and HNN

controller (solid line)

Fig-3.40. The output angles of IPS with initial angle=30 degree, initial angular speed=30 degree/sec: the nonlinear reference controller (dash line) and HNN

controller (solid line)

Fig-3.41. The output angular speeds of IPS with initial angle=30 degree, initial angular speed=30 degree/sec: the nonlinear reference controller (dash line) and HNN

controller (solid line)

Fig-3.42. The node 1 (2) voltage v1 (v2) of the HNN circuit with IPS initial angle=30 degree, initial angular speed=30 degree/sec

Fig-3.43. The control forces of IPS with initial angle=10 degree, initial angular speed=10 degree/sec: the nonlinear reference controller (dash line) and HNN

controller (solid line)

Fig-3.44. The output angles of IPS with initial angle=10 degree, initial angular speed=10 degree/sec: the nonlinear reference controller (dash line) and HNN

controller (solid line)

Fig-3.45. The output angular speeds of IPS with initial angle=10 degree, initial angular speed=10 degree/sec: the nonlinear reference controller (dash line) and HNN

controller (solid line)

Fig-3.46. The node 1 (2) voltage v1 (v2) of the HNN circuit with IPS initial angle=10 degree, initial angular speed=10 degree/sec

Chapter 4

Control of Ball and Beam System (BABS)

4.1 Dynamics of Ball and Beam System (BABS)

θ3 the ball is R=0.01(m); the gravity acceleration is G.=9.8(m/s ); the torque applied to 2 the beam is f (nt-m). With the ball positionθ1 , the ball velocityθ2, the beam angleθ3, and the beam angular speedθ4, we can get the equations bellow:

0

And we define

R2

B , and we can get the equations bellow:

2

We substitute the values of B, G, M, P, P above, and we can get the following b

4.2 Simulation of BABS Controlled by Reference Controller

We use the following equation as reference controller of BABS:

4 where f is the control torque. Let the BABS initial position (ball’s position) =0.2 meter, initial velocity (ball’s velocity) =0 meter/sec, initial angle (beam’s angle) =10 degree and initial angular speed (beam’s angular speed) =0 degree/sec, and the simulation time=15sec. With equation (4-7) and (4-8), we can get the results of the BABS controlled by the reference controller, and we can show them in the following figures.

Fig-4.2. The control torque of the reference controller

Fig-4.3. The ball’s position of BABS controlled by the reference controller

Fig-4.4. The ball’s velocity of BABS controlled by the reference controller

Fig-4.5. The beam’s angle of BABS controlled by the reference controller

Fig-4.6. The beam’s angular speed of BABS controlled by the reference controller

4.3 Architecture and Algorithm of Weighting Training

Fig-4.7. The architecture of the BABS controlled by the HNN controller in the training phase

We use the following parameters of HNN controller: the resistor=1(ohm), the capacitor=0.01(Farr), the amplification constant=-30, and the learning rate=0.001.

In the training phase, we note that the Hopfield neural network (HNN) doesn’t control the ball and beam system (BABS). So we can imagine that when train w11, w12, w , 13

w14, w21, w22, w , 23 w24, w , 31 w , 32 w , 33 w , 34 w41, w42, w and 43 w44 by the set of (u,

θ

1,d1,

θ

2,d2,

θ

3,d3,

θ

4,d4)(the value of the set is corresponding to this moment time t1), the time of the reference controller and the BABS pauses until the HNN circuit is in the steady state. And we continue to train w11, w12, w , 13 w14, w21, w22, w , 23 w24, w , 31 w , 32 w , 33 w , 34 w41, w42, w and 43 w44 by the next set of (u,

θ

1,d1,

θ

2,d2,

θ

3,d3,

θ

4,d4) (the value of the “next set” is corresponding to the next moment time t2).

So we can consider that in the training phase, the circuit is already in the steady state, so no current passes to the four capacitors C (it equals that the four capacitors C are open, C=0), so we can get the equations bellow (by the circuit theorem: the voltage drop equals the multiplication of the resistance and the current):

4

And we have the equation bellow (by the circuit theorem: current equals the multiplication of the conductance and the voltage):

)

And the effect ofϕ(•) is as voltage amplifier, so we can write the equations bellow:

And the equation of the output of Hopfield neural network, the HNN controller‘s control signal f is bellow:

We define the error J as the measurement of the half squared distance between the reference controller’s control signal f and the HNN controller’s control signalf . And we write the equation bellow:

)2 half squared distance between the reference controller’s control signal f and the HNN controller’s control signal f will be smaller. How can we reach this task? We can deal it by training thew11, w12, w , 13 w14, w21, w22, w , 23 w24, w , 31 w , 32 w , 33 w , 34 w41, w42, w and 43 w44 with the steepest descent method. Let us take w11 for example to show how it to be trained. First, we can write the equation bellow to show how we get the better next value ofw11:

11 Where η is the learning rate, and we should calculate the value of

w11

J

∂ . We can

use the chain rule to write the equation bellow:

11 From the equation (4-13), we have the equation bellow:

) From the equation (4-12), we have the equation bellow:

camp From the equation (4-11), we have the equation bellow:

2

From the equation (4-9), (4-10), we have the equation bellow:

)

So, from the equations (4-15), (4-16), (4-17), (4-18) and (4-19), we have equation bellow:

Substitute equations (4-20) to the equations (4-14), we have equation bellow:

)

)

x1

Fig-4.8. The architecture of the BABS controlled by HNN controller

In the working phase, the HNN is a real time controller, responding to control the BABS. The value of the set ofw11, w12, w , 13 w14, w21, w22, w , 23 w24, w , 31 w , 32

w , 33 w , 34 w41, w42, w and 43 w44 is fixed. And as a real time controller, the circuit is dynamic, so we cannot ask the circuit always in the steady state, so we should know that the current passing the both capacitors C is not always zero.

Actually, it is very complicated to calculate the output of BABS. In the working phase, the architecture is the recurrent neural network. The output of BABS is(

θ

1(t),

θ

2(t),

θ

3(t),

θ

4(t)), and (

θ

1(t),

θ

2(t),

θ

3(t),

θ

4(t)) will affect the values of the current(i1(t),i2(t),i3(t),i4(t)), and the current(i1(t),i2(t),i3(t),i4(t)) will affect the values of the voltage(v1(t),v2(t),v3(t),v4(t)), and the time-varying current passing the capacitors will affect the values of the voltage

)) the control signal f(t) will affect the output of the BABS

)) recurrent control system. So we don’t calculate the analytic solution of this system.

Instead, we try to use the numerical method to simulate this system.

4.4 Simulation Result

4.4.1 Seeking for Weighting Factors

First, we should try to seek a good set ofw11, w12, w , 13 w14, w21, w22, w , 23 w24, w , 31 w , 32 w , 33 w , 34 w41, w42, w and 43 w44. With the equations (4-21), (4-22), (4-23), (4-24), (4-25), (4-26), (4-27), (4-28), (4-29), (4-30), (4-31), (4-32), (4-33), (4-34), (4-35)and (4-36), and we may use many training epochs for get better training results. And we can show that the total error during the whole time is the function of the epoch number and the error is the function of the time(last epoch for example) in the following figure, Fig-4.9, and we can find that using 20 epochs is good enough for simulation.

Fig-4.9. The total error Jt(epo) and the last epoch error J(k,20)

By the simulation, we can find a good set ofw11, w12, w , 13 w14, w21, w22, w , 23 w24, w , 31 w , 32 w , 33 w , 34 w41, w42, w and 43 w44, and we write it down as following equation in the matrix form:

⎥⎥ the whole time and every epoch, and we can show the training iteration process (in the last epoch) in the whole time by the following figures:

Fig-4.10. The last epoch training iteration process ofw11,w12,w and 13 w14

Fig-4.11. The last epoch training iteration process ofw21,w22,w and 23 w24

Fig-4.12. The last epoch training iteration process ofw ,31 w ,32 w and 33 w 34

Fig-4.13. The last epoch training iteration process ofw41,w42,w and 43 w44

4.4.2 BABS Controlled by HNN Controller Trained with the Same Initial State

After we have the values of the good set ofw11, w12, w , 13 w14, w21, w22, w , 23 w24, w , 31 w , 32 w , 33 w , 34 w41, w42, w and 43 w44, we can begin to run the simulation of the BABS controlled by the HNN controller in real time. We use the Matlab with the 4th order of Runge-Kutta formula to simulate it. Because its nonlinearity is very high, so we use the 4th order of Runge-Kutta formula to simulate BABS controlled by HNN controller. By the simulation, we can get the following figures as the results:

Fig-4.14. The control torques of BABS: reference controller (dash line) and HNN controller (solid line)

Fig-4.15. The ball’s positions of BABS: reference controller (dash line) and HNN controller (solid line)

Fig-4.16. The ball’s velocities of BABS: reference controller (dash line) and HNN controller (solid line)

Fig-4.17. The beam’s angles of BABS: reference controller (dash line) and HNN controller (solid line)

Fig-4.18. The beam’s angular speeds of BABS: reference controller (dash line) and HNN controller (solid line)

Fig-4.19. The node 1 voltage v1 of the HNN circuit

Fig-4.20. The node 2 voltage v2 of the HNN circuit

Fig-4.21. The node 3 voltage v of the HNN circuit 3

Fig-4.22. The node 4 voltage v4 of the HNN circuit

4.4.3 BABS Controlled by HNN Controller after Trained with Different Initial State

We use the following examples to examine the abilities of HNN controllers to control BABS with initial state different from the initial state of training the HNN controller.

We can let the values ofw11, w12, w , 13 w14, w21, w22, w , 23 w24, w , 31 w , 32 w , 33

is fixed for the initial state of BABS: the initial position of the ball=0.2 (meter),the initial velocity of the ball=0 (meter/sec),the initial angle of the beam=10 (degree), and the initial angular speed of the beam of the BABS=0 (degree/sec) in the training phase.

And then, we will examine the following sets (initial position (meter), initial velocity (meter/sec), initial angle (degree), initial angular speed (degree/sec)) of the initial state of BABS: (0.1, 0, 5, 0) and (0.4, 0, 20, 0) in the working phase as the following figures:

Fig-4.23. The control torques of BABS with initial ball’s position=0.1 meter, initial beam’s angle=5 degree: reference controller (dash line) and HNN controller (solid

line)

Fig-4.24. The ball’s positions of BABS with initial ball’s position=0.1 meter, initial beam’s angle=5 degree: reference controller (dash line) and HNN controller (solid

line)

Fig-4.25. The ball’s velocities of BABS with initial ball’s position=0.1 meter, initial beam’s angle=5 degree: reference controller (dash line) and HNN controller (solid

line)

Fig-4.26. The beam’s angles of BABS with initial ball’s position=0.1 meter, initial beam’s angle=5 degree: reference controller (dash line) and HNN controller (solid

line)

Fig-4.27. The beam’s angular speeds of BABS with initial ball’s position=0.1 meter, initial beam’s angle=5 degree: reference controller (dash line) and HNN controller

(solid line)

Fig-4.28. The node 1 (2) (3) (4) voltage v1 (v2) (v ) (3 v4) of the HNN circuit with BABS initial ball’s position=0.1 meter, initial beam’s angle=5 degree

Fig-4.29. The control torques of BABS with initial ball’s position=0.4 meter, initial beam’s angle=20 degree: reference controller (dash line) and HNN controller (solid

line)

Fig-4.30. The ball’s positions of BABS with initial ball’s position=0.4 meter, initial beam’s angle=20 degree: reference controller (dash line) and HNN controller (solid

line)

Fig-4.31. The ball’s velocities of BABS with initial ball’s position=0.4 meter, initial beam’s angle=20 degree: reference controller (dash line) and HNN controller (solid

line)

Fig-4.32. The beam’s angles of BABS with initial ball’s position=0.4 meter, initial beam’s angle=20 degree: reference controller (dash line) and HNN controller (solid

line)

Fig-4.33. The beam’s angular speeds of BABS with initial ball’s position=0.4meter, initial beam’s angle=20 degree: reference controller (dash line) and HNN controller

(solid line)

Fig-4.34. The node 1 (2) (3) (4) voltage v1 (v2) (v ) (3 v4) of the HNN circuit with BABS initial ball’s position=0.4 meter, initial beam’s angle=20 degree

4.4.4 BABS Controlled by HNN Controller Trained by Nonlinear Reference Controller with the Same Initial State

To examine the ability of HNN controller to mimic the nonlinear reference controller, we try to find the nonlinear reference controller of BABS. First, we use the functions fball and fbeamsimilar to 3.4.4 as the following equations.

)

Equations (4-38) and (4-39) represent the necessary control torques of ball and beam, respectively. So the total necessary control torque is the sum of (4-38) and (4-39).

beam ball f f

f = + (4-40) We use the equation (4-40) (with equations (4-38) and (4-39)) as the nonlinear

reference controller of BABS.

Let the BABS initial position (ball’s position) =0.2 meter, initial velocity (ball’s velocity) =0 meter/sec, initial angle (beam’s angle) =10 degree, initial angular speed (beam’s angular speed) =0 degree/sec, and the simulation time=15sec. We can get the following five figures of BABS controlled by the nonlinear reference controller:

Fig-4.35. The control torque of the nonlinear reference controller

Fig-4.36. The ball’s position of BABS controlled by the nonlinear reference controller

Fig-4.37. The ball’s velocity of BABS controlled by the nonlinear reference controller

Fig-4.38. The beam’s angle of BABS controlled by the nonlinear reference controller

Fig-4.39. The beam’s angular speed of BABS controlled by the nonlinear reference controller

We use the same parameters of HNN controller: the resistor=1(ohm), the capacitor=0.01(Farr), the amplification constant=-30, the learning rate=0.001, and 200 epochs for training, and we show the training process as the following two figures:

Fig-4.40. The total error Jt(epo) and the last epoch error J(k,200)

Fig-4.41. The last epoch training iteration process of

w11(w21,w ,31 w41),w12(w22,w ,32 w42),w (13 w ,23 w ,33 w ) and 43 w14(w24,w ,34 w44) So, we find the values ofw11, w12, w , 13 w14, w21, w22, w , 23 w24, w , 31 w , 32 w , 33 w , 34 w41, w42, w and 43 w44, and we write it down as following equation in the matrix form:

⎥⎥

Then, we show the following six figures as simulation result of BABS controlled by trained HNN controller:

Fig-4.42. The control torques of BABS: the nonlinear reference controller (dash line) and HNN controller (solid line)

Fig-4.43. The ball’s positions of BABS: the nonlinear reference controller (dash line) and HNN controller (solid line)

Fig-4.44. The ball’s velocities of BABS: the nonlinear reference controller (dash line) and HNN controller (solid line)

Fig-4.45. The beam’s angles of BABS: the nonlinear reference controller (dash line) and HNN controller (solid line)

Fig-4.46. The beam’s angular speeds of BABS: the nonlinear reference controller (dash line) and HNN controller (solid line)

Fig-4.47. The node 1 (2) (3) (4) voltage v1 (v2) (v ) (3 v4) of the HNN circuit

4.4.5 BABS Controlled by HNN Controller Trained by Nonlinear Reference Controller with Different Initial State

We use the following examples to examine the abilities of HNN controllers to control IPS with initial state different from the initial state of training the HNN controller by the nonlinear reference controller. We let the values ofw11, w12, w , 13

w14, w21, w22, w , 23 w24, w , 31 w , 32 w , 33 w , 34 w41, w42, w and 43 w44 be the same with section 4.4.3 as the equation (4-41):

⎥⎥

is fixed for the initial state of BABS: the initial position of the ball=0.2 (meter),the initial velocity of the ball=0 (meter/sec),the initial angle of the beam=10 (degree), and the initial angular speed of the beam of the BABS=0 (degree/sec) in the training phase. And then, we will examine the following sets (initial position (meter), initial velocity (meter/sec), initial angle (degree), initial angular speed (degree/sec)) of the initial state of BABS: (0.1, 0, 5, 0) and (0.4, 0, 20, 0) in the working phase as the following figures:

Fig-4.48. The control torques of BABS with initial ball’s position=0.1 meter, initial beam’s angle=5 degree: the nonlinear reference controller (dash line) and HNN

controller (solid line)

Fig-4.49. The ball’s positions of BABS with initial ball’s position=0.1 meter, initial beam’s angle=5 degree: the nonlinear reference controller (dash line) and HNN

controller (solid line)

Fig-4.50. The ball’s velocities of BABS with initial ball’s position=0.1 meter, initial beam’s angle=5 degree: the nonlinear reference controller (dash line) and HNN

controller (solid line)

Fig-4.51. The beam’s angles of BABS with initial ball’s position=0.1 meter, initial beam’s angle=5 degree: the nonlinear reference controller (dash line) and HNN

controller (solid line)

Fig-4.52. The beam’s angular speeds of BABS with initial ball’s position=0.1 meter, initial beam’s angle=5 degree: the nonlinear reference controller (dash line) and

HNN controller (solid line)

Fig-4.53. The node 1 (2) (3) (4) voltage v1 (v2) (v ) (3 v4) of the HNN circuit

Fig-4.54. The control torques of BABS with initial ball’s position=0.4 meter, initial beam’s angle=20 degree: the nonlinear reference controller (dash line) and HNN

controller (solid line)

Fig-4.55. The ball’s positions of BABS with initial ball’s position=0.4 meter, initial beam’s angle=20 degree: the nonlinear reference controller (dash line) and HNN

controller (solid line)

Fig-4.56. The ball’s velocities of BABS with initial ball’s position=0.4 meter, initial beam’s angle=20 degree: the nonlinear reference controller (dash line) and HNN

controller (solid line)

Fig-4.57. The beam’s angles of BABS with initial ball’s position=0.4 meter, initial beam’s angle=20 degree: the nonlinear reference controller (dash line) and HNN

controller (solid line)

Fig-4.58. The beam’s angular speeds of BABS with initial ball’s position=0.4 meter, initial beam’s angle=20 degree: the nonlinear reference controller (dash line) and

HNN controller (solid line)

Fig-4.59. The node 1 (2) (3) (4) voltage v1 (v2) (v ) (3 v4) of the HNN circuit

Chapter 5

Discussion and Conclusion

5.1 Discussion of Parameters Setting

The resistance R of the HNN controller by the way that larger resistance causes larger node voltagev. Because a large voltage is not preferred, therefore a small R should be chosen. The time constant τ can be express as

=RC

τ , (5-1) which is the product of the resistance R and the capacitanceC. τ cannot be chosen too large because it leads to slow response. The amplification constant camp is also an important parameter of the HNN controller. According to the voltage amplifierϕ(•)=tanh(•), the output of a neuron of the HNN is limited between the values -1 to +1, we express as the following inequality.

1 ) tanh(

1≤ = ≤

xj vj (5-2) From the inequality (5-2), we can show that the output control signal of HNN controller is limited as

amp n

j j amp

amp u c x nc

nc ≤ = ≤

=

1

, (5-3) where n is the number of neurons in the HNN. That is the absolute value of the output control signal of the HNN controller is limited by the product of the amplification constant camp and the number of neuronsn.

The learning rate η must be a positive as we discussed in the section 2.3. The large η is not preferred because that will contradict (2-14) [7]. However η cannot be chosen too small or the weightings convergence will be too slow, so we use a proper value of the learning rate η to let the simulation process well.

The simulation time is chosen long enough so that the regulation state of the controlled system can be near the desired point.

The time interval is set to be a small enough value to get the required accuracy of the differential equations of the system controlled by the HNN controller.

In many cases one epoch is enough to achieve favorable training performance.

More training epoch is unnecessary unless one epoch training cannot achieve the preferred performance.

If we do not have prior knowledge of the proper weighting vector, we can just

simple initialize W from zero vector. Notice that the values of the elements of W are the same in the same column. This can be briefly explained as following. We note the equations (3-22) and (3-24), they are very similar. We write them down in the simple form to show the difference. For (3-22), the equation is w11(k+1)=w11(k)−...×{1−[tanh(v1)]2} , while for (3-24), the equation isw21(k+1)=w21(k)−...×{1−[tanh(v2)]2}. And we note the equations (3-10) and (3-11), we find if w11 =w21 andw12 =w22, then we can get i1 =i2 by equation (3-11), and furthermore, we can get v1 =v2 by equation (3-10). So it is interesting that because we set the initial values of all the weighting factors zeros, so

0

At last, the important facts are obtained as following:

n

It should keep in mind that the equation (5-4) is satisfied on the premise of the following:

After training the weighting factors of HNN controller, we find that the output (control signal) of HNN controller is approximated to the output (control signal) of the well-designed controller and the outputs of the plant controlled by the HNN controller are approximated to the outputs of the plant controlled by the well-designed controller. So, the trained HNN controller can be a good model of the well-designed controller with the controlled plant with the same initial state with HNN trained. Furthermore, although the weighting factors of HNN controller are trained by well-designed controller with the plant with initial state different from the

After training the weighting factors of HNN controller, we find that the output (control signal) of HNN controller is approximated to the output (control signal) of the well-designed controller and the outputs of the plant controlled by the HNN controller are approximated to the outputs of the plant controlled by the well-designed controller. So, the trained HNN controller can be a good model of the well-designed controller with the controlled plant with the same initial state with HNN trained. Furthermore, although the weighting factors of HNN controller are trained by well-designed controller with the plant with initial state different from the