Lecture Notes of ME 475: Introducton to Mechatroncs Note 0 Modelng and Smulaton of Dynamc Systems Department of Mechancal Engneerng, Unversty Of Saskatchewan, 57 Campus Drve, Saskatoon, SK S7N 5A9, Canada
Lecture Notes of ME 475: Introducton to Mechatroncs. Modelng of Dynamc System A model of a system can be physcal or mathematcal. The model accuracy needed (closeness to the actual system) depends on the purpose. Generally, a smplfed model s needed to study the man characterstcs of the system. A detaled model s needed for accurate smulaton and predcton studes. In ths class, modelng refers to the mathematcal model of a system. The mathematcal model of a dynamc system s generally n the form of dfferental equatons. Therefore, modelng of dynamc system refers to the use of the physcal laws to set up dfferental equatons for a gven dynamc system. Once we have the model of the system, we are nterested n studyng ts behavor. The behavor of a dynamc system n tme s descrbed by the soluton of ts dfferental equatons. There two dfferent purposes for modelng of a physcal system. Develop a mathematcal model n order to predct the dynamc behavor of the system as accurately as possble, usng numercal methods. Such a model serves as a tool for extensve evaluaton of system behavor wthout actually usng or buldng the actual system. Develop model to gan nsght nto the dynamc behavor qualtatvely nstead of exact response predcton,.e., knowledge of stablty margn, controllablty and observablty of states, and senstvty of response to parameter changes. Such models do not contan all the detal of an actual system, but only the most essental features so as to provde good nsght from an engneerng standpont. Therefore, we may develop smplfed lnear models for controller desgn and analyss purposes, and use more detaled, possbly nonlnear, models n testng and predctng the dynamc system response as accurately as possble. For nstance, consder the robotc manpulator schematcally shown n Fgure. The dynamc model s a set of dfferental equatons whch descrbe the relatonshp between the appled torques at the jonts and moton of the jont angles n tme. The set of nonlnear dfferental equatons can be used to predct the behavor of the robotc manpulator under varous ntal condtons and jont torque nputs. Fgure : Robotc manpulator model Qute often, the dynamcs models of physcal systems are nonlnear. Most control system desgn methods and analytcal methods are applcable only to lnear systems. Therefore, for the sake of beng able to analyze varous controller alternatves, we need to obtan approxmate lnearzed modes from the nonlnear models. Department of Mechancal Engneerng, Unversty Of Saskatchewan, 57 Campus Drve, Saskatoon, SK S7N 5A9, Canada
Lecture Notes of ME 475: Introducton to Mechatroncs. Dfferental Equatons. Bascs of Dfferental Equatons Contnuous tme dynamc systems are descrbed by dfferental equatons. A dfferental equaton s an equaton nvolvng dervatves of dependent varables wth respect to ndependent varables, for example, dy( + ay( u( dt where t s an ndependent varable, y s a dependent varable (e.g. the system outpu, and u s another dependent varable (e.g., the system npu. If there s only one ndependent varable, then the dfferental equaton s called an ordnary dfferental equaton (ODE). If there are two or more ndependent varables, then t s called a partal dfferental equaton (PDE). The hghest dervatve n the equaton s the order of the equaton. Soluton of an nthorder dfferental equaton contans n-arbtrary constants. These constants are determned by n-condtons on dependent varable (.e., the ntal condtons). Nonlneartes and Lnearzaton If the dependent varables or ther dervatves appear n nonlnear functons n the equatons, then the dfferental equaton s nonlnear; otherwse t s lnear. For example, the followng equaton s nonlnear dy ( dy( + dt dt + ay( u( A system s called a lnear dynamc system f ts dynamcs s descrbed by lnear dfferental equaton(s). A lnear system possesses two propertes: superposton and Homogenety. The property of superposton means the output response of a system to the sum of nputs s the sum of the responses to the ndvdual nputs. Thus, f an nput of r ( yelds an output of c ( and an nput of r ( yelds an output of c (, then an nput of r (+r ( wll yeld an output of c (+c (. The property of homogenety descrbes the response of the system to a multplcaton of the nput by a scalar. Specfcally, n a lnear system, the property of homogenety s demonstrated f for an nput of r( that yelds an output of c(, an nput of Kr( wll yeld an output of Kc(. In other words, the multplcaton of an nput by a scalar (.e., K) yelds a response that s multpled by the same scalar. Qute Often, a desgner needs to make a lnear approxmaton to a nonlnear system. Lnear approxmatons smplfy the analyss and desgn of a system and are used as long Department of Mechancal Engneerng, Unversty Of Saskatchewan, 57 Campus Drve, Saskatoon, SK S7N 5A9, Canada 3
Lecture Notes of ME 475: Introducton to Mechatroncs as the results yeld a good approxmaton to realty. For example, f a system conssts of nonlnear components, we must lnearze the system before we can fnd ts transfer functon. Now, let s see how to lnearze a nonlnear system n order to obtan ts transfer functon. The frst step s to wrte the nonlnear dfferental equaton and lnearze t. When we lnearze a nonlnear dfferental equaton, we lnearze t for small changes n the nput about the operatng pont A, as shown n Fgure, where the system nput and the output are x 0 and f(x 0 ), respectvely. Small changes n the nput can be related to changes n the output about the pont by way of the slope of the curve at the pont A. Thus, f the slope of the curve at pnt A s m a, then small excursons of the nput about pnt A, δx, yeld small changes n the output, δf(x), related the slope at pont A. Thus, where δ f ( x) f ( x) f ( x0 ) ma ( x x0 ) m a df ( x) dx x x 0 Fgure : Lnearzaton about the operatng pont A. Once we have the lnearzed dfferental equaton, next we take the Laplace transform of the equaton(s), assumng zero ntal condtons. Fnally, we separate nput and output varables and form the transfer functon. Example (a) Wrte the dfferental equaton for the smple pendulum shown n the followng fgure, where all the mass s concentrated at the endpont. (b) Lnearze the system about the operatng pont of θ 0 and then fnd ts transfer functon. (c) Use SIMULINK to determne the tme response of θ to a step nput T c of N m. Assume l m, m 0.5 kg, and g 9.8 m/s. Department of Mechancal Engneerng, Unversty Of Saskatchewan, 57 Campus Drve, Saskatoon, SK S7N 5A9, Canada 4
Lecture Notes of ME 475: Introducton to Mechatroncs Example Fnd the transfer functon, V L (s)/ V(s), for the electrcal network shown n the followng fgure, whch contans a nonlnear resstor whose voltage-current relatonshp s defned 0.vr by r e, where r and v r are the resstor current and voltage, respectvely. Also, t s know that v( s a small-sgnal source. Use SIMULINK to determne the tme response of v L ( to a step nput v( of 0. V. Department of Mechancal Engneerng, Unversty Of Saskatchewan, 57 Campus Drve, Saskatoon, SK S7N 5A9, Canada 5
Lecture Notes of ME 475: Introducton to Mechatroncs 3. Numercal Smulaton of Nonlnear Dynamc Systems The behavor of a dynamc system n the tme doman can be predcted by the soluton of ts mathematcal model, whch typcally s a set of ordnary dfferental equatons (ODEs). Analytcal soluton of ODEs s avalable for only lnear ODEs and very smple nonlnear ODEs. Therefore, tme doman response of any dynamc system model wth reasonable complexty must be solved usng numercal methods. The prmary tool s the numercal ntegraton of ODEs n the tme doman. Numercal ntegraton s performed by dscretzng ODEs usng varous approxmatons to dfferentaton. 3. Bascs for Solvng a Frst-Order ODE Gven that a dynamc system s descrbe by the followng frst-order ODE y & f ( y, u) The task at hand s to solve for y( gven the ntal condton y ( t0) y0 and the nput u(. The fundamental dea behnd numercal ntegraton s llustrated n Fgure 3, n whch where + y& dt t t + + y ( t ) y( t ) y& dt + t t can be obtaned by usng varous approxmatons, such as the Euler s and Runge-Kutta methods ntroduced n the followng. y& y& y& t 0 y& dτ Fgure 3: Graphcal nterpretaton of numercal ntegraton for solvng a frst-order ODE. Department of Mechancal Engneerng, Unversty Of Saskatchewan, 57 Campus Drve, Saskatoon, SK S7N 5A9, Canada 6
Lecture Notes of ME 475: Introducton to Mechatroncs 3. Euler s Method and Runge-Kutta Methods Euler s method s based on the defnton of a dervatve,.e., dy dt lm Δt 0 Δy Δt Let us examne the dfferental equaton for two values of tme, t and t +, where Δt s suffcently close to zero that the above equaton s approxmated by y y Δt + f ( y, u ) whch can be rewrtten as y y + Δtf ( y, u ) + Repeated evaluaton of the above equaton leads to the numercal soluton. As the ntal pont, y y0 and, for subsequent values of the ndex +, y + takes on the value from the prevous calculaton of y. Any arbtrary tme hstory of the nput u can be used: steps, ramps, snusods, random sequences, or stock market ndces. As the step sze Δt decreases, the accuracy of the method mproves and the requred computaton tme ncreases. Fgure 3 suggests that a more accurate formula s to use the average of the values of the dervatve at t and t +. Because ths s essentally a straght lne approxmaton to the y& curve between t and t +, t s called the trapezodal rule. Unfortunately, t s mpossble to mplement for numercal ntegraton of nonlnear system because the dervatve at t + depends on y(t + ), whch s not known yet. Many dfferent numercal ntegraton schemes have been developed to approxmate the area under the curve; and they are all teratve because the dervatve at the endpont s not ntally known. Runge-Kutta methods comprse one popular set of ntegraton schemes. The secondorder Runge-Kutta method obtans an approxmate value of the endpont usng the Euler method, estmates the dervatve at the endpont usng the approxmate y +, and then arrves at the fnal value for y + usng an average of the two dervatves: k k y f ( y, u ) + f ( y + k Δt, u Δt y + ( k + + k ) ) Department of Mechancal Engneerng, Unversty Of Saskatchewan, 57 Campus Drve, Saskatoon, SK S7N 5A9, Canada 7
Lecture Notes of ME 475: Introducton to Mechatroncs Thrd- and hgher-order Runge-Kutta methods use ths same basc dea; they dffer from the second-order formula by usng estmates of dervatves at md-ponts as well as endponts and ncludng them n a weghted average to arrve at the fnal estmate of y +. Most computer-aded control system desgn software ncludes some form of numercal ntegraton capablty such as Runge-Kutta method and most wll nclude some sort of automatc step sze determnaton. Any method wll be become more accurate as the step sze decrease: however, ntally, nether the computer algorthms nor the user knows what step sze s the best compromse between accuracy and speed. A commonly used scheme s to ntegrate usng two dfferent methods (perhaps a second- and thrd-order Rung-Kutta formula), compare the dfference, and then cut the step sze n half f the error exceeds a certan tolerance. The step sze wll contnue to be cut n half untl the error tolerance s met. 3.3 Smulaton of Nonlnear Dynamc Systems Usng SIMULINK In SIMULINK, we use a block, called Integrator, for contnuous-tme ntegraton of ts nput sgnal,.e., S out Δt 0 S n dt, where Δt s the step sze (specfed n the Solver optons n SIMULINK). The ntal condton of ntegraton can be specfed va the Functon Block Parameters wndow of the block. S n S out s Fgure 4: Integrator n SIMULINK. Suppose a dynamc system s descrbe by the followng n-order ODE y ( n) f ( y ( n ), y ( n ), L, y, u) wth ntal condtons: ( n ) ( n ) y ( t0) y0, ( n ) ( n ) y ( t0) y0,, ( t y0 y 0). The general process to solve the above ODE by means of SIMULINK s dscussed n class. Department of Mechancal Engneerng, Unversty Of Saskatchewan, 57 Campus Drve, Saskatoon, SK S7N 5A9, Canada 8
Lecture Notes of ME 475: Introducton to Mechatroncs Example 3 Use SIMULINK to determne the tme response of θ to a step nput of N m of the pendulum n Example based on the nonlnear dfferental equaton obtaned; and then compare t to the result from the transfer functon after lnearzaton. Example 4 Consder the lqud level n a tank and ts control system shown n the followng fgure. The purpose of control s to mantan the lqud heght n the tank at a constant level. Let us consder a computer-controlled verson of the system: the mechansm for manpulatng the nflow rate to the tank s controlled by a level sensor, a dgtal controller, and a valve. The dgtal controller s an ON/OFF type one wth hysteress: the controller ether fully turns ON or OFF the value, dependng the error sgnal to the controller; and the hysteress s added to the controller n order to make sure the controller does not swtch the valve ON/OFF at hgh frequency due to small change n the lqud level. Ths type of controller s called relay wth hysteress. The nflow rate s proportonal to the valve openng. Manpulated by the aforementoned ON/OFF controller, the flow rate has the value of ether zero or maxmum. The outflow rate s proportonal to the lqud level n the tank by multplyng a constant of /R. Smulate the system for the followng condtons: () the hysteress band of the controller s [-0.05, 0.05], () the maxmum nflow rate s 0.0 m 3 /s, (3) R has a value of 500 m/( m 3 /s), and (4) the cross-secton area of the tank s 0.0 m. Department of Mechancal Engneerng, Unversty Of Saskatchewan, 57 Campus Drve, Saskatoon, SK S7N 5A9, Canada 9