You are on page 1of 35

# Modeling Simulation Block Diagrams Experimentation Summary

## Modeling and Experimentation:

Compound Pendulum

## Department of Mechanical Engineering

The University of Texas at Austin

Fall 2014

## ME 144L Dynamic Systems and Controls Lab (Longoria)

Modeling Simulation Block Diagrams Experimentation Summary

Overview

## This lab focuses on developing a mathematical model of the compound

pendulum system studied in lab experiments.
This lecture reviews the model, then shows how to develop the
mathematical model both as a second order ODE and in state space form.
A key goal is to learn about how numerical simulations of math models can
be used to predict response of a system. A model simulation can be thought
of as another way to experiment with a system.
Block diagrams are also introduced as a way to describe systems within
simulation environments, and LabVIEW examples are provided.
The model simulation results from the pendulum system can be compared
to measured response data in order to improve the model, especially for
determining the dominant type of friction causing the pendulum motion to
decay.

## ME 144L Dynamic Systems and Controls Lab (Longoria)

Modeling Simulation Block Diagrams Experimentation Summary

Lab Objectives

## 1 Practice system modeling methods, including constitutive modeling for

friction effects
2 Become familiar with the National Instruments Control and Simulation
module
3 Use a simulation model to compare with measured data and tune system
parameters

## ME 144L Dynamic Systems and Controls Lab (Longoria)

Modeling Simulation Block Diagrams Experimentation Summary

system model

## Understand the type of model that is needed. To predict the

pendulum response observed in the lab, we need a dynamic system
model in the form of ODEs
Recognize any special considerations. There is significant friction in
the pivot/bearing causing the pendulum oscillation to decay, so the
model needs to include torques induced by friction.
Make sure the model can be used for the intended purpose. Given a
proper model, we need to be able to solve the equations. Since the
ODEs cannot be solved in closed-form, we need to put the model in a
form suitable for simulation.

## ME 144L Dynamic Systems and Controls Lab (Longoria)

Modeling Simulation Block Diagrams Experimentation Summary

## In introductory dynamics courses, you often solved for

forces, accelerations, or velocities of bodies at specific
instants in time. Consider the example below.

## ME 144L Dynamic Systems and Controls Lab (Longoria)

Modeling Simulation Block Diagrams Experimentation Summary

Example continued...

## ME 144L Dynamic Systems and Controls Lab (Longoria)

Modeling Simulation Block Diagrams Experimentation Summary

## We seek system dynamics models as ordinary differential

equations (ODEs) for key variables of interest in order to
study how a system behaves over all time.

The measured decay of the pendulum oscillations in the lab indicates loss
of energy over time due to dissipative effects.

## ME 144L Dynamic Systems and Controls Lab (Longoria)

Modeling Simulation Block Diagrams Experimentation Summary

## A simple pendulum model If there are no other forces, the net

represents dynamics of a point torque for rotation about the pivot
mass at the end of fixed length, is,
massless, rod or string, constrained X
to move in a plane as shown below. T = T = mgl sin
Gravity acts downward.
Now, apply Newtons law,
dh X
= h = J = T
dt
where J = ml2 , so a 2nd order
ODE in is found,

## ME 144L Dynamic Systems and Controls Lab (Longoria)

Modeling Simulation Block Diagrams Experimentation Summary

pendulum

## Simple pendulum: Compound pendulum:

J = ml2 2
J0 = J + mlC
m is the total mass, l is distance from m is the total mass, lC is distance
the pivot to the mass from the pivot to the CG

## ml2 + mgl sin = 0 J0 + mglC sin = 0

g mglC
+ sin = 0 + sin = 0
l J0

## Modeling a compound pendulum as a simple pendulum would incur error that

depends on how widely mass is distributed. In some cases, a simple pendulum
might be a reasonable approximation.

## ME 144L Dynamic Systems and Controls Lab (Longoria)

Modeling Simulation Block Diagrams Experimentation Summary

## Additional torques in the pendulum model

Aside from proper modeling of the inertia effects, the model also needs to
consider other torques that cause changes in the angular momentum. Primarily,
we are concerned here with torques due to dissipative effects (friction at the
pivot, air friction, etc.), or any applied torques or forces on the pendulum body.
Both can be included in the Newtons law equation,

h = T Tf Ta

where Tf is the net torques due to friction/losses and Ta are applied or actuator
torques.
It is clear that the pendulum studied in the lab is not lossless since it does not
oscillate indefinitely, and there are no other applied forces or actuator torques.

## ME 144L Dynamic Systems and Controls Lab (Longoria)

Modeling Simulation Block Diagrams Experimentation Summary

## Modeling frictional torques

Frictional effects can be modeled as frictional torques that act about the pivot.
These torques are modeled as functions of angular velocity, T = f (). Consider
two types:

## These models represent different types of physical processes. For example, if a

bearing has a (viscous) fluid film, induced forces tend to vary linearly with
velocity (left). On the other hand, bearings with dry contact result in forces more
similar to Coulomb-type friction, being relatively constant with velocity (right).
ME 144L Dynamic Systems and Controls Lab (Longoria)
Modeling Simulation Block Diagrams Experimentation Summary

## Case 1: Compound pendulum with only linear damping

Consider a linear damping torque in the pendulum equation,
X
h = T = T Tb

where
Tb = b = linear damping torque
where = . Now,
J0 + b + mglC sin = 0
This equation can be made linear by assuming small motion, so sin would be
approximately and the equation becomes a linear 2nd order ODE with a
closed-form solution.

## ME 144L Dynamic Systems and Controls Lab (Longoria)

Modeling Simulation Block Diagrams Experimentation Summary

## Case 2: Compound pendulum with linear damping and

nonlinear friction
Now include a nonlinear friction torque,
X
h = T = T Tb Tc

where
Tc = To sgn() = Coulombic (nonlinear) frictional torque
Linearizing for small motion as done for Case 1 is problematic, because of the
sgn (signum) function.
The signum function has a very large change in value when its argument is close
to zero: sgn(a) = +1 if a > 0 and sgn(a) = 1 if a < 0.
Closed form solutions for motion cannot be found as readily as for Case 1. It turns
out that this type of friction is more prevalent in many practical systems. Solving
this ODE requires numerical integration schemes for simulating the system.

## ME 144L Dynamic Systems and Controls Lab (Longoria)

Modeling Simulation Block Diagrams Experimentation Summary

## Basic idea behind ODE system simulation

When we talk about system simulation in DSC, this typically refers to solving an
ODE initial value problem. This means that we have a set of ODEs that model
our system of interest1 .
Consider the simplest type of dynamic system, a first order ODE,
dx
= f (x, u, t)
dt
which well call a state equation for the state variable, x. The right hand side is a
function of x itself, an input to the system, u, and time, t.
The modeling process provides f (x, u, t).
Numerical integration requires an initial value at initial time, t0 , x(t0 ) = x0 .
Then, the solution at the next step, t = t0 + t, is to be approximated.

1
Some systems may involve both differential and algebraic equations (DAEs), which
wont be considered in this course.
ME 144L Dynamic Systems and Controls Lab (Longoria)
Modeling Simulation Block Diagrams Experimentation Summary

## Euler ODE Solver

You may recall that numerically solving ODEs for initial value problems is simply
marching forward in time. The solution is found at discrete time steps, given the
initial value at t0 . Given x0 , the value at initial time, an estimate of the value at
t1 is,
x1 = x0 + x0
The job of the solver is to estimate x0 . The simplest algorithm is the Euler
solver, which is basically a Taylor series approximation.
The Euler solve estimates x0 by,

x0 = f (x0 , u0 , t0 ) t

## using an approximation from the ODE

x/t f (x, u, t), and given all
initial values. There is always error in
the estimate of the true value, x1 .

## ME 144L Dynamic Systems and Controls Lab (Longoria)

Modeling Simulation Block Diagrams Experimentation Summary

## Selection of ODE Solvers

The Euler method is the simplest ODE solver, and it usually uses a fixed
time step. To get good solutions (more accurate, stable), usually you need
to make the time step very small.
The Euler method is a 1st order Runge-Kutta (RK) method. You may have
learned about Runge-Kutta methods in a computational methods course.
The most commonly used RK algorithm is 4th order, which uses four
evaluations of the ODEs to estimate the next value of x, as opposed to the
single evaluation made by the Euler routine. The RK4 algorithm allows you
to take larger time steps than Euler, is more stable, but as for Euler the error
must be managed by the user. More sophisticated algorithms use variable
time step to control numerical errors.
Many commercial and open-source software packages have built-in fixed-step
and variable step algorithms that can be used for ODE simulation. This
course will provide practice in using the algorithms available in LabVIEW.

## ME 144L Dynamic Systems and Controls Lab (Longoria)

Modeling Simulation Block Diagrams Experimentation Summary

## ODE solvers require that the equations be put into 1st

order form
The Euler solver was described using the simple 1st order ODE in the variable x.
This is the form required by ODE solvers.
Consider the single x variable generalized as a vector x formed by n state
variables of a system.
ODE algorithms are designed to accept descriptions of the system ODEs as a
vector formed by the model equations. In general, the 1st order vector of state
equations is,
x = f (x, u, t)
where u is now a vector of r inputs.
Writing the equations in this form can either be done by converting the nth order
ODE to n 1st order ODEs, or the n 1st order ODEs can be derived directly. The
latter method is the way equations are directly derived when the bond graph
method is used.

## ME 144L Dynamic Systems and Controls Lab (Longoria)

Modeling Simulation Block Diagrams Experimentation Summary

## Example: Convert the simple pendulum model from 2nd

order to 1st order form

## Recall the simple pendulum model Now, take derivative of second

variable, x2 = . To find this
ml2 + mgl sin = 0 equation, we must use the original 2nd
order ODE, which has as well as .
To convert this 2nd order ODE to 1st Solve for ,
order, first define n = 2 state variables
as x1 = and x2 = . We now want = (g/l) sin = (g/l) sin x1
to write two 1st order ODEs in terms
of these new state variables. The first This gives us the second state
one is found by taking the derivative equation,
of the first variable, x1 = , which is
recognized as x2 . Therefore, the first x2 = (g/l) sin x1
equation is,
These two equations are the state
x1 = x2 space equations for the simple
pendulum.

## ME 144L Dynamic Systems and Controls Lab (Longoria)

Modeling Simulation Block Diagrams Experimentation Summary

## State space form

Here are the simple pendulum state space equations in matrix form:
   
x1 x2
x = = f (x, u, t) =
x2 gl sin(x1 )

## The rightmost term is a vector of the n nonlinear, state equations.

These are in the form required by ODE solvers.
The state equations are generally coupled; i.e., each equation can be
a function of any and all system states.
Each equation quantifies how each state changes over time (the slope
at each time step).
In a numerical algorithm, each equation is used to estimate the value
of the state at each time step, as illustrated for the simple Euler
routine.
ME 144L Dynamic Systems and Controls Lab (Longoria)
Modeling Simulation Block Diagrams Experimentation Summary

## Commercial software packages such as Matlab and LabVIEW have solvers

that will numerically integrate ODEs. The ODEs are usually formatted in
a script function file.
For example, for the simple pendulum, a script file may take the form:

function file
function f = PendulumEqs(t,x)
global g l
f1 = x(2);
f2 = -g*sin(x(1))/l;
f = [f1;f2];

Here, the values returned by this function are sent to the solver (e.g., ode45).
The use of script files is very effective. In this course, we will be learning a
different approach that uses block diagrams to graphically describe the ODEs.
Using this approach allows use of LabVIEW for simulation.

## ME 144L Dynamic Systems and Controls Lab (Longoria)

Modeling Simulation Block Diagrams Experimentation Summary

## Block diagrams are used to graphically represent signal flow and

functional relationships between signals.
A directed line (with arrowhead) indicates a signal, which can
represent a system variable or a control input.
Nodes, shown as blocks, represent input-output relationships between
signal variables..
Basic functions are gains, summers, integrators and differentiators,
and as such block diagrams are effective in representing differential
equation models.
Modern software programs use block diagrams as a way to
communicate system representations to computer-aided analysis tools.

## ME 144L Dynamic Systems and Controls Lab (Longoria)

Modeling Simulation Block Diagrams Experimentation Summary

## Block diagram programming environments have become

very popular as part of computer-aided engineering
packages

Why?
They allow us to describe systems using a graphical form, which can
be useful for communicating how different components interact.
Block diagrams are functional and not just schematics (as we will
see).
There is a rich history not only in describing control systems but also
in how (analog) computational algorithms were originally designed.

## ME 144L Dynamic Systems and Controls Lab (Longoria)

Modeling Simulation Block Diagrams Experimentation Summary

## Summing point Let x(t) input and y(t) output. For

general nonlinear systems, the output
is simply, y = g(x).

Branching point

## G (gain) may be a constant or a

system transfer function, G(s).
The s represents the Laplace
operator.

## ME 144L Dynamic Systems and Controls Lab (Longoria)

Modeling Simulation Block Diagrams Experimentation Summary

## Block diagram calculus

Other blocks especially useful for These are common blocks, but they
representing physical system models are sometimes shown in software
include the integrator: products using the s Laplace operator.
For example, the integrator is:

## Important: these are just symbols - the blocks perform

numerical integration/differentiation (not Laplace
transforms).

## ME 144L Dynamic Systems and Controls Lab (Longoria)

Modeling Simulation Block Diagrams Experimentation Summary

## How do you build a block diagram of system state

equations?
For a given complete set of state equations (as you will learn to derive in ME
344), the following steps are taken:
1 Identify an integrator for each first order equation, so each integrator
generates a state
2 Form the terms of each equation using system parameters, gain blocks, and
functional blocks
3 Use summing blocks form the state derivatives (i.e., add terms as needed to
form the right hand side of each 1st order equation)
4 Specify initial conditions, x(0), and system inputs, u

NOTE: There are some systems that result in equations where the ODEs do not
take this desirable form. You may learn about algebraic loops and derivative

## ME 144L Dynamic Systems and Controls Lab (Longoria)

Modeling Simulation Block Diagrams Experimentation Summary

## Block diagram of nth order state space system

The system equations generate the dx/dt for each state, and the n
integrators produce the states, which are then passed back into the system
equations.

## Note each integrator requires an initial condition, x(0).

ME 144L Dynamic Systems and Controls Lab (Longoria)
Modeling Simulation Block Diagrams Experimentation Summary

## Re-write the 1st order ODE in the form:

dx 1
= [x + u(t)]
dt
Then we can use basic block elements to describe the algebra and the
calculus in the equations, as shown below.

## Remember that to find x the integrator needs to have an initial condition,

x(0).
ME 144L Dynamic Systems and Controls Lab (Longoria)
Modeling Simulation Block Diagrams Experimentation Summary

## These programs feature:

combined structured and block diagram programming
a capacity to communicate with physical hardware
efficient means for designing a human-user interface
modeling and simulation tools for physical and engineering systems

## ME 144L Dynamic Systems and Controls Lab (Longoria)

Modeling Simulation Block Diagrams Experimentation Summary

## ME 144L Dynamic Systems and Controls Lab (Longoria)

Modeling Simulation Block Diagrams Experimentation Summary

## LabVIEW Control and Simulation Module

Build your block diagrams within the Basic block diagram VIs are found
C&S Loop: under Signal Arithmetic:

## ME 144L Dynamic Systems and Controls Lab (Longoria)

Modeling Simulation Block Diagrams Experimentation Summary

state equations

## Remember that the input to the By double-clicking the integrator VI

integrator block will be the derivative block, you can access settings:

## The settings allow you to configure

how you will set key integration
and the output is the state.
parameters and whether you will set
them in the dialog box or wire to a
terminal.
ME 144L Dynamic Systems and Controls Lab (Longoria)
Modeling Simulation Block Diagrams Experimentation Summary

system

## ME 144L Dynamic Systems and Controls Lab (Longoria)

Modeling Simulation Block Diagrams Experimentation Summary

## In this example VI for the simple pendulum, a formula node used as an

alternate way to code the state equations rather than with block diagrams.

## ME 144L Dynamic Systems and Controls Lab (Longoria)

Modeling Simulation Block Diagrams Experimentation Summary

Experimentation

## The experimentation is now to be conducted using a numerical model.

Here are some suggestions for using your simulation model:
determine if your estimates of the pendulum moment of inertia allows
predictions to compare well with measured response data; show how
the simulation can be tuned to improve the model
show that the simulation gives the same type of response
characteristics, especially with proper frictional torque models; weigh
the effect of linear versus nonlinear type friction
calculate stored energy, and improve prediction on how energy
decreases with each cycle

## ME 144L Dynamic Systems and Controls Lab (Longoria)

Modeling Simulation Block Diagrams Experimentation Summary

Summary

## Build experience formulating system models from physical laws

Use a known physical problem for learning about constitutive models,
especially linear vs. nonlinear types
More opportunity to experiment with LabVIEW VIs for simulation,
learning about Control and Simulation Module
Use LabVIEW for analyzing data from experiments, relating to
modeling results