Modeling and Experimentation: Compound Pendulum Prof. R.G. Longoria Department of Mechanical Engineering The University of Texas at Austin Fall 2014
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.
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
Use modeling to build insight and derive a proper dynamic 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.
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.
Example continued...
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.
Example: the simple pendulum model A simple pendulum model represents dynamics of a point mass at the end of fixed length, massless, rod or string, constrained to move in a plane as shown below. Gravity acts downward. If there are no other forces, the net torque for rotation about the pivot is, T = Tθ = mgl sin θ Now, apply Newton s law, dh dt = ḣ = J θ = T where J = ml 2, so a 2nd order ODE in θ is found, ml 2 θ + mgl sin θ = 0
Contrast the simple pendulum with the compound pendulum Simple pendulum: J = ml 2 m is the total mass, l is distance from the pivot to the mass ml 2 θ + mgl sin θ = 0 θ + g l sin θ = 0 Compound pendulum: J 0 = J + ml 2 C m is the total mass, l C is distance from the pivot to the CG J 0 θ + mglc sin θ = 0 θ + mgl C J 0 sin θ = 0 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.
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 Newton s law equation, ḣ = T θ T f T a where T f is the net torques due to friction/losses and T a 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.
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).
Case 1: Compound pendulum with only linear damping Consider a linear damping torque in the pendulum equation, ḣ = T = T θ T b where where ω = θ. Now, T b = bω = linear damping torque J 0 θ + 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.
Modeling Simulation Block Diagrams Experimentation Summary Case 2: Compound pendulum with linear damping and nonlinear friction Now include a nonlinear friction torque, where ḣ = T = T θ T b T c T c = T o 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.
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 interest 1. Consider the simplest type of dynamic system, a first order ODE, dx dt = f(x, u, t) which we ll 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, t 0, x(t 0 ) = x 0. Then, the solution at the next step, t = t 0 + t, is to be approximated. 1 Some systems may involve both differential and algebraic equations (DAEs), which won t be considered in this course.
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 t 0. Given x 0, the value at initial time, an estimate of the value at t 1 is, ˆx 1 = x 0 + x 0 The job of the solver is to estimate x 0. The simplest algorithm is the Euler solver, which is basically a Taylor series approximation. The Euler solve estimates x 0 by, x 0 = f(x 0, u 0, t 0 ) 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, x 1.
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.
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, ẋ = 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.
Modeling Simulation Block Diagrams Experimentation Summary Example: Convert the simple pendulum model from 2nd order to 1st order form Recall the simple pendulum model ml 2 θ + mgl sin θ = 0 To convert this 2nd order ODE to 1st order, first define n = 2 state variables as x 1 = θ and x 2 = θ. We now want to write two 1st order ODEs in terms of these new state variables. The first one is found by taking the derivative of the first variable, ẋ 1 = θ, which is recognized as x 2. Therefore, the first equation is, ẋ 1 = x 2 Now, take derivative of second variable, ẋ 2 = θ. To find this equation, we must use the original 2nd order ODE, which has θ as well as θ. Solve for θ, θ = (g/l) sin θ = (g/l) sin x 1 This gives us the second state equation, ẋ 2 = (g/l) sin x 1 These two equations are the state space equations for the simple pendulum.
State space form Here are the simple pendulum state space equations in matrix form: [ ] [ ] ẋ1 x ẋ = = f(x, u, t) = 2 g l sin(x 1) ẋ 2 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.
Using solvers with script files 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.
Block diagram representations of systems 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.
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.
Block diagram algebra Summing point Let x(t) input and y(t) output. For general nonlinear systems, the output is simply, y = g(x). Branching point If the system is linear, y = G x G (gain) may be a constant or a system transfer function, G(s). The s represents the Laplace operator.
Block diagram calculus Other blocks especially useful for representing physical system models include the integrator: These are common blocks, but they are sometimes shown in software products using the s Laplace operator. For example, the integrator is: There is also a derivative and the derivative block is Important: these are just symbols - the blocks perform numerical integration/differentiation (not Laplace transforms).
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 causality in your DSC course.
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).
Example: block diagram for linear 1st order ODE Re-write the 1st order ODE in the form: dx dt = 1 [ x + u(t)] τ 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).
Two popular software products that use block diagrams are LabVIEW and Matlab/Simulink. 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 We have adopted LabVIEW for use in this course.
LabVIEW Control and Simulation Module
LabVIEW Control and Simulation Module Build your block diagrams within the C&S Loop: Basic block diagram VIs are found under Signal Arithmetic: and Continuous Linear Systems:
Modeling Simulation Block Diagrams Experimentation Summary The integrator block is a key element for integrating your state equations Remember that the input to the integrator block will be the derivative of your state: By double-clicking the integrator VI block, you can access settings: and the output is the state. The settings allow you to configure how you will set key integration parameters and whether you will set them in the dialog box or wire to a terminal.
Modeling Simulation Block Diagrams Experimentation Summary Example: LV simulation diagram for standard 1st order system
Example: LV simulation diagram for the simple pendulum 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.
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
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