PID Control Design - MapleSim Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


Using the MapleSim Control Design Toolbox to Design a PID Controller

 

1. Introduction

2. Pole Placement Method

3. Exact Pole Placement Method

4. Gain-Phase Margin Method

5. Automatic Tuning

 

 

 

 

 

1. Introduction

2. Pole Placement Method

3. Exact Pole Placement Method

4. Gain-Phase Margin Method

5. Automatic Tuning

1. Introduction

This worksheet illustrates how the MapleSim Control Design Toolbox can be used to design PID controllers using several methods. This worksheet is divided into 3 sections. In the first section, we will use the Pole Placement method to design a PI controller for a second-order system so that we can confine the closed-loop poles to a desired region. In the second section, we will use the Exact Pole Placement method to design a PID controller so that we can specify the exact location of the dominant poles. Finally, in the last section, we will use the Gain-Phase Margin method to design a PID controller for a fifth-order system.

2. Pole Placement Method

 

The Pole Placement method is a unique feature of the MapleSim ControlDesign toolbox. It allows you to specify a desired region for the closed-loop poles based on damping ratio, ζ, and the natural frequency, ωn.  In this section, we will show how the Pole Placement method can be used to design a PI controller for an arbitrary second-order system.

We can create a second-order system using the DynamicSystems[NewSystem] command

sys1  DynamicSystemsNewSystems+3s23s+5:

DynamicSystemsPrintSystemsys1

Transfer Functioncontinuous1 output(s); 1 input(s)inputvariable=u1soutputvariable=y1stf1,1=s+3s23s+5

(1)

As mentioned above, the desired region for the closed-loop poles is defined by the damping ratio, ζ, and the natural frequency, ωn. For this example, the values of 0.7 and 5/2 have been chosen for the damping ratio and natural frequency, respectively.

 

ζ10.7

0.7

(2)

ωn152

52

(3)

Based on the values of ζ1 and ωn1, the command ControlDesign[FeasibleGain] provides you with the option to output a list of 3 possible gain values for the PI controller as sample designs for which all the closed-loop poles will lie in the desired region. Alternatively, the command gives you the option to plot a region of feasible gain values.

 

solution1ControlDesignFeasibleGainssys1,ζ1, ωn1, 'output'=samplepoints, 'condition' =all, posgains=true, controller= 'PI'

K=20,Ki=56,K=22,Ki=64,K=3544762151115137438953472,Ki=64

(4)

 

ControlDesignFeasibleGainssys1,ζ1, ωn1, 'output' =region, 'condition' =all, 'posgains' =false, 'controller' = 'PI'

For this example, we will use the gain values for kc and ki as provided in (4)

kp1rhssolution121;ki1rhssolution122

64

(5)

Using these gain values, the transfer function for the PI controller can be determined as:

Gc1  DynamicSystemsNewSystemkp1+ki1s:

DynamicSystemsPrintSystemGc1

Transfer Functioncontinuous1 output(s); 1 input(s)inputvariable=u1soutputvariable=y1stf1,1=22s+64s

(6)

 

At this point, we can automatically obtain the transfer function for the closed-loop system using the command ControlDesign[PIDClosedLoop].

ClosedLoopSys1  ControlDesignPIDClosedLoopsys1,Gc1:

DynamicSystemsPrintSystemClosedLoopSys1

Transfer Functioncontinuous1 output(s); 1 input(s)inputvariable=y1_refsoutputvariable=y1stf1,1=22s2+130s+192s3+19s2+135s+192

(7)

 

As expected, the poles of the closed-loop reside in the region defined by ζ1 and ωn1.

 

ControlDesignRegionPolesClosedLoopSys1,ζ1,ωn1 

 

The pole locations can be determined using the following command:

polesDynamicSystemsZeroPolePlotClosedLoopSys1,output=data2:

Pole Locations

poles1 = 8.568677101072685.44581967628199I

poles2 = 8.56867710107268+5.44581967628199I

 

poles3 = 1.86264579785464

 

 

The step response of the open and closed-loop system can be determined using the DynamicSystems[ResponsePlot] command. From the plots, we can see how the including of a PI controller was able to stabilize the system.

 

p1DynamicSystemsResponsePlotClosedLoopSys1,Step, 'duration' =5, 'numpoints' =300, 'color' =blue, 'legend' =Closed Loop Response, 'labels' =time,Amplitude:

p2DynamicSystemsResponsePlotsys1,Step, 'duration' =3, 'numpoints' =300, 'color' =red, 'legend' = Open Loop Response, 'labels' =time,Amplitude:

plotsdualaxisplotp1,p2

3. Exact Pole Placement Method

 

In this section, we will show how the Exact Pole Placement method is used to design a PID controller for a 2nd order system.

 

As in the previous section, the transfer function of the open loop system can be defined as follows:

sys2  DynamicSystemsNewSystem3s2+3s+5:

DynamicSystemsPrintSystemsys2

Transfer Functioncontinuous1 output(s); 1 input(s)inputvariable=u1soutputvariable=y1stf1,1=3s2+3s+5

(8)

 

Let us assume that the desired closed-loop pole locations are:

 

poles24+2I,42I,52

4+2I,42I,52

(9)

 

Using the ControlDesign[DominantPole] command we can obtain the PID controller transfer function

Gc2ControlDesignDominantPolesys2,poles2, 'controller' =PID, 'returntype' = system: DynamicSystemsPrintSystemGc2;

Transfer Functioncontinuous1 output(s); 1 input(s)inputvariable=u1soutputvariable=y1stf1,1=15s2+70s+1006s

(10)

 

At this point, we can automatically obtain the transfer function for the closed-loop system using the command ControlDesign[PIDClosedLoop].

ClosedLoopSys2ControlDesignPIDClosedLoopsys2, Gc2:DynamicSystemsPrintSystemClosedLoopSys2

Transfer Functioncontinuous1 output(s); 1 input(s)inputvariable=y1_refsoutputvariable=y1stf1,1=15s2+70s+1002s3+21s2+80s+100

(11)

 

The step response of the open and closed-loop system is shown in the following plots. The closed-loop response in addition to tracking the input signal is much faster than then open-loop response.

 

p3DynamicSystemsResponsePlotClosedLoopSys2,Step,duration=7,numpoints=300,color=blue,legend=Closed Loop Response,parameters=a=3,b=5,c=2:

p4DynamicSystemsResponsePlotsys2,Step,duration=7,numpoints=300, color=red, legend = Open Loop Response,parameters=a=3,b=5,c=2:

plotsdisplayp3,p4, labels=time,Amplitude

4. Gain-Phase Margin Method

In this section, we will show how the Gain-Phase Margin method is used to design a PID controller for the following fifth-order system.

 

sys3  NewSystem70s+1s+25:

DynamicSystemsPrintSystemsys3

Transfer Functioncontinuous1 output(s); 1 input(s)inputvariable=u1soutputvariable=y1stf1,1=70s+70s5+10s4+40s3+80s2+80s+32

(12)

 

The system gain margin (in decibels) and associated crossover frequency (in rad/sec) is:

DynamicSystemsGainMarginsys3,decibels=true

3.736886602,2.329625869

(13)

 

Similarly, the system phase margin (in degrees) and crossover frequency (in rad/sec) is:

DynamicSystemsPhaseMarginsys3,radians=false

29.28289234,1.826456270

(14)

 

Using the ControlDesign[GainPhaseMargin] command we can obtain the PID gain values so that the desired gain and phase margin for the closed-loop system is at least, 15 dB and 60°, respectively.

Gc3  ControlDesignGainPhaseMarginsys3,15,60, 'controller' =PID, 'decibels' =true, 'radians' =false, 'returntype' = system: DynamicSystemsPrintSystemGc3;

Transfer Functioncontinuous1 output(s); 1 input(s)inputvariable=u1soutputvariable=y1stf1,1=0.1091140582s2+0.1653439858s+0.2796556965s

(15)

 

At this point, we can automatically obtain the transfer function for the closed-loop system using the command ControlDesign[PIDClosedLoop].

ClosedLoopSys3  ControlDesignPIDClosedLoopsys3, Gc3:

DynamicSystemsPrintSystemClosedLoopSys3

Transfer Functioncontinuous1 output(s); 1 input(s)inputvariable=y1_refsoutputvariable=y1stf1,1=7.637984074s3+19.21206308s2+31.14997776s+19.57589876s6+10.s5+40.s4+87.63798407s3+99.21206308s2+63.14997776s+19.57589876

(16)

 

The gain and phase margin and crossover frequencies for the loop transfer function are shown below. These values exceed the minimum requirements specified above.

 

LoopTfDynamicSystemsTransferFunctionsys3:-tf1,1Gc3:-tf1,1:

 

DynamicSystemsGainMarginLoopTf, decibels=true

24.84114154,4.262178342

(17)

DynamicSystemsPhaseMarginLoopTf, radians=false

62.28336593,0.5475206098

(18)

 

The step response of the open and closed-loop system is shown in the following plots. Unlike the open-loop response which was more than 100% off in the steady state, the closed-loop response now tracks the input signal.

 

p5DynamicSystemsResponsePlotClosedLoopSys3,Step,duration=20,numpoints=300,color=blue,legend=Closed Loop Response:

p6DynamicSystemsResponsePlotsys3,Step,duration=20,numpoints=300, color=red, legend = Open Loop Response:

plotsdisplayp5,p6, labels=time,Amplitude

 

The bode plots of the open-loop system and the loop transfer function are shown below.

 

DynamicSystemsBodePlotsys3, color=Red

 

DynamicSystemsBodePlotLoopTf,color=Blue

 

5. Automatic Tuning

In this section, we will show how to tune the parameters of a PID controller using a single tuning parameter t, which is equivalent to the desired time constant of the closed-loop system.

 

sys4  NewSystem5s+13 s+15 s+1:

DynamicSystemsPrintSystemsys4

Transfer Functioncontinuous1 output(s); 1 input(s)inputvariable=u1soutputvariable=y1stf1,1=515s3+23s2+9s+1

(19)

The desired closed-loop time constant t is 1.0 second (for a settling time of approximately 6τ=6 seconds).

  τ1.0

1.0

(20)

infolevelControlDesign3:

pidtf  ControlDesignPIDAutosys4, τ, 'returntype' = system: DynamicSystemsPrintSystempidtf

Transfer Functioncontinuous1 output(s); 1 input(s)inputvariable=u1soutputvariable=y1stf1,1=2.359777777s2+1.136444444s+0.13333333330.02333333333s2+s

(21)

ClosedLoopSys4  ControlDesignPIDClosedLoopsys4, pidtf:

DynamicSystemsPrintSystemClosedLoopSys4

Transfer Functioncontinuous1 output(s); 1 input(s)inputvariable=y1_refsoutputvariable=y1stf1,1=11.79888888s2+5.682222220s+0.66666666650.3500000000s5+15.53666667s4+23.21000000s3+20.82222221s2+6.682222220s+0.6666666665

(22)

p7DynamicSystemsResponsePlotClosedLoopSys4,Step,duration=30,numpoints=300,color=blue,legend=Closed Loop Response:

p8DynamicSystemsResponsePlotsys4,Step,duration=30,numpoints=300, color=red, legend = Open Loop Response:

plotsdisplayp7,p8, labels=time,Amplitude

 

Verify the resulting closed-loop settling time

tsettling  DynamicSystemsStepPropertiesClosedLoopSys47

6.04634199312517,1.02000000000000

(23)