You are on page 1of 4

# UPDATE

technology

## Dynamic system simulation

T
Kevin Hogan his is the final article of a five-part given time, it suffices to specify the initial values
Ricardo Dunia series reviewing various programming of the systems state variables as well as a func-
National Instruments approaches to complex systems. Pre- tion that determines how quickly the variables
vious articles have focused on ladder should be changing at any time:
diagrams, function block diagrams, textual pro-
a programming model for describing and simu- dx (t)= f (x(t),t)
lating the behavior of dynamic systems as they dt
change over timean often essential step in the
design of a controller system. You can approximate time evolution of the
The term dynamic system usually refers to system as a series of states that it reaches in
a system whose state variables change in time. time steps. Simplest, although usually least
In a mechanical system, these variables might accurate, is the Euler method, which computes
be the positions, velocities, and accelerations. In the state at the next time step by the Euler
electrical systems, currents and capacitor charg- formula:
es usually provide state variables. In a chemical
system, the variables might be concentrations of x (tn+1)=x(tn)+dx (tn)(tn+1tn)
various reactants. dt
You may often want to control dynamic
systems, and the control algorithm itself is a There are other more accurate but more com-
dynamic system (controller) with internal state plicated methods for approximating the systems
variables. To help design a complicated control state, but they all work similarly to the Euler
algorithm, you can simulate the interaction of equation, and all compute approximate states of
the controller and the plant offline. the system at a series of time steps.

## Simulation of a dynamic system Control block diagrams

To compute the state of a dynamic system at any Control engineers rarely think of their systems in

## Control block diagram for a torsional pendulum system

Profile
Position
PID Electric DC motor Plant
controller driver

ONLINE
To see the first four parts Process variable
of this Programming
Low pass
Methods series, see filter cutoff
www.controleng.com/
Setpoint
archives for the following
articles: PID gains (x 2^8)
Aug. 2007 - Statecharts
halp program powerful Notch filter frequency
systems
Jul. 2007 - Function
block diagrams Camera
Jun. 2007 - Textual
computation models Source: National Instruments and Control Engineering

Mar. 2007 - Ladder logic Many control engineers prefer to visualize their systems in a control block diagram rather than
strengths and weaknesses as a set of differential equations.

## 22 OCTOBER 2007 CONTROL ENGINEERING www.controleng.com

technology update

Software tools help engineers create simulations in control block form. Source: National Instruments

terms of the differential equations. Rather, they of the system, which are driven not only by their
prefer to think in terms of separate, interacting initial conditions but also by the input variables.
components connected together as part of a con-
x (t0)= x0
trol block diagram. In a control block diagram,
the output of a component block may depend on dx (t)= f (x(t),u(t),t)
dt
the physical state of the component block and/
y(t)= g(x(t),u(t),t)
or its inputs. In addition, it is often necessary to
have output signals from the plant that feed back Note that the outputs are described as a func-
to the controller input. tion of the state variables and input variables,
Although they appear different, control block with no dynamics added but the ones provided
diagrams are equivalent to the differential equa- by the states.
tion representation. In general, a dynamic system You can place system blocks in a series,
block in the control block diagram is represented which indicates that for consecutive blocks, the
by a single box with internal state variables and outputs of a former block become the inputs of
time-varying input and output variables. the later one. For example, consider the case of
The input and output variables are signals a torsional pendulum. The actuator is an electric
injected into and extracted from the dynamic motor that provides torque based on the elec-
system to account for interaction among the dif- tric current supplied to the motor. The electric
ferent components in the block diagram. The current is determined by drive electronics that
state variables define the dynamic characteristics communicate to the PID controller. The PID
controller input is the
difference between
the reference (instan-
taneous value of the
set point as it moves
on its trajectory) and
the plant-block out-
put measured by a
camera that deter-
mines the position of
the top disc.
A typical control
loop feature is feed-
back interaction,
which is the connec-
tion of outputs from
Simulation tools can later system blocks
provide graphic repre- to the inputs of for-
sentations of system mer system blocks.
activity. Source: National In our example, the
Instruments plant-block output

## 24 OCTOBER 2007 CONTROL ENGINEERING www.controleng.com

technology update

is an input for the PID controller. The MATRIXx suite, MathWorks Simulink Dynamic system block
computed simulation model accounts environment, and NI LabVIEW Con-
for feedback connections in a natural trol Design and Simulation Moduleare
fashion. available to describe a system using
u(t) System y(t)
control block diagrams and simulate the
x(t)
Simulation of a control block systems behavior.
diagram system Software that simulates a control
Several software toolsincluding NI block diagram generally runs the system
Source: National Instruments and Control Engineering

## Each system block has inputs and out-

puts, as well as internal state variables.

## as part of a large loop, with iterations of

the loop representing one time step of
the system. In addition, such software
provides several methods for solving
the system described by the diagram
including highly accurate variable-step-
size solvers suitable for quick offline
simulation, as well as fixed-step-size and
discrete solvers suitable for deployment
to a real-time target.
Some dynamic system simulation
products also make it easy to interact
directly with hardware in the diagram.
For example, the LabVIEW Control
Design and Simulation Module includes
functions for interfacing with data acqui-
sition devices.
functions for porting a simulation to a
real-time implementation. For example,
you can use the NI LabVIEW Control
Design and Simulation Module to port
targets such as NI CompactRIO and PXI
hardware.
In a control block diagram, all blocks
placed inside the simulation framework
execute according to the integration
solver defined for the simulation loop.
The blocks represent control blocks
5.7" Color Touchpanel, QVGA I/O options: via snap-in & expansion that could execute at different sample
256 colors, TFT LCD display modules, including HS I/Os, temperature rates. This multirate execution is essen-
Up to 1024 displays per application and weight measurement tial to determine the interaction of the
HMI graphs- color-code application trends Application memory: 2MB; different mechanical-electrical devices
Fonts - 1MB; Images - 6MB because devices placed inside a control
loop rarely all execute at the same sam-
Scan time: 9 sec per 1K of pling rate.
Ethernet via TCP/IP typical application Another benefit to using the simu-
MODBUS, CANopen and UniCAN Auto-tune PID: up to 20 lation model is that you can adjust
GPRS/GSM/SMS support independent loops parameters on the fly as the simulation
progresses in time. You can modify the
Remote Access utilities Recipe programs and datalogging PID controller gains and motor configu-
ration parameters to determine optimal
parameters for the closed-loop response.
Unitronics, Inc., 1 Batterymarch Park, Quincy, MA 02169 Note also the feedback interconnection,
Toll free: 866-666-6033, Tel: 617-657-6596 , Fax: 617-657-6598 in which the pendulum position con-
www.unitronics.com . usa.sales@unitronics.com
26 SEPTEMBER 2007 CONTROL ENGINEERING www.controleng.com
technology update

## nects to the controller input, is natu- Strengths and weaknesses Strengths:

rally implemented inside the simulation As with all computation models, dynam- Intuitive, self-documenting repre-
loop. ic system simulation is more appropriate sentations of dynamic systems. Cre-
Finally, the implementation of a in some programming situations and less ate descriptions of complex systems that
simulation in a software package can in others. It is important to understand are easily read and understood by other
also make it easy to create complex user and incorporate the strengths and weak- engineers.
interfaces. nesses of the computational model into Multiple options for advanced
your software design decisions. simulation solver methods. Take
implementations of complex solver
and BDF solvers.
Multirate execution capability.
Easily and intuitively schedule control
blocks running at different rates.
eters. Easily vary the parameters of the
control blocks during the course of the
simulation.

Weaknesses:
Incomplete programming system.
To represent functions that are not pro-
vided directly with the simulation suite,
you must combine the simulation system
with a general-purpose programming
language such as C or LabVIEW.
More time spent on analysis. To
break a system down into component
dynamic systems, you must conduct
some analysis.
With the simulation model of com-
putation, controls experts can develop
complicated control algorithms quickly
to test their interactions with simulated
plants and to deploy their control algo-
rithms to a variety of targets.

## Kevin Hogan is a senior engineer for the

LabVIEW Control Design and Simulation
Module in LabVIEW R&D at National
Instruments in Austin, Texas. Hogan joined
NI in August 1999 and holds a masters in
computational applied mathematics from
The University of Texas at Austin.
Ricardo Dunia is a senior engineer for
the LabVIEW Control Design and Simula-
tion Module in LabVIEW R&D at National
Instruments in Austin, Texas. He is also a
lecturer for the Process Control senior class
in the Cockrell School of Engineering at
The University of Texas at Austin. Dunia
joined NI in March 2003 and holds a doc-
torate in chemical engineering from the
UT-Austin.