Sunteți pe pagina 1din 8

NEURAL NETWORKS BASED CONTROLLER FOR DC MOTOR POSITION

Transfer Function
J = 3.2284E-6; %moment of inertia
b = 3.5077E-6; %motor viscous friction constant
K = 0.0274; %Gain
R = 4; %electric resistance
L = 2.75E-6; %electric inductance
s = tf('s'); %define transfer function
p_motor = K/(s*((J*s+b)*(L*s+R)+K*K)) %define transfer function

P_motor =

0.0274

-------------------------------------------

8.878e-12 s^3 + 1.291e-05 s^2 + 0.0007648 s

Continuous-time transfer function.

Figure 1 : Simulink Model for Motor Position


Simulink Model is constructed as shown above. The PID Controller tunes the output to finally
obtain peak overshoot of 9% as shown below.

1.2 X: 0.02192
Y: 1.09
1.1

0.9

0.8
amplitude

0.7

0.6

0.5

0.4

0.3

0.2

0 0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.16 0.18 0.2
time in sec

Figure 2 : PID tuned unit step response

After the data from SIMULINK is exported to WORKSPACE, we can convert the column
arrays to row arrays as this is the way the the neural net would accept the input and target pairs.

Then type:

>> nftool

A GUI presented for Neural Network Fitting Tool.

The network is TRAINED.


>> nftool

A GUI presented for Neural Network Fitting Tool as shown below. Inputs are named as
INPUT. Outputs are named as OUTPUT. Samples are being Matrix Rows

The training parameters inputted to the neural network to build a PID controller using neural
networks:
Checking the values of PERFORMANCE and REGRESSION:

The Performance plot should be such that the Mean Squared Error (MSE) is minima between
the Train and (Validation and Test). Below, it is seen that error is of the magnitude 10e-4

Best Validation Performance is 4.5765e-06 at epoch 10


2
10
Train
Validation
Test
Best
Mean Squared Error (mse)

0
10

-2
10

-4
10

-6
10
0 1 2 3 4 5 6 7 8 9 10
10 Epochs

The R values for Training set, Validation set, Test set, and overall. R should be as close to 1 as
possible.
Training: R=0.99936 Validation: R=0.99914

Output ~= 1*Target + -0.00011


Data Data

Output ~= 1*Target + 2e-06


1.5 1.5
Fit Fit
Y=T Y=T

1 1

0.5 0.5

0 0

0 0.5 1 1.5 0 0.5 1 1.5


Target Target

Test: R=0.99947 All: R=0.99934

Output ~= 1*Target + -1.1e-05


Output ~= 1*Target + 2.6e-05

Data Data
1.5 1.5
Fit Fit
Y=T Y=T

1 1

0.5 0.5

0 0

0 0.5 1 1.5 0 0.5 1 1.5


Target Target

The neural network equivalent is:

Now that the neural network is trained completely, the next step is to generate SIMULINK
DIAGRAM from the GUI itself. The scope colors appear as : Yellow, purple, blue.

Import the neural network model into the Simulink model:


figure();
plot(pid_controller_output3(:,1),pid_controller_output3(:,2),'r',pid_controll
er_output3(:,1),pid_controller_output3(:,4));
xlabel('time in seconds');
ylabel('unit step response');
legend('PID tuning','neural network tuning');
Step response obtained using PID Tuned system and Neural network tuned plant is obtained and
it is concluded that the neural network performs exactly the same manner as the PID tuner.

1.2 PID tuning


neural network tuning
1.1

0.9
unit step response

0.8

0.7

0.6

0.5

0.4

0.3
0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5
time in seconds

S-ar putea să vă placă și