Controls Tutorials
Controls Tutorials
Controls Tutorials
VERSION 2016
by
Gamma Technologies
GT SUPPORT
• TELEPHONE: (630) 325-5848
• E-MAIL: [email protected]
TABLE OF CONTENTS
TUTORIAL 1: Defining and Using a PID Controller ........................................................................... 1
1.1 Introduction to PID Controllers (and alternative options) ............................................................... 1
1.2 Role about GT-SUITE Controllers .................................................................................................. 1
1.3 Controller Fundamentals ................................................................................................................. 2
1.3.1 Terminology ........................................................................................................................... 2
1.3.2 PID Controller Technical Background ................................................................................... 3
1.3.3 Controller and Plant Interaction ............................................................................................. 3
1.4 Methodology to Characterize the Plant and Build a Controller ...................................................... 5
1.4.1 Simulate the Step Function and the Plant's Response ............................................................ 5
1.4.2 Characterize the system by solving for K and τ ..................................................................... 5
1.4.3 Use K and τ to calculate the gains .......................................................................................... 6
1.4.4 Build the controller using the gains ........................................................................................ 6
1.4.5 Check the controller................................................................................................................ 6
1.5 Example: Target Boost Pressure by Wastegate Control .................................................................. 7
1.5.1 Simulate the Step Function and the Plant Response .............................................................. 7
1.5.2 Characterize the system by solving for K and τ ................................................................... 12
1.5.3 Use K and τ to calculate the gains ........................................................................................ 15
1.5.4 Build the controller using the gains. ..................................................................................... 15
1.5.5 Check the controller.............................................................................................................. 17
Tutorial 1
• controlling the wastegate diameter of a turbocharger to target a given boost pressure, turbine
RPM, or airflow rate
• controlling a throttle or injection rate to target engine speed or vehicle speed
• controlling a valve in a cooling system to target a coolant temperature
The generic nature of a PID controller--the fact that it can be used to target almost any quantity, also
means that effort is required to calibrate its "gains" so that the controller reaches the target:
1) In a stable manner--a steady output signal so that there is not oscillation around the target
2) In a prompt manner (i.e. reasonable time scale) so that excessive computational time is not required
waiting for the signal to move.
It can take time, and sometimes be difficult, to find a set of gains that reach the proper balance of
stability and prompt response; in fact, that is the purpose of this tutorial - to provide a means of finding
good gains. For this reason, GT-SUITE provides specialized templates, known as model-based
controllers, which can replace a PID controller for a few common engine control situations (see
"Targeting Controllers" group in the Controls tab of the template library), and several more are expected
to be added in the near future. In general, when a model-based controller is available, it should generally
be used instead of the PID because it will be both easier to use and more robust than a PID controller.
The purpose of the example in this tutorial is somewhat different…it is to create a "utility" for modeling.
This purpose is analogous to the many controllers that exist on laboratory software to target many things
such as engine speed, torque, EGR fraction, intercooler outlet temperature, etc. Most typically these
controllers are run at steady state or quasi-steady state, and designed strictly to aid the engineers working
the laboratory to run tests at particular conditions. These controllers are most typically not related to the
development efforts to make the engine control unit (ECU) strategy for the production engine/vehicle.
Another question that sometimes arises is the relationship between Simulink and GT-SUITE. Simulink is
the most common tool used in the automotive industry to develop ECU control strategies, and for several
good reasons. Simulink and GT-SUITE can readily be coupled together for controls studies. For more
information on co-simulation between GT-SUITE and Simulink please consult the Controls Coupling and
Real-Time manual (File\Manuals\Co-Simulation_And_UserCode\ControlsCouplingAndRealTime.pdf).
On the other hand, for the more modest objective of making simulation utility controllers it is more
convenient to use the controls library built into GT-SUITE. Reasons including the following:
1) GT-SUITE's library of controllers is often more convenient to use in GT-SUITE for such simple,
system-level tasks, especially in the case of post-processing and model building. (A key factor in
this is that Simulink does not have a "Case Setup" utility analogous to the one in GT-SUITE.)
2) Often times, the powertrain development engineers who need such controllers are not trained in
Simulink.
3) Software costs are minimized--to run GT-SUITE and Simulink coupled is not difficult, but it
does require a full license of both programs to run.
4) Support is available from Gamma Technologies for the combined powertrain and controls
system.
1.3.1 Terminology
System: The "system" refers to the simulation components in its entirety, including both the controller
and the plant.
Plant: The "plant" typically refers to the physical part of the system being modeled. In the example of
this tutorial, the engine, including its turbocharger, ambient, combustion conditions, injectors, etc., is the
plant.
Controller: The controller refers to the components that sense performance, make "decisions" according
to those results (typically through electronic means), and the actuators that in-turn operate on the plant.
For example, the wastegate is part of the plant, but a servo-motor that controls the wastegate position is
part of the controller.
Target Signal: The "target" value assigned to the controller. A well-designed controller will move the
actuator (such as injection rate, wastegate diameter, etc.) so that the plant's output (i.e. torque, BMEP,
manifold pressure, etc.) is forced to the specified target signal.
Characterize: The process of actuating the plant with some predefined inputs and studying the resultant
response of the plant in an attempt to describe its behavior. The plant can be thought of as a "black box",
and the goal is to find the coefficients to an equation, ideally a linear first order equation, that will
"characterize" the plant.
Three values characterize a PID controller: Proportional gain, Integral gain, and Derivative gain. Please
refer to the documentation for 'PIDController' in the Reference Manual or on-line help for the exact
equations of the PID controller. The equations for a "true mathematical" PID controller are slightly
different than the governing equations presented in the documentation, but the GT-SUITE equations are
more commonly used in industry because of certain computational difficulties associated with true PID
mathematical differential equations.
A common practice in industry is to ignore the D (derivative) term of the PID controller. Derivative gain
is usually not necessary, and therefore its use creates an unnecessary complication when finding good
PID gains. This tutorial follows this practice by always setting the D term to 0.0, effectively making a PI
Controller. However, common practice is that it is still called a PID controller, despite the lack of a D
term.
The primary goal when building a PID controller is to find gains that will force the plant to the target
value as quickly as possible. In the controls field, the most common approach finding good gains is the
"trial-and-error" method, typically known as "controls calibration". Controls engineers use many
different utilities to automate the calibration process, and so it is typically an efficient method, especially
considering the complex interactions and behaviors that are exhibited by some engine and controller
combinations.
However, the controller is a time-based mechanism, and so the ability to run many trial-and-error tests
takes time—literally elapsed time. If the controlled event lasts a few seconds, then many controller
iterations can be run without consuming a great deal of time. However, if the event occurs very slowly,
the trial and error calibration method becomes much less attractive. Such is the case when running
simulations in GT-SUITE, because even though the events being modeled may occur over just a few
seconds in real time, the simulation may run significantly slower than real time, thus the computational
time can become very large. Therefore, an analytical method has been developed to find the P and I
gains.
Time (t)
∆Y
-1 0 1 2 3 4 5
Time (t)
Therefore, if the plant is assumed to have a linear first order response, then τ, ∆X, and ∆Y at some
operating condition are all that is needed to characterize the plant as a linear first order system. Once they
are known, complementary proportional and integral gains can be calculated analytically. This leads to
the following questions:
1) Does the plant (the engine) typically behave as a linear first-order system?
2) If so, how can τ, ∆X, and ∆Y be found?
3) Once the system has been characterized, how are the gains solved?
Fortunately, most of the engine's responses to inputs do behave closely enough to a first-order system for
the equations above to be useful. A diesel engine's boost pressure response to a change in wastegate
diameter is a very close match.
The spreadsheet also needs inputs for the steady state result, both before and after the step, and the time
at which the step is imposed. From this data, K will be calculated. The spreadsheet then has features that
can be used to easily find the time constant, τ.
The output from the 'PIDController' can then be connected to an 'ActuatorConn' to actuate the plant input.
If the input values specified in #2 above are not in a form consistent to the actuator (i.e. the inputs to the
spreadsheet were discharge coefficients, but the throttle is actuated by angle, or the inputs were diameter-
squared, but the wastegate is actuated by diameter), then use a 'Lookup1D' component to modify the
signal to the compatible input unit.
Open %GTIHOME%\v2016\tutorials\Modeling_Applications\Controls\01-PIDcontrol\PID-begin.gtm
and save it as PID-step.gtm. Edit the 'turb' object to impose a step at 1 second - Type "WG-Step" into the
object value field for Wastegate Diameter, then double-click on it to define it as a 'Profile Transient'
object. Fill in the Arrays folder as shown below to impose a step from 12 to 14mm. No changes are
needed in the Options folder.
When performing this procedure, make sure that the imposed step in WG diameter occurs after the
'Inertia Multiplier' attribute in the 'ShaftTurbo' object has returned to a value of 1.0. This can be checked
by opening the 'ProfilePeriod' object "inert-mult" from the 'tcshaft' object (edit 'tcshaft' and double click
"inert-mult"). In the Arrays folder, it can be seen that the "Inertia-Multiplier" returns to 1.0 after 18
cycles. Since 18 cycles = 0.72 seconds at 3000 RPM, the "Inertia-Multiplier" is indeed back at 1.0 after
1 second, the time of the imposed step. We may continue.
Go to Case Setup and turn off cases 2 and 3. Double check that RPM=3000 in Case 1.
Go to Run Setup. In the TimeControl folder, make Simulation Duration 100 cycles so that the simulation
will be able to run long enough to capture the tail of the response curve. Change the minimum number of
cycles to 30 (a value greater than the step change at 1 second=25 cycles) so that the simulation cannot
shut off until after the step function is imposed. You may also turn off Automatic Shut-off When Steady
State.
For this particular control situation, it is really the AVERAGE boost pressure that is to be targeted - it
would be impossible to make the pressure match the target at every crank-angle, due to the pressure
pulses from the engine; and even if we did, the wastegate would be constantly oscillating, which would
also be undesirable. Therefore, a 'MovingAverage' template will be used to smooth the signal before
feeding the signal into the controller. We want to include the 'MovingAverage' even in this step of
characterizing the system, since it contributes to the speed at which the system will respond to the input
step. Note: When using any of the model-based controllers mentioned in Section 1.1, it is not necessary
to pass the input signal through a 'MovingAverage' template because the controller will appropriately
condition the input signal by design.
Drag the 'MovingAverage' template from the "Controls" folder (Averaging and Filtering group) of the
template library into the PIDstep.gtm. Make a new object called "Boost-Smooth" for the moving average.
A window width of 1 cycle should be chosen. The other attribute values may be left as "def". Notice the
folder "Input/Output Signal Setup". Open that attribute folder and re-name the Input Signal Description
to "Intercooler Outlet Pressure (bar)" and the Output Signal Description to "Smoothed Intercooler Outlet
Pressure (bar)". This folder is available in a variety of controls templates, and allows the user to override
the signal labels, such that they assume more meaningful names. This is especially useful for very
complex models with many links, and can make complex model building and debugging significantly
easier.
Main Folder
Let's assume that the boost pressure target is intended for the intercooler outlet - at the flowsplit part
named "icout." Drag the new 'Boost-Smooth' part on to the map, then link from the flowsplit to the
'MovingAverage'. A 'SensorConn' will automatically be placed in the middle, and you will be prompted
to choose the value to be sensed. Choose "Static Pressure". You will see that the Link ID for part Boost-
Smooth-1 is what was entered into the "Input Signal Description" attribute of the Boost-Smooth.
Then, turn on the plots in the 'MovingAverage' so that a record of the smoothed pressure is available.
Also, when the mouse is hovered over the link that was renamed, a tooltip textbox will appear which
displays the link name.
To get the steady-state outputs before and after the step, open PIDstep.gdx in GT-POST. View the output
plot of the 'MovingAverage' that we turned on in the previous step. (Compare this to the input plot to see
the purpose of the MovingAverage.) Then in the tree-view of GT-POST, expand the tree to find the data
set for the "Output". Right-click on it and select "View Data" to see the raw data in the plot. Find the
data just prior to 1.0 second (the step) and then at the simulation end. Note that your data may differ
slightly from the values shown below.
Enter the data just discussed into the boost.xls spreadsheet, as shown below. Since we are using
diameter2, enter 144 and 196 for the input signals. It also asks for the "Desired Number of Time
Constants". This is because we will be using the curve immediately above to "fit" the linear first-order
curve, thus allowing τ to be found. It is typically recommended that 1.5 times constant be chosen. The
Green-colored cell (B15) informs us that the value of Y (i.e. the sensed and filtered boost pressure) at
1.5τ is equal to 1.9756 bar in this case. Viewing the data again in GT-POST, find the time after the step
change when the pressure drops to the value shown in cell B15 and enter it into the spreadsheet.
Once the data has all been entered, the characterization is finished. Note the values for τ and K in the
"RESULTS" section of the spreadsheet. The fit of our equation using τ and K can be seen in the plot
below that was created in GT-POST by pasting the curve from the spreadsheet (just below the RESULTS
section) against the plot shown above by creating a new Report File (GU) in GT_POST. The range of the
plot may be shortened or lengthened by adjusting the time interval in cell B24.
Even though we have chosen to control diameter-squared, the actuator option available on the 'turb' part
is "Wastegate Diameter (mm)". Use a 'MathFunction' template to perform a square-root operation on the
signal.
Connect the control parts together as shown below. An 'ActuatorConn' will automatically be added to the
link between the 'MathFunction' and the 'turb' objects. Select "Wastegate Diameter" as the link input.
The same exact controller can be built using the second set of radio-buttoned attributes titled "Gains
Calculated". The attributes "Slope, Time Constant (Tau), and Ratio of Settling Time to Time Constant"
can be used to fully-constrain the system. To do this, double-click on Boost-Controller, and instead
select the radio button for "Gains Calculated", as shown in the image below. Insert the Slope, Time
Constant, and Ratio of Settling Time to Time Constant that was calculated previously using the Excel
spreadsheet. Note that when this set of attributes is used, the damping ratio is always assumed to be 1.
Keep all other folders of the Boost-Controller the same, and re-run the simulation. The results of this
simulation should be identical as when using the "Gains Specified" radio button.
The benefit of using the "Gains Calculated" attributes is that the slope and time constant may be more
directly intuitive from some knowledge of the physical system itself. For this reason, it may be easier for
the user to simply make some educated estimates of the behavior of the system to achieve acceptable
controller behavior, rather than going through the calibration procedure for that particular system.