# Pid Control Of A Servo System Computer Science Essay

Published: Last Edited:

This essay has been submitted by a student. This is not an example of the work written by our professional essay writers.

For this laboratory you will be required to complete all of the exercises listed in this script and write a report in which you:

Present and explain the results of your simulations.

Answer the questions from this lab script.

Provide and explain the code fragments that you have developed.

Each exercise includes a list of tasks (bullet points) that you need to complete. The tasks which are highlighted in bold indicate what information you should include in your final laboratory report.

Exercise 1: Compile and run the program

Figure1. Controller outputIn this exercise, I have chosen the Kp = 6, Ki = 0, Kd = 0. The observed values of the DC servo gave us 90 degrees overall without overshoot i.e. end to end. When we applied the controller for at least 30 seconds, then we saved the datas in the file data.txt as two columns. The first column corresponds to the controller output which is shown in figure1 along with the second column corresponds to the system response (potentiometer voltage) is shown in figure1a below. C:\Users\owner\Documents\doc.uni\S4\ACS214,ACS271\A3\PID2\figures\f11.jpg

Figure1a. System responseC:\Users\owner\Documents\doc.uni\S4\ACS214,ACS271\A3\PID2\figures\f1.jpg

As we can see from the figure 1a above, the system response without the overshoot is measured from approx 2v to -3v which means the overall voltage measured is 5 volts. This reassure the value is correct because the given effective range for V from handout is in fact: -2.5/+2.5 Volts i.e. 5 volts overall.

The main steps to examine the response of the system in matlab are as followed:

Run Matlab

Dt=1/30 ƒ¨ This define the sampling time

Sz=size(data,1); ƒ¨ Determine the number of samples available

plot([0:dt:(sz-1)*dt],data(:,1)); ƒ¨ Plot the controller output (first column)

plot([0:dt:(sz-1)*dt],data(:,2)); ƒ¨ Plot the system response (potentiometer voltage)

Next, when converting the potentiometer output Vp(Volts) into angular position Ø(degrees) we need to find the conversion constant v2deg to perform the process. V2deg is found by using the overall value V and the measured degrees.

5 volts ƒ¨ 90 degrees

1 volt ƒ¨ v2deg

So, v2deg is = 18.

The plot of the system response expressed in degrees is shown in figure1c below. C:\Users\owner\Documents\doc.uni\S4\ACS214,ACS271\A3\PID2\figures\f12.jpg

Figure1c. System response expressed in degrees.

Exercise 2: Proportional control of the servo system

This exercise will concentrate on how the proportional elements in PID control effect the system. After running the program for about 30-40 seconds with different values of proportional gain Kp. The responses of the systems are shown in figure below along with a table indicating what values of the Kp used in each figures and the details responses.

Kp

tr

tp

%Overshoot

ts

figure

3

0.2 s

None

None

0.1s

2a

## 2b

7

0.15s

0.15s

117.24

0.5s

2c

8

0.13s

0.15s

300

0.6s

2d

Kp= Proportional gain

tr = rise time (10%-90%)

ts = settling time(within 2%)

tp = peak time

Note: the above values are only approximation.f43.jpgf42.jpg

Figure2a. System response with Kp=3

Figure2a. Zoom version with Kp=3

Comments when Kp=3: As we can see from figure2a above, there is no overshoot when Kp=3 but the overall system is slower compare with the system when the value of Kp is increased. C:\Users\owner\Documents\doc.uni\S4\ACS214,ACS271\A3\PID2\figures\f23.jpgC:\Users\owner\Documents\doc.uni\S4\ACS214,ACS271\A3\PID2\figures\f22.jpg

Figure2b. Zoom version with Kp=6

Figure2b. System response with Kp=6

Comments when Kp=6: the response has an overshoot of around 127% but it gives faster response overall. The response details values i.e. settling time, rise time, etc are shown in the table above.C:\Users\owner\Documents\doc.uni\S4\ACS214,ACS271\A3\PID2\figures\f33.jpgC:\Users\owner\Documents\doc.uni\S4\ACS214,ACS271\A3\PID2\figures\f32.jpg

Figure2c.Zoom version with Kp=7

Figure2c. System response with Kp=7

Comments when Kp=7: The response starts to oscillate but increase the speed of response of the overall system. It has an overshoot of around 117% and increase the settling time of the response i.e. ts= 0.5seconds.

Figure2d. Zoom version with Kp=8

Figure2d. System response with Kp=8C:\Users\owner\Documents\doc.uni\S4\ACS214,ACS271\A3\PID2\figures\f53.jpgC:\Users\owner\Documents\doc.uni\S4\ACS214,ACS271\A3\PID2\figures\f52.jpg

Comments when Kp=8: the oscillation starts to increase and it also increases the settling time. However, it speeds up the overall system.

The system response stats to oscillate when the Kp is greater than 6 i.e. when Kp=7 it is oscillating as shown in figure2c above. In general, the system response becomes faster as the Kp increases and the settling time becomes bigger. However, the overshoot of the systems get bigger as Kp increases. The actuator saturation effects are caused by the physical system that could not exceed a certain boundary limit. If one exceed the limit than, the changing values in the actuator did not give any effects to the systems output. Moreover, the steady state error is hard to reduce if we only used the Kp as we can see from the figures above.

Exercise 3: Proportional control of the servo system with step disturbance.

In this exercise, we will see the effects of step disturbance in the servo system with proportional control only.

Having uncommented the necessary codes area which is "Dain += 100;" (In the handout it mentioned Dain+=200 however in the given codes the Dain +=100 and we were told to leave it as 100) the systems responses are as followed:C:\Users\owner\Documents\doc.uni\S4\ACS214,ACS271\A3\PID2\figures\f72.jpg

Zoom version system of response when Kp=6

Zoom version controller output when Kp=6

Controller output when Kp=6C:\Users\owner\Documents\doc.uni\S4\ACS214,ACS271\A3\PID2\figures\f71.jpg

Comments when Kp=6: The controller response is shifted down 0.5 volts compared to that for the system with the Kp=6 without the disturbance applied to it. Furthermore the system response becomes more oscillate than the system using the same Kp without disturbance. The steady state error becomes larger if we only increase the Kp . It also increases the overall settling time of the system when we compare that to the previous same response without disturbances.

## C:\Users\owner\Documents\doc.uni\S4\ACS214,ACS271\A3\PID2\figures\f84.jpgC:\Users\owner\Documents\doc.uni\S4\ACS214,ACS271\A3\PID2\figures\f82.jpg

Zoom version of system response when Kp=8

Zoom version of controller output when Kp=8

Comments when Kp=8: When we increase the Kp to 8, the controller output is oscillating for a certain period of time before it reaches the steady state. It is obvious to see that this system response oscillate a lot compare to that when Kp=6. So when we applied the disturbance, increasing the Kp will only leads to more oscillation, increase the settling time and steady state error(controller only) but increase the overall response time i.e. rise time.

C:\Users\owner\Documents\doc.uni\S4\ACS214,ACS271\A3\PID2\figures\f94.jpgC:\Users\owner\Documents\doc.uni\S4\ACS214,ACS271\A3\PID2\figures\f92.jpg

Zoom version of system response when Kp=4

Zoom version of controller output when Kp=4

Comments when Kp=4: When we reduce the Kp to 4, the controller output becomes less oscillatory compare to that when Kp= 6. The output has a very small overshoot and good rise time. However, the speed of the response is reduced slightly.

Exercise 4: PI control of the servo system with step disturbance

In order to see the system response when we applied given PID controller law as shown below along with the codes are:

//PID control law

s(t) €½€ s(t €­1) €«€ e(t)

u(t) €½€ K pe(t) €«€ Kd [e(t) €­e(t €­1)]€«€ Kis(t)

//Having got the PID control law now we will substitute the values in the code variables accordingly.

//When we find the variable declarations sections which is in the main, we found that each variables //contributes to the above PID control law equations.

//In the main codes we found one of the section is PID related variables as followed:

void main ()

## {

/* PID related variables */

float Kp, Ki, Kd; // Proportional, derivative and integral gains

float Error; // Positioning error e(t-1) (volts)

float LastError=0; // e(t-2)

float SumError=0; // integral error, initial is zero

float V; // Controller output (Volts)

int Dist=0; // step disturbance

## }

//TODO implements the PID control law and the codes are as followed:

SumError = SumError + Error; // error accumulated = Sumerror + error signal

V = Kp*Error + Kd*(Error - LastError) + Ki*SumError; // controller output= proportional control *error signal + derivative control*(error-last error) + integral control * Sum error.

Error= LastError; //this error variable will store the intermediate result from last error

The system response when we applied different values for Kp and Ki are shown in table 4 below along with the system responses in the figures below.

Kp

Ki

tr

tp

%Overshoot

ts

figure

10

0.1

n.a

n.a

n.a

n.a

4a

6

0.1

0.1s

0.13s

66.67

0.4s

4b

4.5

0.05

0.1s

0.15s

37.5

1.8s

4c

The responses are as followed:C:\Users\owner\Documents\doc.uni\S4\ACS214,ACS271\A3\PID2\figures\f102.jpgC:\Users\owner\Documents\doc.uni\S4\ACS214,ACS271\A3\PID2\figures\f104.jpg

Figure 4a.Zoom version of system response when Kp=4,Ki=0.1

Figure 4a.Zoom version of controller output when Kp=4,Ki=0.1

Comments when Kp=4,Ki=0.1: The controller output and the system responses are more oscillatory compared to that with the proportional control only. The value of tr, tp, overshoot and ts are not possible to determine because it is too oscillatory.

## C:\Users\ashley\AppData\Local\Temp\UDEFOVD}GCYDEU8R(SNUT9G.jpgC:\Users\ashley\AppData\Local\Temp\_EMYQFRFN42ICK[H0IXWHDT.jpg

Figure 4b.controller output when Kp=6,Ki=0.1

Figure 4c.controller output when Kp=4.5,Ki=0.05

## Comments of figure 4b when Kp=6 and Ki=0.1:

This time I have saved the axis in the degrees form rather than voltages. As we can see in the figure 4b above, the response of the controller output has only one overshoot compare to that when only using Kp= 6 in exercise 3 i.e. 2 overshoot. Furthermore, the integral element will give a better steady state error than only using Kp. The affects of Kp is to reduce the oscillation and gives more stability to a system as we compare figure 4a and 4b.

## Comments of figure 4c when Kp=4.5 and Ki=0.05:

When comparing the controller output response with only using Kp=3 in the previous exercise, we can see that when we only used the Kp=3 the response is much faster with one overshoot. However, when we added the integral element to the system as in figure 4c, the response becomes a bit slower but the integral element gives better steady state error of the system compare to that when only using Kp.

Exercise 5: PID control of the servo system with step disturbance

I have not got time to finish this exercise. However, I am expecting the system response follow the reference input in a robust way if a good parameters of the PID controller are selected.

Generally the affects of each element in PID controller:

P is the proportional element which relates to oscillation of a system response.

I is the integral element which affect the steady state of a system response.

D is the derivative element which affects the speed of the response and reduces the overshoot.