design of a pid controller using matlab and labview

51
8/17/2019 Design of a PID controller using Matlab and LabVIEW http://slidepdf.com/reader/full/design-of-a-pid-controller-using-matlab-and-labview 1/51 1 2016 Robotics and Manufacturing  Automation  MN5552 1446800 Brunel University 12/02/2016

Upload: dannyalejo

Post on 06-Jul-2018

269 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Design of a PID controller using Matlab and LabVIEW

8/17/2019 Design of a PID controller using Matlab and LabVIEW

http://slidepdf.com/reader/full/design-of-a-pid-controller-using-matlab-and-labview 1/51

1

2016 

Robotics and

Manufacturing

 Automation 

MN5552 1446800 

Brunel University

12/02/2016

Page 2: Design of a PID controller using Matlab and LabVIEW

8/17/2019 Design of a PID controller using Matlab and LabVIEW

http://slidepdf.com/reader/full/design-of-a-pid-controller-using-matlab-and-labview 2/51

2

CONTENT

1. Introduction .................................................................................................................................. 7

1.1. Initial Assumptions ................................................................................................................ 7

2. Objectives ..................................................................................................................................... 8

3. Formulation .................................................................................................................................. 8

3.1. Type of the manipulator's work envelope ................................................................................. 8

3.2. Manipulator configuration ......................................................................................................... 9

3.2.1. Error measuring device and feedback signal ..................................................................... 10

3.2.2. Amplifier ........................................................................................................................... 11

3.2.3. Motor ................................................................................................................................ 12

3.2.4. Gear Train of the revolute joint......................................................................................... 13

3.2.5. Gear Train of the prismatic joint ....................................................................................... 14

3.3. Transfer Function of the revolute joint (Servo System 0)......................................................... 14

3.3.1. Inductance Analysis ........................................................................................................... 18

3.4. Transfer Function of the prismatic joint (Servo System 1) ....................................................... 20

3.5. Matlab Program ....................................................................................................................... 21

3.5.1. Revolute joint (Servo System 0) ........................................................................................ 24

3.5.2. Prismatic joint (Servo System 1) ........................................................................................ 26

3.6. Design a control system for the drives of the joints ................................................................. 28

3.6.1. Revolute Joint (Servo System 0) ........................................................................................ 28

3.6.2. Prismatic Joint (Servo System 1) ....................................................................................... 33

3.7. Arbitrary signals ....................................................................................................................... 36

3.7.1. Reference signal 1 ............................................................................................................. 36

3.7.2. Reference Signal 2 ............................................................................................................. 39

3.7.3. Reference Signal 3 ............................................................................................................. 42

Conclusion .......................................................................................................................................... 44

Appendix ............................................................................................................................................. 45

Page 3: Design of a PID controller using Matlab and LabVIEW

8/17/2019 Design of a PID controller using Matlab and LabVIEW

http://slidepdf.com/reader/full/design-of-a-pid-controller-using-matlab-and-labview 3/51

3

INDEX OF FIGURES

Figure 1. Robotic Arm Scheme .............................................................................................................. 7

Figure 2. Hollow cylinder as the work envelope shape ......................................................................... 9

Figure 3. Manipulator with articulated arms ........................................................................................ 9

Figure 4. Schematic diagram for both drivers ..................................................................................... 10

Figure 5. Operational Amplifier noninverting ..................................................................................... 11

Figure 6. Gear train of the revolute joint ............................................................................................ 13

Figure 7. Gear train of the prismatic joint ........................................................................................... 14

Figure 8. Block diagram of the servo system 0 .................................................................................... 15

Figure 9. Armature Circuit of a servo motor ....................................................................................... 16

Figure 10. Transfer function for the servo system 0 ........................................................................... 17

Figure 11. Simplified Transfer Function for the servo system 0 .......................................................... 19

Figure 12. Transfer function for the servo system 1 ........................................................................... 20

Figure 13. Simplified Transfer Function for the servo system 1 .......................................................... 21

Figure 14. Step-Response for the revolute joint ................................................................................. 24

Figure 15. Poles and zeros of the revolute joint in closed-loop .......................................................... 25Figure 16. . Step-Response for the prismatic joint .............................................................................. 26

Figure 17. Poles and zeros of the revolute joint in closed-loop .......................................................... 27

Figure 18. Graphic proof of the second conventional method of Z-N for the revolute joint .............. 28

Figure 19. Step response of the System 0 by applying custom parameters ........................................ 32

Figure 20. Graphic proof of the second conventional method of Z-N for the prismatic joint ............. 33

Figure 21. Step response of the System 1 by applying custom parameters ........................................ 35

Figure 22. Simulink model................................................................................................................... 36

Figure 23. Reference Signal 1 .............................................................................................................. 37

Figure 24. Response of the revolute joint to the reference signal 1 ................................................... 37

Figure 25. Error of the servo system 0 in steady state by applying the reference signal 1 ................. 38

Figure 26. Response of the prismatic joint to the reference signal 1 .................................................. 38

Figure 27. Error of the servo system 1 in steady state by applying the reference signal 1 ................. 39

Figure 28. Reference Signal 2 .............................................................................................................. 39

Figure 29. Response of the revolute joint to the reference signal 2 ................................................... 40

Figure 30. Error of the servo system 0 in steady state by applying the reference signal 2 ................. 40

Page 4: Design of a PID controller using Matlab and LabVIEW

8/17/2019 Design of a PID controller using Matlab and LabVIEW

http://slidepdf.com/reader/full/design-of-a-pid-controller-using-matlab-and-labview 4/51

4

Figure 31. Response of the prismatic joint to the reference signal 2 .................................................. 41

Figure 32. Error of the servo system 1 in steady state by applying the reference signal 2 ................. 41

Figure 33. Reference Signal 3 .............................................................................................................. 42

Figure 34. Response of the revolute joint to the reference signal 3 ................................................... 42

Figure 35. Error of the servo system 0 in steady state by applying the reference signal 3 ................. 43

Figure 36. Response of the prismatic joint to the reference signal 3 .................................................. 43

Figure 37. Error of the servo system 1 in steady state by applying the reference signal 3 ................. 44

Figure 38. Step-Response for the revolute joint ................................................................................. 47

Figure 39. Original system vs. System with Z-N PID ............................................................................ 47

Page 5: Design of a PID controller using Matlab and LabVIEW

8/17/2019 Design of a PID controller using Matlab and LabVIEW

http://slidepdf.com/reader/full/design-of-a-pid-controller-using-matlab-and-labview 5/51

5

INDEX OF TABLES 

Table 1. Specification dc servo motor type M66CE-12 ....................................................................... 12

Table 2. Parameters of the servo systems .......................................................................................... 21

Table 3. Results of different tuning methods of controllers applied to the revolute joint .................. 30

Table 4. Results of different tuning methods of controllers applied to the prismatic joint ................ 34

Table 5. Original system vs. System with Z-N PID ............................................................................... 48

Page 6: Design of a PID controller using Matlab and LabVIEW

8/17/2019 Design of a PID controller using Matlab and LabVIEW

http://slidepdf.com/reader/full/design-of-a-pid-controller-using-matlab-and-labview 6/51

6

INDEX OF EQUATIONS

Equation 1. Error of position ............................................................................................................... 10

Equation 2. Relation between the error of voltage and the error of position .................................... 10

Equation 3. Gain of the operational amplifier noninverting ............................................................... 11

Equation 4. Relation between the position of the output shaft and the position of the motor shaft 13

Equation 5. Relation between the output shaft position and the vertical displacement .................... 14

Equation 6. Transfer function in open loop for the servo system 0 .................................................... 15

Equation 7. Relation between the position of the motor shaft and the voltage error. ....................... 17

Equation 8. Complex impedance of the servo motor ......................................................................... 18

Equation 9. Transfer function for the servo system 0 ......................................................................... 18

Equation 10. Variables J, B, and K ....................................................................................................... 19

Equation 11. Transfer function for the servo system 1 ....................................................................... 20

Equation 12. Variables J1, B1, and K1  ................................................................................................... 20

Equation 13. Transfer Function in closed loop of the servo system 0 ................................................. 24

Equation 14. Transfer Function in closed loop of the servo system 1 ................................................. 26

Equation 15. Transfer Function in open loop of the servo system 0 ................................................... 29

Equation 16. PID controller applied to the revolute joint ................................................................... 31Equation 17. Transfer Function in open loop of the servo system 1 ................................................... 33

Equation 18. PID controller applied to the prismatic joint .................................................................. 34

Page 7: Design of a PID controller using Matlab and LabVIEW

8/17/2019 Design of a PID controller using Matlab and LabVIEW

http://slidepdf.com/reader/full/design-of-a-pid-controller-using-matlab-and-labview 7/51

7

1. 

Introduction

In this assignment, a robotic arm will be analysed. This robotic manipulator has a revolute and a

prismatic joint, as shown in Figure 1. When the gripper is at the initial position; it is assumed that the

end effector is at the same height with link1. Additionally, it is assumed that the tool tip can reach

ground level. Therefore, the length of link2 is 450mm.

Firstly, at Section 3.1 the type of the manipulator's work envelope will be described. Secondly, at

Section 3.2 the configuration of the selected joint drives will be studied. Later, the transfer function

of the revolute joint and prismatic joint will be developed in Section 3.3 and 3.4 respectively. Next,

the step response of each joint driver will be analysed by using Matlab at Section 3.5. Afterwards, at

Section 3.6 will perform a control system for each of the joint drivers by using Matlab and LabVIEW.

Finally, at Section 3.7 will simulate the system response when applying the controller, by using the

three reference signals.

Figure 1. Robotic Arm Scheme

1.1. 

Initial Assumptions

  When the end effector is placed on the object it immediately grabs the object. Hence, this

assignment does not take into account any delay due to gripper operation.

  This paper does not consider in controlling the gripping action for the gripper, only the

Page 8: Design of a PID controller using Matlab and LabVIEW

8/17/2019 Design of a PID controller using Matlab and LabVIEW

http://slidepdf.com/reader/full/design-of-a-pid-controller-using-matlab-and-labview 8/51

8

placement of the gripper to the desired position.

  The weights and inertia of the links are negligible, so all the force or torque generated by the

drives is used for movement.

2. 

Objectives

  Understand the criticality and importance of automation and robotics in the modern

industrial environment

  Critically analyse automated manufacturing equipment and specify suitable approaches for

control  Evaluate and justify an automated system

  Understand the issues in modelling and controlling automated equipment

  Apply a suitable modelling tool (MATLAB) to model and control a system

3. 

Formulation

3.1. Type of the manipulator's work envelope

The system is composed of seven parts:

  Base = reference frame

  Link 1

  Vertex 1  Link 2

  Joint 0 = Revolute joint

  Joint 1 = Prismatic joint

  Gripper

The base is connected to the Link 1 through the Joint 0. This joint allows the Link 1 to rotate 360º

about the vertical axis of the base. Additionally, the Link 1 is composed of two parts: a horizontal

stick and a vertical stick, both connected by means the Vertex 1 of 90º. However, unlike Joint 0, theVertex 1 is static. In other words, neither angular nor linear movements are allowed. Consequently,

Page 9: Design of a PID controller using Matlab and LabVIEW

8/17/2019 Design of a PID controller using Matlab and LabVIEW

http://slidepdf.com/reader/full/design-of-a-pid-controller-using-matlab-and-labview 9/51

9

the system describes a circular movement about the z0 axis with 450mm of height and 300 mm of

radio. This movement creates a hollow cylinder as the work envelope shape. As a result, there is a

cylindrical dead zone around the robot structure which the end tool cannot reach, as shown in

Figure 2. 

Furthermore, the Link 1 is connected to the Link 2 through a prismatic joint, Joint 1 allows the

gripper to move up and down. The maximum vertical distance the end-tool can reach is the vertical

length of Link 1 (450 mm). This linear motion enables the gripper tool to reach the ground level. The

combined movement of the two joints allows performing a pick and placing operation.

An example of application is the manipulator with articulated arms MaxiPartner MX   of the

Italian Company Dalmec S.p.A, as shown in Figure 3, which is equipped with special gripping tools, is

suitable to handle heavy (max 900 kg) and also off-set loads, in any direction, allowing the operator

to work with the minimum effort in good ergonomic and safety conditions (Dalmec S.p.A., 2016).

Figure 2. Hollow cylinder as the work envelope shape  Figure 3. Manipulator with articulated arms

 

3.2. Manipulator configuration

The aim of the project is to control the position in accordance with a reference.   Figure 4

depicts the system for both drivers. Both joints are analysed using the same scheme. The onlydifference between the two systems appears in the gear train; since the prismatic joint employs a

Page 10: Design of a PID controller using Matlab and LabVIEW

8/17/2019 Design of a PID controller using Matlab and LabVIEW

http://slidepdf.com/reader/full/design-of-a-pid-controller-using-matlab-and-labview 10/51

10

rack and pinion driver to convert angular motion to linear displacement. In any case, the servo

system has five parts: error measuring device, amplifier, motor and the gear train and the load

(Ogata, 2010).

Figure 4. Schematic diagram for both drivers

3.2.1. Error measuring device and feedback signal

The error measuring device consists of two potentiometers; they convert the input and

output positions into electric signals. The potentiometer ‘r’ is the input reference position to the

system and the potentiometer ‘c’ is the output shaft position (from the feedback). The difference

between ‘r’ and ‘c’ is the error of position ‘e’.   The feedback signal comes from a rotary encoder

(shaft encoder). Furthermore, it is assumed that the gain of the feedback is 1.

=   (1)

Equation 1. Error of position

The error of voltage is proportional to the error of position.

 =  

 =    (2)

Equation 2. Relation between the error of voltage and the error of position

Page 11: Design of a PID controller using Matlab and LabVIEW

8/17/2019 Design of a PID controller using Matlab and LabVIEW

http://slidepdf.com/reader/full/design-of-a-pid-controller-using-matlab-and-labview 11/51

11

Where:

 : Error of voltage

 : Proportionality constant = 1

3.2.2. Amplifier

The chosen servo motor (M66CE-12 of Farnell) uses the MSE421 amplifier, which can be

depicted by using operational amplifiers as displayed in Figure 5 and Equation 3. The output voltage

of this amplifier

  is applied to the armature circuit of the servo motor. This paper will assume a

gain of 5.

Figure 5. Operational Amplifier noninverting

 = .   (3)

Equation 3. Gain of the operational amplifier noninverting

Where:

 : Voltage of armature

 : Gain of the amplifier = 5

Page 12: Design of a PID controller using Matlab and LabVIEW

8/17/2019 Design of a PID controller using Matlab and LabVIEW

http://slidepdf.com/reader/full/design-of-a-pid-controller-using-matlab-and-labview 12/51

12

3.2.3. Motor

The rotary actuator used is a servo-motor; it allows to control angular or linear position (servo

motors also permit control of velocity and acceleration. However, this paper just considers the

control of position). It consists of a motor coupled to a sensor for position feedback (shaft encoder).

Choosing a servo motor as the actuator of the robotic arm is based on the next statements.

  When  ≠ 0; the motor rotates to bring the output shaft to the appropriate position in

such a way as to reduce the error to zero.

  Servo motors have three characteristics: strength, speed, and low inertia. For this reason,

they are used in applications of robotic arms or CNC machines.

Although a stepper motor would have been the first option to control the position; normally

they do not have feedback; this fact limits its applications to work with controllers. However, in

recent years, some manufacturers as Fastech Company from Korea, have developed closed loop

stepping systems having better performance than the servo systems (Fastech Co., Ltd., 2014).

The servo motor selected is the M66CE-12 of Farnell that has a high performance and low

inertia. Its characteristics are displayed in Table 1. 

Table 1. Specification dc servo motor type M66CE-12 

Source. (Farnell element14, 2013)

Page 13: Design of a PID controller using Matlab and LabVIEW

8/17/2019 Design of a PID controller using Matlab and LabVIEW

http://slidepdf.com/reader/full/design-of-a-pid-controller-using-matlab-and-labview 13/51

13

Where:

J0: Moment of inertia referred to the motor shaft = 0.0214 Kg.m2 

b0: Viscous-friction coefficient referred to the motor shaft = 0.1 N.m.s

K2: Torque constant = 0.041 .  

K3: Back emf constant = 0.041    ⁄  

3.2.4. Gear Train of the revolute joint

It has been assumed that the gear ratio is such that the output shaft rotates 2 times for each

revolution of the motor shaft, as depicted in the Equation 4.  Figure 6 shows the revolute joint

developed with spur gears.

=  θ =  

  (4)

Equation 4. Relation between the position of the output shaft and the position of the motor shaft

Where:

c : Angular position of the output shaft

θ : Angular position of the motor shaft

: Ratio of the output shaft kgm2

: Ratio of the motor shaft

Figure 6. Gear train of the revolute joint

Page 14: Design of a PID controller using Matlab and LabVIEW

8/17/2019 Design of a PID controller using Matlab and LabVIEW

http://slidepdf.com/reader/full/design-of-a-pid-controller-using-matlab-and-labview 14/51

14

3.2.5. Gear Train of the prismatic joint

To convert angular motion to linear displacement, a rack and pinion driver has been

designed. It has been assumed that the ratio of the output shaft   is 18 mm, as displayed in

Figure 7. 

Figure 7. Gear train of the prismatic joint 

For instance, if the output shaft turns 19.44 radians, the gripper will reach a linear position of 350

mm as shown in the Equation 5. 

= ×  

= 19.44 × 18 

= 350  

Equation 5. Relation between the output shaft position and the vertical displacement

3.3. Transfer Function of the revolute joint (Servo System 0)

The aim of this section is to relate the input reference position to the output shaft position.

Therefore, the cascaded procedure will be applied to obtain the TF. Figure 8 and Equation 6

represent the TF for the servo system 0.

Page 15: Design of a PID controller using Matlab and LabVIEW

8/17/2019 Design of a PID controller using Matlab and LabVIEW

http://slidepdf.com/reader/full/design-of-a-pid-controller-using-matlab-and-labview 15/51

15

Figure 8. Block diagram of the servo system 0

 =  ×  

 ×   

Equation 6. Transfer function in open loop for the servo system 0

The Equation 1 joins the error of position with the difference between the input reference

position and the output shaft position. The Equation 2 relates the error of voltage and the error of

position. Moreover, the Equation 4 links the position of the output shaft and the position of the

motor shaft. Hence, the only relation missing is the position of the motor shaft with the error of

voltage.

Figure 9 exhibits the armature circuit of a servo motor. When the armature is rotating, a

proportional voltage to the product of the flux and angular velocity is induced in the armature. For a

constant flux, the induced voltage  is directly proportional to the angular velocity, as follows:

 =    (5)

Where:

 : back electromotive force (emf)

 : back emf constant

Page 16: Design of a PID controller using Matlab and LabVIEW

8/17/2019 Design of a PID controller using Matlab and LabVIEW

http://slidepdf.com/reader/full/design-of-a-pid-controller-using-matlab-and-labview 16/51

16

Figure 9. Armature Circuit of a servo motor

Applying the Ohm law to the armature circuit:

     =   (6)

(3) and (5) in (6)

     

 =  

Applying the Laplace Transformation:

ℒ        =  

(  )   (  ) =  

Applying initial conditions:

 = 0 

 = 0 

     =   (7)

Additionally, the equation for the torque equilibrium is:

     

 =   (8)

For constant field current, the torque developed by the motor is:

Page 17: Design of a PID controller using Matlab and LabVIEW

8/17/2019 Design of a PID controller using Matlab and LabVIEW

http://slidepdf.com/reader/full/design-of-a-pid-controller-using-matlab-and-labview 17/51

17

=   (9)

(9) in (8)

 

   =  

Applying Laplace Transformation:

ℒ  

 =  

 (    ) (  ) =  

Applying initial conditions:

    =  

 =  +   (10)

(10) in (7)

 =  

 

 

Equation 7. Relation between the position of the motor shaft and the voltage error.

Figure 10 depicts the TF for the servo system 0

Figure 10. Transfer function for the servo system 0

Page 18: Design of a PID controller using Matlab and LabVIEW

8/17/2019 Design of a PID controller using Matlab and LabVIEW

http://slidepdf.com/reader/full/design-of-a-pid-controller-using-matlab-and-labview 18/51

18

3.3.1. Inductance Analysis

Considering Figure 9, the complex impedance can be expressed in polar form as follows:

= ||  

Equation 8. Complex impedance of the servo motor 

Where:

|| =     

= tan−  

Z: complex impedanceω: angular velocity = 2πf

La: Inductance of armature = 0.00001 H

Replacing values:

|| = √ 1.9  2 × 50 × 0.00001 || = 1.900003 Ω 

= 2 × 50 × 0.00001

1.9 

= 0.0003° 

By analysing the values, the complex impedance is equal to the resistance of armature.

Consequently, the inductance of armature is very small and can be neglected. Thus, the TF is

expressed as follows

 =      

Equation 9. Transfer function for the servo system 0

 =

   

   

Page 19: Design of a PID controller using Matlab and LabVIEW

8/17/2019 Design of a PID controller using Matlab and LabVIEW

http://slidepdf.com/reader/full/design-of-a-pid-controller-using-matlab-and-labview 19/51

19

 =

        

 =        

 

If the new variables J, B, and K are defined as in the Equation 10; the TF is expressed as in Figure 11. 

  = 

 

=    

=   

Equation 10. Variables J, B, and K

Where:

J: Moment of inertia referred to the to the output shaft

B: Viscous friction coefficient referred to the output shaft

Figure 11. Simplified Transfer Function for the servo system 0

Page 20: Design of a PID controller using Matlab and LabVIEW

8/17/2019 Design of a PID controller using Matlab and LabVIEW

http://slidepdf.com/reader/full/design-of-a-pid-controller-using-matlab-and-labview 20/51

20

3.4. Transfer Function of the prismatic joint (Servo System 1)

The TF for the prismatic joint is very similar to the revolute joint. However, the output of the

prismatic joint is not an angular position, but it is a linear displacement. The Equation 5 links theoutput shaft position with the vertical displacement of the gripper. Figure 12 and Equation 11 depict

the TF for the servo system 1

Figure 12. Transfer function for the servo system 1

 =    ×  ×  × ×    

Equation 11. Transfer function for the servo system 1

If the new variables J1, B1, and K1 are defined as the Equation 12; the TF is expressed as in Figure 13. 

  =    

 =    

 =   ×  ×  

Equation 12. Variables J1, B1, and K1 

Page 21: Design of a PID controller using Matlab and LabVIEW

8/17/2019 Design of a PID controller using Matlab and LabVIEW

http://slidepdf.com/reader/full/design-of-a-pid-controller-using-matlab-and-labview 21/51

21

Figure 13. Simplified Transfer Function for the servo system 1

3.5. Matlab Program

This section will be performed stability analysis and transient response. Table 2 displays the

parameters of both servo systems.

Table 2. Parameters of the servo systems

Parameters

Servo System 0 Servo System 1

Revolute Joint Prismatic Joint

   0.0214 Kg.m2  0.0214 Kg.m2 

  0.1 N.m.s 0.1 N.m.s

  1.9 Ω  1.9 Ω 

  1 1

  5 5

  0.041 .     0.041 .

   

  0.041    ⁄   0.041  

 ⁄  

  2 2

   _ 17.9 mm

%1446800 %Robotic and Manufacturing Automation %Servo system M66CE-12%Data 

v=input('press "p" for prismatic joint or "r" for revolute joint: ','s'); if v=='r' %revolute joint 

Jo=0.0214; %inertia of the motor referred to the motor shaft bo=0.1; %viscous-friction referred to the motor shaft Ra=1.9; %Resistance of armature

Page 22: Design of a PID controller using Matlab and LabVIEW

8/17/2019 Design of a PID controller using Matlab and LabVIEW

http://slidepdf.com/reader/full/design-of-a-pid-controller-using-matlab-and-labview 22/51

22

ko=1; %constant of error k1=5; %gain of the amplifier k2=0.041; %motor torque constant k3=0.041; %back emf constant of the motor n=2; %gear ratio 

K=(ko*k1*k2)/(n*Ra); J=Jo/n^2; %moment of inertia referred to the output shaft B=(bo+(k2*k3)/Ra)/n^2; %viscous-friction referred to the output shaft 

%TF 

num=[K]; den=[J B 0]; Gp=tf(num,den); %open loop TF H=1; %feedback Sys=feedback(Gp,H) %closed-loop TF figure (1) step(Sys) %unit step response

grid title ('Step-Response for the revolute joint') xlabel('t Sec') ylabel('Output') 

%Transient response 

Z=B/(2*sqrt(J*K)); %damping ratio Wn=sqrt(K/J); %undamped natural frequencyWd=Wn*sqrt(1-(Z^2)); %damped natural frequency 

tr=(pi-atan(Wd/(Z*Wn)))/Wd; %rise time 

tp=pi/Wd; %peak timeMp=exp(-(Z/sqrt(1-Z^2))*pi); %maximum overshoot ts=4/(Z*Wn); %settling time 2% criterion

%Stability analysis 

if Z>1 dynamic_behavior='Overdamped case'; 

end if Z==1 

dynamic_behavior='Critically damped case'; end if Z<1

dynamic_behavior='Underdamped case'; end 

figure(2) pzmap(Sys) %poles and zeros map in closed-looptitle('poles and zeros of revolute joint in closed-loop') grid gtext(dynamic_behavior) 

end 

if v=='p' %prismatic joint 

Jo=0.0214; %inertia of the motor referred to the motor shaft bo=0.1; %viscous-friction referred to the motor shaft Ra=1.9; %Resistance of armature

Page 23: Design of a PID controller using Matlab and LabVIEW

8/17/2019 Design of a PID controller using Matlab and LabVIEW

http://slidepdf.com/reader/full/design-of-a-pid-controller-using-matlab-and-labview 23/51

23

ko=1; %constant of error k1=5; %gain of the amplifier k2=0.041; %motor torque constant k3=0.041; %back emf constant of the motor n=2; %gear ratio rc=112.5/(2*pi); %ratio of the output shaft 

K=(ko*k1*k2)/(n*rc*Ra); J=Jo/(n*rc)^2; %inertia referred to the output shaft B=(bo+(k2*k3)/Ra)/(n*rc)^2; %viscous referred to the output shaft

%TF 

num=[K]; den=[J B 0]; Gp=tf(num,den); %open loop TF H=1; %feedback Sys=feedback(Gp,H) %closed-loop TF figure (1) step(Sys) %unit step responsegrid title ('Step-Response for the prismatic joint') xlabel('t Sec') ylabel('Output') 

%Transient response 

Z=B/(2*sqrt(J*K)); %damping ratio Wn=sqrt(K/J); %undamped natural frequencyWd=Wn*sqrt(1-(Z^2)); %damped natural frequency 

tr=(pi-atan(Wd/(Z*Wn)))/Wd; %rise time tp=pi/Wd; %peak timeMp=exp(-(Z/sqrt(1-Z^2))*pi); %maximum overshoot ts=4/(Z*Wn); %settling time 2% criterion

%Stability analysis 

if Z>1 dynamic_behavior='Overdamped case'; 

end if Z==1 

dynamic_behavior='Critically damped case'; end 

if Z<1dynamic_behavior='Underdamped case'; 

end 

figure(2) pzmap(Sys) %poles and zeros map in closed-looptitle('poles and zeros of the prismatic joint in closed-loop') grid gtext(dynamic_behavior) 

end 

Page 24: Design of a PID controller using Matlab and LabVIEW

8/17/2019 Design of a PID controller using Matlab and LabVIEW

http://slidepdf.com/reader/full/design-of-a-pid-controller-using-matlab-and-labview 24/51

24

3.5.1. Revolute joint (Servo System 0)

The Equation 13 represents the TF in closed loop with feedback equal to 1.

=   0.053950.00535  0.02522 0.05395  

Equation 13. Transfer Function in closed loop of the servo system 0

3.5.1.1. Transient Response

The system is underdamped, as the damping ratio ζ = 0.7423. Consequently, the transient

response is oscillatory. Additionally, this type of systems gets close to the final value more rapidly

than a critically damped or overdamped system. Figure 14 exhibits the response curve when a unit

step is applied to the TF in close loop.

Figure 14. Step-Response for the revolute joint

Based on Figure 14, the system requires 0.712 seconds to rise from 10% to 90% of its final

value. Additionally, it takes 1.83 seconds to reach and stay within about 2% of its final value. Finally,

Page 25: Design of a PID controller using Matlab and LabVIEW

8/17/2019 Design of a PID controller using Matlab and LabVIEW

http://slidepdf.com/reader/full/design-of-a-pid-controller-using-matlab-and-labview 25/51

25

the maximum overshoot ()  occurs within 1.48 seconds, with a value of 3.08%. It can be

concluded that not only the system is too slow in reaching the steady state (3 seconds

approximately), but also   will generate problems for a robotic arm application. Therefore, a

controller needs to be implemented to enhance the transient response.

3.5.1.2. Stability Analysis

According to the Figure 15,  the closed-loop poles are complex conjugates and lie in the left-half s

plane.

 = 2.3571 2.1278 

 = 2.3571 2.1278 

Figure 15. Poles and zeros of the revolute joint in closed-loop

Applying the criterion of the location of the closed-loop poles in the s plane; since all closed-

loop poles lie to the left of the axis jω, the transient response eventually reaches equilibrium (3

seconds). Consequently, the servo motor 0 represents a stable system.

Page 26: Design of a PID controller using Matlab and LabVIEW

8/17/2019 Design of a PID controller using Matlab and LabVIEW

http://slidepdf.com/reader/full/design-of-a-pid-controller-using-matlab-and-labview 26/51

26

A further analysis can be carried out by applying The Linear System Analyzer Tool  in Matlab.

This tool not only permits to study the Root-Locus Method but also Nyquist Stability Criterion, by

typing >> ltiview in the command window.

3.5.2. Prismatic joint (Servo System 1)

The Equation 14 represents the TF in closed loop with feedback equal to 1.

=  0.003013

1.669 × 10−  7.867 ×10− 0.003013 

Equation 14. Transfer Function in closed loop of the servo system 1 

3.5.2.1. Transient Response

The system is underdamped, as the damping ratio ζ = 0.1754. Consequently, the transient

response is oscillatory. Figure 16 exhibits the response curve when a unit step is applied to the TF in

close loop.

Figure 16. . Step-Response for the prismatic joint

Page 27: Design of a PID controller using Matlab and LabVIEW

8/17/2019 Design of a PID controller using Matlab and LabVIEW

http://slidepdf.com/reader/full/design-of-a-pid-controller-using-matlab-and-labview 27/51

27

Based on Figure 16, the system requires 0.089 seconds to rise from 10% to 90% of its final

value. Additionally, it takes 1.5 seconds to reach and stay within about 2% of its final value. Finally,

 occurs within 0.234 seconds, with amplitude of 57.1%. In the same manner of the revolute joint,

not only the system is too slow in reaching the steady state (2.5 seconds approximately), but also

 

is unacceptable.

3.5.2.2. Stability Analysis

According to the Figure 17,  the closed-loop poles are complex conjugates and lie in the left-half s

plane.

 = 2.3571 13.2284 

 = 2.3571 13.2284 

Figure 17. Poles and zeros of the revolute joint in closed-loop

Applying the criterion of the location of the closed-loop poles in the s plane; since all closed-

loop poles lie to the left of the axis jω, the transient response eventually reaches equilibrium (2.5

seconds). Consequently, the servo motor 1 represents a stable system.

Page 28: Design of a PID controller using Matlab and LabVIEW

8/17/2019 Design of a PID controller using Matlab and LabVIEW

http://slidepdf.com/reader/full/design-of-a-pid-controller-using-matlab-and-labview 28/51

28

3.6. Design a control system for the drives of the joints

In this section the classic Ziegler-Nichols (Z-N) method for tuning PID will be analysed. This

procedure has two ways to be applied; the first way is used if the plant involves neither integrator

nor dominant complex-conjugate poles. Besides, the second way can be employed if the output

exhibits sustained oscillations for whatever value of proportional gain (Kp) may take (Åström &

Hägglund, 2004).

3.6.1. Revolute Joint (Servo System 0)

The plant has an integrator, as shown in the Equation 15. Additionally, the plant contents

dominant complex-conjugate poles. As a result, the first conventional method cannot be used.

Figure 18 illustrates the output signals by applying Kp = [2, 4, 6, 8, 10, 12]. Regardless of the values of

Kp; the amplitude decreases over time. In other words, the output does not exhibits sustained

oscillations, as there are not closed-loop poles on the jω  axis. Consequently, the revolute joint

(Servo System 0) satisfies neither the requirements for the first conventional method nor the

conditions for the second conventional method

Figure 18. Graphic proof of the second conventional method of Z-N for the revolute joint 

Page 29: Design of a PID controller using Matlab and LabVIEW

8/17/2019 Design of a PID controller using Matlab and LabVIEW

http://slidepdf.com/reader/full/design-of-a-pid-controller-using-matlab-and-labview 29/51

29

Note: A Matlab code has been developed in the Appendix A to show the results if the first classic

method is applied to the servo system 0. Although was proofed that the classic Z-N

 procedures should not be used. 

3.6.1.1. The Control and Estimation tool Manager in Matlab

The classic Z-N method is not the only way to tune controllers; Matlab offers the Control and

Estimation tool Manager, which contains four well-known methods to tune controllers (MathWorks,

2015)

  Robust

  Approximate MIGO

  Chien, Hrones & Reswick

  Skogestad IMC (Skogestad, 2002)

According to the transient response, the system is too slow and the level of Mp  (3.08%) is

unacceptable in applications of robotics and fine movements. For these reasons, the Control and

Estimation tool Manager  will be run to enhance those parameters; by typing >> sisotool(G0) in the

command window, where:

 =   0.053950.00535 0.02522 

Equation 15. Transfer Function in open loop of the servo system 0

Within the  Automated Tuning  option is possible to select any design method of controllers.

Moreover, Table 3 shows the results of the four tuning methods, applied to the revolute joint.

Page 30: Design of a PID controller using Matlab and LabVIEW

8/17/2019 Design of a PID controller using Matlab and LabVIEW

http://slidepdf.com/reader/full/design-of-a-pid-controller-using-matlab-and-labview 30/51

30

Table 3. Results of different tuning methods of controllers applied to the revolute joint

By analysing the Table 3, there are two tuning methods providing  almost zero; the AMIGO

and Chien-Hrones-Reswick proportional controllers. However, they take almost 3 second to reach

the steady stable. Thus, the best method is a PI robust control, resulting:

   = 8.08%

  Steady state time (SST) = 2.5 s

However, by applying a PI robust control,   is still high and the new system is only 0.5 seconds

faster than previous one. Consequently, custom parameters will be configured to enhance the

system response, using LabVIEW.

3.6.1.2. Bonus (LabVIEW)

Based on the responses obtained by applying the robust PI controller, the system can be further

improved by modifying the controller variables. There are three enhancement methods

  Root-Locus approach

Rise time Peak time Overshoot Settling time Steady State

seconds seconds % seconds seconds Kp Ki Kd

Original

system  0.71 1.48 3.08 1.83 3

P 0.49 1.04 8.77 1.55 2.5

PI 0.55 1.18 8.08 1.91 2.5 1.271 0.05378

PD 0.16 0.34 9.21 0.53 0.7

PID 0.16 0.34 9.08 0.52 0.7

P 1.14 2.99 0.09 1.87 3

PI 0.74 1.96 18.1 6.81 10

PID 1.85 4.75 38.7 19.4 30

P 1.14 2.99 0.09 1.87 3

PI 0.4 1.08 43.5 2.96 4

PID 0.32 0.82 39.2 3.1 4.5P 34.1 > 90 0 60.9 90

PI 0.18 0.47 44.6 2.4 3.5

PID 0.19 0.44 13.3 1.72 6

Custom

Parameters  PID 0.1 0.32 0.56 0.17 0.32 10.271 0.05378 2

Skogestad

IMC

Tuning

method

Type of

controller

Gain

Robust

Approximate

MIGO

Chien

Hrones

Reswick

Page 31: Design of a PID controller using Matlab and LabVIEW

8/17/2019 Design of a PID controller using Matlab and LabVIEW

http://slidepdf.com/reader/full/design-of-a-pid-controller-using-matlab-and-labview 31/51

31

  Frequency response approach

  Controller gains approach

At this paper, the controller gains have been modified manually by using LabVIEW, as presented

in Figure 19. Additionally, the last row of  Table 3 presents the result by applying custom parameters

to the servo system 0. In this case, the system is overdamped, in other words, it will not oscillate.

Thus, the peak time () is equal to the SST.

In conclusion, by applying the parameters computed in LabVIEW;  was reduced near 14 times

and SST was narrowed about 8 times. Finally, the Equation 16 represents the applied controller to

the revolute joint.

    = 0.56%  SST = 0.32 s

 =    

 = 2  10.271 0.05378  

Equation 16. PID controller applied to the revolute joint

Page 32: Design of a PID controller using Matlab and LabVIEW

8/17/2019 Design of a PID controller using Matlab and LabVIEW

http://slidepdf.com/reader/full/design-of-a-pid-controller-using-matlab-and-labview 32/51

32

Figure 19. Step response of the System 0 by applying custom parameters 

Page 33: Design of a PID controller using Matlab and LabVIEW

8/17/2019 Design of a PID controller using Matlab and LabVIEW

http://slidepdf.com/reader/full/design-of-a-pid-controller-using-matlab-and-labview 33/51

33

3.6.2. Prismatic Joint (Servo System 1)

Like the previous case, the servo system 1 does not meet the classic Z-N method

requirements, since the plant has an integrator, as shown in the Equation 17. Moreover, the output

does not exhibit sustained oscillations for any value that Kp may take as shown in Figure 20. 

Therefore, the conventional Z-N procedure cannot be applied.

Figure 20. Graphic proof of the second conventional method of Z-N for the prismatic joint 

As not only the system is too slow in reaching the steady state, but also  is unacceptable

(57.1%); the effects of some controllers has been studied by applying The Control and Estimation

tool Manager , whose characteristics are presented in the Table 4. 

 =   0.0030131.669 ×10− 7.867 × 10− 

Equation 17. Transfer Function in open loop of the servo system 1

Page 34: Design of a PID controller using Matlab and LabVIEW

8/17/2019 Design of a PID controller using Matlab and LabVIEW

http://slidepdf.com/reader/full/design-of-a-pid-controller-using-matlab-and-labview 34/51

34

Table 4. Results of different tuning methods of controllers applied to the prismatic joint 

It can be seen that the most favourable outcome is achieved by applying a proportional-

integrative robust control. However,

 and SST are still out of control

   = 8.08%

  SST = 2.5 s

Thus, the response has been improved by using LabVIEW, as displayed in  Figure 21. In addition, the

last row of  Table 4 contains the result by applying custom parameters to the servo system 1.

   = 0.08%

  SST = 0.02 s

In brief,  has been lessened near 101 times and SST has been diminished close 125 times. Finally,

the Equation 18 represents the applied controller to the prismatic joint.

 = 2  10.071 0.003004  

Equation 18. PID controller applied to the prismatic joint 

Rise time Peak time Overshoot Settling time Steady State

seconds seconds % seconds seconds   Kp   Ki Kd

Original

system  0.09   0.23 57.1 1.5 2.5

P 0.49 1.04 8.77 1.55 2.5

PI 0.55 1.18 8.08 1.91 2.5 0.07096 0.003004

PD 0.16 0.34 9.21 0.53 0.7

PID 0.16 0.34 9.08 0.52 0.7

P 1.14 2.99 0.09 1.87 3

PI 0.74 1.96 18.1 6.81 10

PID 1.85 4.75 38.7 19.4 30

P 1.14 3 0.09 1.87 3

PI 0.4 1.08 43.5 2.96 4

PID 0.32 0.82 39.2 3.1 4.5P 34.1 > 90 0 60.9 90

PI 0.18 0.47 44.6 2.4 3.5

PID 0.19 0.44 13.3 1.72 6

Custom

Parameters  PID 0.01 0.02 0.08 0.01 0.02 10.07096 0.003004 2

Skogestad

IMC

Tuning

method

Type of

controller

Gain

Robust

Approximate

MIGO

Chien

Hrones

Reswick

Page 35: Design of a PID controller using Matlab and LabVIEW

8/17/2019 Design of a PID controller using Matlab and LabVIEW

http://slidepdf.com/reader/full/design-of-a-pid-controller-using-matlab-and-labview 35/51

35

Figure 21. Step response of the System 1 by applying custom parameters

Page 36: Design of a PID controller using Matlab and LabVIEW

8/17/2019 Design of a PID controller using Matlab and LabVIEW

http://slidepdf.com/reader/full/design-of-a-pid-controller-using-matlab-and-labview 36/51

36

3.7. Arbitrary signals

In this section, the system response will be simulated in Simulink  by applying three reference signals.

The signals were built by using the Signal Builder Block , as presented in Figure 22. 

Figure 22. Simulink model

3.7.1. Reference signal 1

The first reference signal (RS1) consists of eight steps detailed in  Figure 23.  The revolute

 joint moves 0.785 rad, -0.873 rad and comes back to the initial position. Besides, the prismatic joint

moves 350 mm.

Page 37: Design of a PID controller using Matlab and LabVIEW

8/17/2019 Design of a PID controller using Matlab and LabVIEW

http://slidepdf.com/reader/full/design-of-a-pid-controller-using-matlab-and-labview 37/51

37

Figure 23. Reference Signal 1

3.7.1.1. Revolute Joint (Servo System 0)

The simulation is presented in Figure 24. The yellow and purple lines represent the reference

signal and system response respectively. As can be observed, the output eventually comes back to

its equilibrium state when the system is subjected to a disturbance. Consequently, the system error

in steady state is zero, as shown in Figure 25. 

Figure 24. Response of the revolute joint to the reference signal 1

Page 38: Design of a PID controller using Matlab and LabVIEW

8/17/2019 Design of a PID controller using Matlab and LabVIEW

http://slidepdf.com/reader/full/design-of-a-pid-controller-using-matlab-and-labview 38/51

38

Figure 25. Error of the servo system 0 in steady state by applying the reference signal 1

3.7.1.2. Prismatic Joint (Servo System 1)

The simulation is presented in Figure 26. Like the previous case, the system response is flat,

snapshot and without overshoot. Additionally, the  Figure 27 shows that the steady-state error is

zero

Figure 26. Response of the prismatic joint to the reference signal 1

Page 39: Design of a PID controller using Matlab and LabVIEW

8/17/2019 Design of a PID controller using Matlab and LabVIEW

http://slidepdf.com/reader/full/design-of-a-pid-controller-using-matlab-and-labview 39/51

39

Figure 27. Error of the servo system 1 in steady state by applying the reference signal 1 

3.7.2. Reference Signal 2

The RS2 consists of 14 steps displayed in Figure 28. The revolute joint moves 0.524 rad, -

0.619 rad, 1.047 rad, -0.952 rad and returns to the original position. Moreover, the prismatic joint

moves 350 mm.

Figure 28. Reference Signal 2

Page 40: Design of a PID controller using Matlab and LabVIEW

8/17/2019 Design of a PID controller using Matlab and LabVIEW

http://slidepdf.com/reader/full/design-of-a-pid-controller-using-matlab-and-labview 40/51

Page 41: Design of a PID controller using Matlab and LabVIEW

8/17/2019 Design of a PID controller using Matlab and LabVIEW

http://slidepdf.com/reader/full/design-of-a-pid-controller-using-matlab-and-labview 41/51

41

3.7.2.2. Prismatic Joint (Servo System 1)

The simulation is presented in the. Like the previous cases, the system response is flat, snapshot and

without overshoot. Additionally, the Figure 32 shows that the steady-state error is zero.

Figure 31. Response of the prismatic joint to the reference signal 2

Figure 32. Error of the servo system 1 in steady state by applying the reference signal 2

Page 42: Design of a PID controller using Matlab and LabVIEW

8/17/2019 Design of a PID controller using Matlab and LabVIEW

http://slidepdf.com/reader/full/design-of-a-pid-controller-using-matlab-and-labview 42/51

42

3.7.3. Reference Signal 3

The RS3 consists of 20 steps displayed in Figure 33. The revolute joint moves 0.524 rad, -

0.357 rad, 0.698 rad, -0.69 rad, 0.873 rad, -0.524 rad and returns to the original position. Moreover,

the prismatic joint moves 250mm, 350 mm and comes back to the initial position.

Figure 33. Reference Signal 3

3.7.3.1. Revolute Joint (Servo System 0)

Figure 34. Response of the revolute joint to the reference signal 3

Page 43: Design of a PID controller using Matlab and LabVIEW

8/17/2019 Design of a PID controller using Matlab and LabVIEW

http://slidepdf.com/reader/full/design-of-a-pid-controller-using-matlab-and-labview 43/51

43

Figure 35. Error of the servo system 0 in steady state by applying the reference signal 3 

3.7.3.2. Prismatic Joint (Servo System 1)

Figure 36. Response of the prismatic joint to the reference signal 3

Page 44: Design of a PID controller using Matlab and LabVIEW

8/17/2019 Design of a PID controller using Matlab and LabVIEW

http://slidepdf.com/reader/full/design-of-a-pid-controller-using-matlab-and-labview 44/51

44

Figure 37. Error of the servo system 1 in steady state by applying the reference signal 3 

Conclusion

These types of robots are not widely used in industry since the lack of flexibility and grades

of freedom limit their applications. However, some few applications are used for handling heavy.

The rotary actuator used is a servo motor as it presents various advantages over step and DC

motors. The transfer function of the servo motor considers all basic things like Error measuring

device, amplifiers, motor, gear train and the feedback signal. The only difference between the rack

and pinion drivers used to convert angular motion to linear displacement. Additionally, the transfer

function considers that the inductance of armature can be neglected since its value is very small.

By studying the results of Transient Response and Stability Analysis, can be concluded that

the Z-N method cannot be applied since does meet neither the conditions for the first method northe conditions for the second method. For this reason, other procedures like Robust, Approximate

MIGO, Chien-Hrones-Reswick and Skogestad have been applied by using The Control and Estimation

tool Manager in Matlab. However, the Z-N method was built in the Appendix a and B to prove that

the results are even worse than the original system.

The system was further improved by developing a Virtual Instrument in LabVIEW by means

the controller gains approach. As a result, the custom PID eliminated the overshoot and reduced the

settling time about zero.

Page 45: Design of a PID controller using Matlab and LabVIEW

8/17/2019 Design of a PID controller using Matlab and LabVIEW

http://slidepdf.com/reader/full/design-of-a-pid-controller-using-matlab-and-labview 45/51

45

The advantages of adding a derivative control action are:

  Anticipate the actuating error,

  Initiate an early corrective action,

  Increase the stability of the system.

The advantages of adding an integral control action are:

  Eliminate the steady-state error

  Reduce the overshoot

  Reduce the settling time

In conclusion, the proportional control action plus derivative and integral control actions eliminate

the steady-state error, reduce the overshoot and reduce the settling time.

The stability of the system was proved by building arbitrary signals in Simulink. The plant is

in equilibrium since in the absence of any disturbance or input; the output stays in the same state.

Consequently, the steady error is zero.

Page 46: Design of a PID controller using Matlab and LabVIEW

8/17/2019 Design of a PID controller using Matlab and LabVIEW

http://slidepdf.com/reader/full/design-of-a-pid-controller-using-matlab-and-labview 46/51

46

Appendix A (Revolute joint)

%1446800 %Robotic and Manufacturing Automation %Servo system M66CE-12

%Data Servo System 0 

close all clear all clc 

Jo=0.0214; %inertia of the motor referred to the motor shaft bo=0.1; %viscous-friction referred to the motor shaft Ra=1.9; %Resistance of armatureko=1; %constant of error 

k1=5; %gain of the amplifier k2=0.041; %motor torque constant k3=0.041; %back emf constant of the motor n=2; %gear ratio 

K1=(ko*k1*k2)/(n*Ra); J1=Jo/n^2; %moment of inertia referred to the output shaft B1=(bo+(k2*k3)/Ra)/n^2; %viscous-friction referred to the output shaft 

num1=[K1]; den1=[J1 B1 0]; G1=tf(num1,den1); %transfer function H=1; %feedback 

G2=feedback(G1,H); %closed-loop transfer function dt=0.01; %time vector t=0:dt:3; y1=step(G2,t)'; %don't use [y,t]=step(G2,t) because 't'

was already defineddy1=diff(y1)/dt; %difference and approximate derivative d2y1=diff(dy1)/dt; %second derivative [m1,p1]=max(dy1); %returns the indices of the maximum values

in vector p yi1=y1(p1); %inflection point positionti1=t(p1); %inflection point time plot(ti1,yi1,'*r') hold on 

L1=ti1-yi1/m1; %delay timeT1=(y1(end)-yi1)/m1+ti1-L1; %time constant figure(1) plot(t,y1,'b',[0 L1 L1+T1 t(end)],[0 0 y1(end) y1(end)],'k') title('Step response of the original system 0') grid ylabel('Amplitude') xlabel('Time (sec)') legend('Inflection point','Step response','Tangent line at inflectionpoint') 

% Ziegler–Nichols Rules for Tuning PID Controllers, First Method Kp1=1.2*T1/L1; %proportional gain 

Ti1=2*L1; %integral timeTd1=0.5*L1; %derivative time 

Page 47: Design of a PID controller using Matlab and LabVIEW

8/17/2019 Design of a PID controller using Matlab and LabVIEW

http://slidepdf.com/reader/full/design-of-a-pid-controller-using-matlab-and-labview 47/51

47

Ki1=Kp1/Ti1; %integration gainKd1=Kp1*Td1; %derivation gainC1=tf(pid(Kp1,Ki1,Kd1)); G3=feedback(C1*G1,H); 

figure (2) 

step(G2,G3) title('Step response of the controlled system 0') legend('Original System 0','System 0 with PID') grid 

Figure 38. Step-Response for the revolute joint

Figure 39. Original system vs. System with Z-N PID

Page 48: Design of a PID controller using Matlab and LabVIEW

8/17/2019 Design of a PID controller using Matlab and LabVIEW

http://slidepdf.com/reader/full/design-of-a-pid-controller-using-matlab-and-labview 48/51

48

Table 5. Original system vs. System with Z-N PID

Original System System with Z-N PID

Settling time 1.8278 2.7154

Overshoot % 3.0792 56.9358

Steady state time 3 4

Figure 38 shows the inflection point and tangent line. Moreover, Figure 39 shows the results

of the original system and the system with Z-N PID. By applying a Z-N PID controller, the settling time

increased 1.5 times approximately, the overshoot boosted 18.5 times and SST augmented 1.3 times,

as illustrated in Table 5. Therefore, Z-N controller should not be used, if the system does not meet

the method conditions.

Appendix B (Prismatic Joint)

%1446800 %Robotic and Manufacturing Automation %Servo system M66CE-12

%Data Servo System 1 

close all clear all clc 

Jo=0.0214; %inertia of the combination of the motor, load, and geartrain referred to the motor shaft bo=0.1; %viscous-friction coefficient of the combination of the

motor, load, and gear train referred to the motor shaft Ra=1.9; %Resistance of armatureko=1; %constant of error k1=5; %gain of the amplifier k2=0.041; %motor torque constant k3=0.041; %back emf constant of the motor n=2; %gear ratio rc=112.5/(2*pi); %ratio of the output shaft 

K2=(ko*k1*k2)/(n*rc*Ra); J2=Jo/(n*rc)^2; %moment of inertia referred to the outputshaft B2=(bo+(k2*k3)/Ra)/(n*rc)^2; %viscous-friction coefficient referred to

the output shaft 

Page 49: Design of a PID controller using Matlab and LabVIEW

8/17/2019 Design of a PID controller using Matlab and LabVIEW

http://slidepdf.com/reader/full/design-of-a-pid-controller-using-matlab-and-labview 49/51

49

num2=[K2]; den2=[J2 B2 0]; G4=tf(num2,den2); %transfer function H=1; %feedback G5=feedback(G4,H); %closed-loop transfer function dt=0.01; %time vector 

t=0:dt:3; y2=step(G5,t)'; %don't use [y,t]=step(G5,t) because 't'was already defineddy2=diff(y2)/dt; %difference and approximate derivative d2y2=diff(dy2)/dt; %second derivative [m2,p2]=max(dy2); %returns the indices of the maximum valuesin vector p yi2=y2(p2); %inflection point positionti2=t(p2); %inflection point time plot(ti2,yi2,'*r') hold on L2=ti2-yi2/m2; %delay timeT2=(y2(end)-yi2)/m2+ti2-L2; %time constant 

figure(1) plot(t,y2,'b',[0 L2 L2+T2 t(end)],[0 0 y2(end) y2(end)],'k') title('Step response of the original system 1') grid ylabel('Amplitude') xlabel('Time (sec)') legend('Inflection point','Step response','Tangent line at inflectionpoint') 

% Ziegler–Nichols Rules for Tuning PID Controllers, First Method Kp2=1.2*T2/L2; %proportional gain Ti2=2*L2; %integral timeTd2=0.5*L2; %derivative time 

Ki2=Kp2/Ti2; %integration gainKd2=Kp2*Td2; %derivation gainC2=tf(pid(Kp2,Ki2,Kd2)); G6=feedback(C2*G4,H); 

figure (2) step(G5,G6) title('Step response of the controlled system 1') legend('Original System 1','System 1 with PID') grid 

Figure 40 shows the inflection point and tangent line. Moreover, Figure 41 shows the resultsof the original system and the system with Z-N PID. By applying a Z-N PID controller, the settling time

increased 5.7 times approximately, the overshoot boosted 1.4 times and SST augmented 4.8 times,

as illustrated in Table 6. Therefore, Z-N controller should not be used, if the system does not meet

the method conditions.

Page 50: Design of a PID controller using Matlab and LabVIEW

8/17/2019 Design of a PID controller using Matlab and LabVIEW

http://slidepdf.com/reader/full/design-of-a-pid-controller-using-matlab-and-labview 50/51

50

Figure 40. Step-Response of the prismatic joint

Figure 41. Original system vs. System with Z-N PID

Table 6. Original system vs. System with Z-N PID 

Original System System with Z-N PID

Settling time 1.5006 8.4829

Overshoot % 57.0850 80.0837

Steady state time 2.5 12

Page 51: Design of a PID controller using Matlab and LabVIEW

8/17/2019 Design of a PID controller using Matlab and LabVIEW

http://slidepdf.com/reader/full/design-of-a-pid-controller-using-matlab-and-labview 51/51

REFERENCES

  Åström, K. & Hägglund, T., 2004. Revisiting the Ziegler –Nichols step response method for PID

control. Journal of Process Control, 14(1), pp. 635 - 650.

  Dalmec S.p.A., 2016. Technical characteristics of pneumatic manipulators MaxiPartner.

[Online]

Available at:

http://www.dalmec.com/ing/manipulators/industrial_manipulators_Maxipartner.html

[Accessed 10 04 2016].

  Farnell element14, 2013. Low inertia dc servo motors. [Online]

Available at: http://uk.farnell.com/mclennan/m66ce-12/motor-servo-12vdc-

2700rpm/dp/1784823?ost=M66CE-

12&selectedCategoryId=&categoryName=All+Categories&categoryNameResp=All%2BCatego

ries

[Accessed 02 02 2016].

  Fastech Co., Ltd., 2014. Cloosing Loop Steepping System. [Online]

Available at: http://www.fastech.co.kr/bbs/eng/motor.php

[Accessed 2016 02 08].

  MathWorks, 2015. Control System Toolbox™ User's Guide. 26 ed. Natick(Massachusetts): The

MathWorks, Inc..

  Ogata, K., 2010. Modern Control Engineering. 5 ed. Upper Saddle River(New Jersey): Pearson

Education, Inc.

  Skogestad, S., 2002. Simple analytic rules for model reduction and PID controller tuning.

 Journal of Process Control, I(13), p. 291 –309.