Prepared by: Gordana Janevska

0 downloads 0 Views 7MB Size Report
mechanical components and may include fluid, pneumatic, thermal, ... combination of existing systems, or the application of new technology or new k. l d t ...... R.C. Dorf, R.H. Bishop, Modern Control Systems, Addison-Wesley, 7th edition, 1995.
Prepared by: Gordana Janevska

WARNING: This material is for educational (teaching) purposes only and should be used according to the copyright and “fair use” rules. No further reproduction or distribution of this material is permitted. Any further reproduction or distribution of the material or some parts of the material may require prior approval from the copyright owner. If the use of this material excess the “fair use” rules, the user may be responsible for copyright violations.

Gordana Janevska

MODELING AND SIMULATION OF MECHATRONIC SYSTEMS Contents 1. INTRODUCTION TO MECHATRONICS DEFINING MECHATRONICS KEY ELEMENTS OF MECHATRONICS APPLICATIONS OF MECHATRONIC SYSTEMS THE PURPOSE OF MODELLING AND SIMULATION OF MECHATRONIC SYSTEMS

2. BASICS MODELS AND SIMULATION: THE VIRTUAL REALITY SYSTEMS AND MODELS TYPES OF MATHEMATICALMODELS

Input-output model versus state space model Static versus dynamic systems A (loose) classification of dynamic models Lumped versus Distributed parameters Linear versus nonlinear models Continuous versus discrete models Continuous-time versus discrete-time models Deterministic versus stochastic models Summary

MODEL VALIDATION MODEL AND SIMULATION 3. INTRODUCTION TO MATLAB, Simulink and LabVIEW INTRODUCTION TO MATLAB MATLAB Environment Vectors Functions Plotting Polynomials Matrices Script Files or M-Files Getting help in MATLAB INTRODUCTION TO SIMULINK Starting SIMULINK Basic Elements Simple Example INTRODUCTION TO LABVIEW

1

VI Front Panel Block diagram Icon and connector pane Three LabVIEW Palettes Status Toolbar Show context Help Help Options 4. THEORETICAL MODELING MODEL PARAMETERS AND SIGNALS PHASES OF MODELING Phase 1: Structuring the Problem Phase 2: Setting up the Basic Equations Phase 3: Forming the final model SOME BASIC RELATIONSHIPS IN PHYSICS Electrical Systems Mechanical Systems Translational Mechanical Systems Rotational Mechanical Systems

Fluid Systems Thermal Systems Analogies between physical sub-areas MODEL SIMPLIFICATION 5. BOND GRAPHS INTRODUCTION EFFORTS AND FLOWES JUNCTIONS SIMPLE BOND GRAPHS TRANSFORMERS AND GYRATORS SYSTEMS WITH MIXED PHYSICAL VARIABLES CAUSALITY: SIGNALS BETWEEN SUBSYSTEMS STATE EQUATIONS FROM BOND GRAPHS CONCLUSIONS 6. EXPERIMENTAL MODELING - IDENTIFICATION INTRODUCTION BASICS OF EXPERIMENTAL MODELING SIMPLE PRELIMINARY IDENTIFICATION

PARAMETER ESTIMATION IDENTIFICATION IN CLOSED LOOP IDENTIFICATION AS A TOOL FOR MODEL BUILDING 7. SIMULATION USING MODELS FOR SIMULATION NUMERICAL INTEGRATION ALGORITHMS

2

SCALING OF THE MODEL EQUATIONS BLOCK DIAGRAMS AND SUBSYSTEMS SIMULATION LANGUAGES

TRANSLATIONAL MECHANICAL SYSTEM WITH MASSES, SPRING AND FRICTION (Train system - EXAMPLE) Physical Modeling Mathematical Modeling MATLAB representation Building the Model in SIMULINK Running the Model Obtaining MATLAB Model Building the Model in LABVIEW Running the Model in LABVIEW

DC MOTOR – EXAMPLE MODELING DC MOTOR POSITION Physical Modeling Mathematical Modeling MATLAB representation and open-loop response Building the Model in SIMULINK LabVIEWrepresentation and open-loop response LABVIEW SIMULATION OF DC MOTOR

FLUID FLOW RESERVOIR MODELING – EXAMPLE FLUID FLOW RESERVOIR Physical Modeling Mathematical Modeling Step response

Modeling and Simulation of a Pneumatic Servosystem for Position Control

3

MODELING AND SIMULATION OF MECHATRONIC SYSTEMS 1. INTRODUCTION TO MECHATRONICS

TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

INTRODUCTION TO MECHATRONICS

DEFINING MECHATRONICS ™ The word mechatronics as a compositon of mecha from mechanics and tronics from electronics originated in Japan around 1970 to describe the integration of mechanical and electronic components in consumer products.

MECHANICS ELETRONICS ™ The meaning of this word continuously evolves after the original definition. Today it has come to mean multidisciplinary systems engineering. The definition that mechatronics is simply the combination of different technologies is no longer sufficient to explain mechatronics TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

4

INTRODUCTION TO MECHATRONICS

DEFINING MECHATRONICS ™ Integration is the key element in mechatronic design as complexity has been transferred from the mechanical domain to the electronic and computer software domains. ™ Mechatronics, as an engineering discipline, is the synergistic combination of mechanical engineering, electronics, control engineering, and computers, all integrated through the design process.

Aerial Venn diagram from Rensselaer Polytechnic Institute (Troy, New York) website describes the various ffields that make upp Mechatronics

™ Mechatronics is the integration of the different technologies to obtain the best solution to a given technological problem, which is the realization of a product. It is really nothing but good design practice. It means using modern, costeffective technology to improve product and process performance and flexibility. TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

INTRODUCTION TO MECHATRONICS

DEFINING MECHATRONICS ™ Mechatronics gained legitimacy in academic circles with the publication of the first refereed f d journal: j l IEEE/ASME /AS Transactions on Mechat ronics, where the following definition was given: Mechatronics is the synergistic combination of precision mechanical engineering, electronic control and systems thinking in the design of products and manufacturing processes processes.

Aerial Venn diagram from Rensselaer Polytechnic Institute (Troy, New York) website describes the various fields that make up Mechatronics

™ Mechatronics is an evolutionary design development that demands horizontal integration among the various engineering disciplines as well as vertical integration between design and manufacturing. It is the best practice for synthesis by engineers driven by the needs of industry and human beings. TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

5

INTRODUCTION TO MECHATRONICS

DEFINING MECHATRONICS ™ All of the known definitions and statements about mechatronics are accurate and informative, yet each one in and of itself fails to capture the totality of mechatronics. ™ Although, an all-encompassing definition of mechatronics does not exist, but in reality, engineers understand from the known definitions and from their own personal experiences the essence of the philosophy of mechatronics. ™ It should be understood that mechatronics is a way of life in modern engineering practice.

TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

INTRODUCTION TO MECHATRONICS

KEY ELEMENTS OF MECHATRONICS ™ The conception of mechatronics arises from the integration of knowledge from different areas of physics and technical disciplines. The purpose of mechatronics is to use this integration in order to achieve a synergic effect, i.e. to obtain a product with highest possible technical and economical parameters. In this light, the study of mechatronic systems can be divided into the following areas of specialty: ¾ ¾ ¾ ¾ ¾

Physical Systems Modeling; Sensors and Actuators; Signals and Systems; Computers and Logic Systems; Software and Data Acquisition RPI (Troy, New York) website

TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

6

KEY ELEMENTS OF MECHATRONICS

INTRODUCTION TO MECHATRONICS

Bishop, ed, The Mechatronics Handbook TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

INTRODUCTION TO MECHATRONICS

KEY ELEMENTS OF MECHATRONICS ™ The key elements of the mechatronics approach are presented in the figure:

Mechatronics is the result of applying information systems to physical systems. The physical system, the rightmost dotted block, consists of mechanical, electrical, and computer (electronic) systems as well as actuators, sensors, and real time interfacing. Sensors and actuators are used to transduce energy from high power, usually the mechanical side, to low power, the electrical and computer or electronic side. The block labeled mechanical systems frequently consists of more than just mechanical components and may include fluid, pneumatic, thermal, acoustic, chemical, and other disciplines as well. TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

RPI (Troy, New York) website

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

7

INTRODUCTION TO MECHATRONICS

APPLICATIONS OF MECHATRONIC SYSTEMS ™ Today, mechatronic systems are commonly found in homes, offices, schools, shops, and of course, in industrial applications. ¾ M Machine-tool hi t l construction t ti andd equipment i t for f automation t ti off technological processes ¾ Robotics (industrial and special) ¾ Aviation, space and military techniques ¾ Automotive (climate control, antilock brake, active suspension, cruise control, air bags, engine management, safety, etc.) ¾ Office equipment (for example, copy and fax machines) ¾ Computer facilities (for example, printers, plotters, disk drives) ¾ Home appliances (microwave ovens, ovens washing machines machines, vacuum cleaners, dishwashers, air conditioning units, security systems).

TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

INTRODUCTION TO MECHATRONICS

THE PURPOSE OF MODELLING AND SIMULATION OF MECHATRONIC SYSTEMS ™ There two different purposes for modeling of a physical system: ¾ To predict the dynamic behavior of the system as accurately as possible ¾ To gain insight into the dynamic behavior qualitatively instead of exact response prediction, i.e., knowledge of stability margin, controllability and observability of states, and sensitivity of response to parameter changes.

The mathematical models are need because: ™ Do not require a physical system ¾ Can treat new designs/technologies without prototype ¾ Do not disturb operation of existing system

™ Easier to work with than real world ¾ Easy to check many approaches, parameter, values, ... ¾ Flexible to time-scales ¾ Can access un-measurable quantities TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

™ Support safety ¾ Experiments may be dangerous ¾ Operators need to be trained for extreme situations

™ Help to gain insight and better understanding ™ Analogous Systems ¾ Can have the same mathematical model though different types of physical systems ¾ Common analysis methods and tools can be used. MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

8

INTRODUCTION TO MECHATRONICS

THE PURPOSE OF MODELLING AND SIMULATION OF MECHATRONIC SYSTEMS ™ Mechatronic systems' behavior is determined by interdependencies between different components. Therefore, an integrated and interdisciplinary engineering approach is necessary. Communication i i across the h traditional di i l boundaries b d i between b mechanical, h i l electrotechnical and computational engineering has to take place in an early design process stage. The importance of modeling and analysis in the design process has never been more important. ™ Designs are usually the result of the improvement of an existing system, the innovative combination of existing systems, or the application of new technology or new k knowledge l d to t an existing i ti system. t In I all ll this, thi understanding d t di what h t exists i t is i paramountt and modeling is essential to that understanding. ™ Once a concept has been developed in the conceptual phase of design it is evaluated through modeling , not by building and testing the physical system, sensors, actuators, and controls, all integrated into the design concept. TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

INTRODUCTION TO MECHATRONICS

THE PURPOSE OF MODELLING AND SIMULATION OF MECHATRONIC SYSTEMS ™ Mechatronics design is more than just the combination of mechanical, electronic and software design, so the mechatronic designer must optimize a design solution across these disparate fields. fields This requires a sufficient understanding of each of these fields to determine which portions of an engineering problem are best solved in each of these domains given the current state of technology. In turn, this requires the ability to model the problem and potential solutions using techniques that are domain independent or at least permit easy comparison of solutions and tools from different domains. ™ Through system modeling and simulation, the Mechatronic System Design Process facilitates: ¾ ¾ ¾ ¾ ¾

understanding d di the h bbehavior h i off the h proposed d system concept; optimizing the system design parameters; developing optimal control algorithms, both local and supervisory; testing control algorithms under various scenarios; and qualifying the production controller with a simulated version of the plant running in real time (hardware-in-the-loop testing), before connecting it to the real plant.

TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

9

INTRODUCTION TO MECHATRONICS

THE PURPOSE OF MODELLING AND SIMULATION OF MECHATRONIC SYSTEMS ™ More and more, simulation is being used to detect and eliminate integration issues. Simulation has been used on individual components and subsystems for quite some time, i bbut the h reall value l becomes b apparent with i h the h ability bili off virtual i l integration i i off those h individual systems. The tremendous cost savings of finding problems before you commit to hardware are well-known. What's more important, however, is being able to optimize system performance. That's something you can only achieve in simulation when you can combine those different domains with the controllers in a single simulation environment. ™ By running simulations early in the design process, engineers can try out new technologies and see if they will improve the design. ™ Experimental study on physical prototypes is expensive and time consuming. Virtual prototyping, as a new way of dynamic simulation of the controlled machine, is more compliant with time and budget constraints of R&D industrial centers. If design choices on the mechanical as well as on the electronic side can be tested before assembling the physical prototype, the time to market is shortened and the knowledge of the system is improved, obviously as long as the simulation plant is a reliable replication of reality and the simulation tool is reasonably easy to use for people coming from different areas. TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

10

MODELING AND SIMULATION OF MECHATRONIC SYSTEMS 2. BASICS

TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

BASICS MODELS AND SIMULATION: THE VIRTUAL REALITY ™ Many technical problems can not be resolved by observations or experiments: ¾ Process is not yyet exists,, or ¾ It can not be carried out without financial or technical risk.

™ In order to save time and money and not taking any unnecessary risks, it is desirable to get answers on the basis of a model instead of carried out experiments. ™ The model has the form of a mathematical description that allows performing a numerical simulation on the computer. ™ The modeling of mechatronic systems plays an important role in the development process of a mechatronic product. Generally, a model is required for: ¾ Simulation purposes, ¾ Analyzing the system, ¾ Designing a controller. TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

11

BASICS MODELS AND SIMULATION: THE VIRTUAL REALITY ™ Through system modeling and simulation, the engineers have a powerful tool which allows them to: ¾ Answer essential issues and also examine the border areas without risk ¾ Test in advance the characteristics and modify if necessary, when the system is a concept in the design process.

™ Besides their advantages, the modeling and simulation also have some pitfalls: ¾ Too simple model can not describe all aspects of the real system (process) p model requires q too much time and effort in the creation and ¾ Too complex simulation ¾ A model can also be not valid ¾ Selection of appropriate integration algorithm is very important and only in this way a correct simulation is ensured. TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

BASICS MODELS AND SIMULATION: THE VIRTUAL REALITY ™ Reality is initially an entity, situation or system to be investigated by simulation. Its modelling can be viewed as a two-stage process: ¾ Establishing a conceptual model through analyzed and modeled the reality by using verbal descriptions, equations, relationships or laws of nature; ¾ Transforming the conceptual model into an executable model (model that can be used for simulation)) as ppart of implementation. p

Model generation, simulation, validation and verification in context (Georg Pelz, Mechatronic Systems) y )

™ Model verification investigates whether the executable model reflects the conceptual model within the field of application. ™ Model validation should tell us whether the executable model is suitable for fulfilling the envisaged task within its field of application. TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

12

BASICS MODELS AND SIMULATION: THE VIRTUAL REALITY ™ There are actually two distinct models of an actual dynamic physical system and the distinction between them is most important ¾ Ph Physical i l model d l – an imaginary i i physical h i l system t – a slice li off reality, lit which hi h is i an approximation i ti of the actual system capturing the essential elements in as much detail as the need for the model requires. In modeling dynamic physical systems we use engineering judgment and simplifying assumptions to develop a physical model. ¾ Mathematical model – The laws of nature (physics, chemistry, biology) are applied to the physical model (not the physical system) and the mathematical equations describing the system are derived.

Hierarchy of Models, depending on the particular need for the model   p , , y more‐complex, more‐realistic, less‐easily‐solved Truth Model

Design Model

less ‐complex, less‐realistic, more‐easily‐solved TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

BASICS MODELS AND SIMULATION: THE VIRTUAL REALITY ™ There are two basic approaches to build mathematical modes: ¾ Th Theoretical ti l modeling d li - carried i d outt from f th the physical-technical h i l t h i l basic b i equations ¾ Experimental modeling - carried out from measured input and output data (Need prototype or real system!)

™ Simulation: Calculation of the behavior of a system model in dependence on time, and the state of a system and environment. The simulation provides projections about the behavior of the real system with the aid of a model, which can be executed in a computer. Simulation is thus an inexpensive and safe way to experiment with the system. However, the value of the simulation results depends completely on the quality of the model of the system. TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

13

BASIC CONCEPTS

SYSTEMS AND MODELS System: set of elements, which are interconnected in different interactions. A system is a combination of components which are coordinated together f ifi objective. bj i to perform a specific Disturbance Inputs Subsystem

System Outputs

System Control C l Inputs I Subsystem: a component of a larger system A system is a defined part of the real world. Essential for defining a system is the system boundary to the environment. Interactions with the environment are described by system inputs and system outputs. TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

BASIC CONCEPTS

SYSTEMS AND MODELS ™ For the modeling it is necessary to abstract the given real problem, i.e. to y which can then be used as a model for the original g define a suitable system, problem. It can be noted here that the experience is playing a great role in model development

™ Model: A description of the system. The model should capture the essential information about the system. ™ The model, which defines a system, must also give a mathematical description of the internal and external interactions. Although some software already provides graphical elements, the mathematical formula is the basis for numerical implementation and interchangeability of information (regardless of computer platforms!). This step can be done easier with experience, but a systematic approach is recommended from the very beginning. TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

14

BASIC CONCEPTS

TYPES OF MATHEMATICAL MODELS Input--output model versus state space model Input Inputs, u: External influences on the system y ((force, current, …)) Outputs, y: Variables of interest to be calculated or measured (position, velocity, …)

Input‐output  system model  Input-output models, regardless of the complexity of the context, described the output variables y directly by the inputs u. A system is considered as a device that transformed inputs to outputs. The state space p model includes additional internal variables – state variables,, x State variables, x: Represent the status or memory of the system. The state is a collection of variables that summarize the past of a system for the purpose of prediction the future. Initial states x(t0) and inputs u(t) completely determine future outputs y(t) and states x(t), t≥t0 . TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

BASIC CONCEPTS

TYPES OF MATHEMATICAL MODELS Static versus dynamic systems ™ In a static system, the outputs are defined by algebraic combinations of the inputs. Dependencies of variables upon one another are fixed (independent of time). Example:

V=i R and even V(t) =i(t)R that is, the fact that current must be multiplied by resistance to give voltage (the dependency) is independent of time.

™ In dynamic systems, the output variables due to memory effects show complex dependencies. The present output of the system depends on past inputs. Dependencies of variables upon one another change with time. A slightly narrower definition: A dynamic system is a system that is described by differential and/or difference equations. Example: A capacitor connected to a resistor with an external voltage V The voltage over the capacitor depends on the charge and thereby on earlier values of the current and voltage V TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

15

BASIC CONCEPTS

TYPES OF MATHEMATICAL MODELS A (loose) classification of dynamic models

TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

BASIC CONCEPTS

TYPES OF MATHEMATICAL MODELS Lumped versus Distributed parameters Both properties are related to systems of dynamic nature. ™ In a lumped-parameter model, system dependent variables are assumed uniform over finite regions of space. Time is the only independent variable and the mathematical model is an ordinary differential equation. The events are described by a finite number of changing variable ™ In a distributed-parameter model, time and spatial variables are independent variables and the mathematical model is a partial differential equation. The events in the system are so to speak dispersed over the space variables.

TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

16

BASIC CONCEPTS

TYPES OF MATHEMATICAL MODELS Linear versus nonlinear models ™ Th The mathematical th ti l description d i ti off a linear li model d l consists i t off a li linear combination bi ti of inputs and outputs. Linear models, both analytically and numerically, are much more efficient to deal with, especially stability analysis can be performed easily and closed. Unfortunately, linearity is only one ideal shape, real systems are almost always non-linear. ™ All other models are called nonlinear. Nearly all physical elements or systems are inherently nonlinear if there are no restrictions at all placed on the allo able values allowable al es of the inp inputs, ts ee.g., g sat saturation, ration dead-zone, dead one sq square-law are la nonlinearities

TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

BASIC CONCEPTS

TYPES OF MATHEMATICAL MODELS Linear versus nonlinear models A linear system satisfies the properties of superposition and homogeneity ™ The superposition property states that for a system initially at rest with zero energy the response to several inputs applied simultaneously is the sum of the individual responses to each input applied separately When the system at rest is subjected to an excitation x1(t), it provides a response y1(t). Furthermore, when the system is subjected to an excitation x2(t), it provides a corresponding response y2(t). For a linear system, it is necessary that the excitation x1(t) + x2(t) result in a response y1(t) + y2(t). This is usually called the principle of superposition. ™ The property of homogeneity: the magnitude scale factor must be preserved, i.e. multiplying lti l i the th inputs i t by b any constant t t multiplies lti li the th outputs t t by b the th same constant. t t For a system with an input x(t) that results in an output y(t), the response of a linear system to a constant multiple β of an input x must be equal to the response to the input multiplied by the same constant so that the output is equal to β y Non-linear systems do not satisfy both these criteria TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

17

BASIC CONCEPTS

TYPES OF MATHEMATICAL MODELS Linear versus nonlinear models ™ Often, the theoretical modeling goes through a nonlinear model, which is then linearized around an operating point. If the values of the inputs are confined to a sufficiently small range, th original the i i l nonlinear li model d l off the th system t may often ft bbe replaced l d bby a li linear model d l whose h response closely approximates that of the nonlinear model. A linear approximation is as accurate as the assumption of small signals is applicable to the specific problem.

Example: The normal operating point of the system consists of mass M sitting on a nonlinear spring is the equilibrium position that occurs when the spring force balances the gravitational force M g (g is the gravitational constant). Thus, f0 = M g. For the nonlinear spring with f = y 2, the equilibrium position i i iis y0 = (M ( g))1/2. The h li linear model d l ffor small ll deviation is ∆f = m ∆ y, where Thus, m = 2 y0.

TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

BASIC CONCEPTS

TYPES OF MATHEMATICAL MODELS Continuous versus discrete models ™ The distinction continuous – discrete dates back to the controversy between analog ((=continuous)) and digital g ((=discrete)) simulation. However, use of these attributes without further precision may causes confusion, so it should be avoid. Both, dynamic systems and models have dependent and independent variables and one, several or all may change continuously or in discrete way. ™ The contrast continuous-time and discrete-time is not a precise. Systems may change at discrete instants of time in a deterministic manner or, such changes may occur stochastically. Therefore, it is better to make distinction between three properties: continuous-time and discrete-time − discrete-event − hybrid: There are systems which change continuously with time. time Other systems change only at certain instants of time or during rather short intervals. Moreover, there are systems subjected to a sequence of countable events where it can be assumed that nothing of interest take place between them (discrete-event system or model, respectively). Furthermore, there are systems where both continuous time and discrete-events are present (hybrid systems). TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

18

BASIC CONCEPTS

TYPES OF MATHEMATICAL MODELS Continuous--time versus discreteContinuous discrete-time models ™ A mathematical model that describes the relationship between time continuous signals is called time continuous. Differential equations q are often used to describe such a relationship. ™ A model that directly expresses the relationships between the values of the signals at the sampling instants is called a discrete time or sampled model. Such a model is typically described by difference equation. For processing by digital computers, all signals are, both, quantized value and discretized in time (sampling time Ts). I practice, In ti the th signals i l off interest i t t are most often obtained in sampled form, which is a result of discrete time measurements. Sampling a continuous signal: a) continuous-time signal, b) time-discretized (sampled) signal. TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

BASIC CONCEPTS

TYPES OF MATHEMATICAL MODELS Continuous--time versus discreteContinuous discrete-time models Example A continuous-time model of a damped linear oscillator is given by the differential equation The discretization of this model with a sampling time Ts =0.25 s results in a difference equation of the form where k is an abbreviated form for all time points t = k Ts . The numerical coefficients of the discrete model depend not only on the continuous model, but the choice of sampling time Ts also plays an important role! In Figure, the step responses of both models are shown. Note that the discrete-time model output is a constant on a sampling interval, which means a loss of information compared to the continuous model. Step response of a damped oscillator. Left: continuous-time model. Right: time-discrete model with a sampling time Ts =0.25 s

TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

19

BASIC CONCEPTS

TYPES OF MATHEMATICAL MODELS Deterministic versus stochastic models ™ Deterministic system - all system inputs are explicitly known during the time and the system parameters are either constant or their variations are also known known. A model is called deterministic if it works with an exact relationship between measurable and derived variables and expresses itself without uncertainty. Deterministic systems show in principle predictable behavior, if modeled exactly; the future behavior can be computed from its present state and the known influence on it. ™ Stochastic system – the system inputs or parameters are known only from statistical measurements or can be specified only probabilistically. A model is stochastic if it works with uncertainty or probability concepts. A stochastic, mathematical model contains quantities that are described using stochastic variables or stochastic processes. The stochastic models are especially important because in every measurement noise occurs. To get models or to estimate optimal experimental conditions from these noisy measurements, the stochastic system theory must be considered. The important area of system identification is therefore also dependent on stochastic models. TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

BASIC CONCEPTS

TYPES OF MATHEMATICAL MODELS Summary ™ The most realistic physical model of a dynamic system leads to differential equations of motion that are: ¾ nonlinear, partial differential equations with time-varying and space-varying parameters ¾ These equations are the most difficult to solve. ™ The simplifying assumptions lead to a physical model of a dynamic system that is less realistic and to equations of motion that are: ¾ linear, ordinary differential equations with constant coefficients ¾ These Th equations ti are easier i to t solve l andd design d i with ith This dilemma between easy-to-handle and realistic has been formulated very nicely by Pindyck already in 1972: ‘Our preoccupation with linear time-invariant systems is not a reflection of a belief in a linear time-invariant real world, but instead a reflection of the present state of the art of describing the real world’. TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

20

BASIC CONCEPTS

TYPES OF MATHEMATICAL MODELS

TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

BASIC CONCEPTS

MODEL VALIDATION Model validation procedure

After the model creation, it must be examine whether the model fulfills its purpose well, i.e. whether the model reflects the reality sufficiently well. A model is not useful until its validity has been tested and established. Models have been developed to help in solving certain problems. We call a model that is useful in this way valid with regard to the purpose in mind. Deciding if a certain model is valid is called model validation. The model validation is not a one step, but an iterative process that is closely associated with the actual modeling task.

Test of the validity TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

21

BASIC CONCEPTS

MODEL AND SIMULATION Simulation models are a special subset of mathematical or physical models that allow the user to ask "what if" questions about the system. Changes are made in the physical conditions diti or their th i mathematical th ti l representation t ti andd the th model d l is i run many times ti to t "simulate" the impacts of the changes in the conditions. The model results are then compared to gain insight into the behavior of the system. The form in which a model must be brought for a simulation crucially depends on the simulation software that is used. In graphical interfaces, a block diagram representation is sufficient (e.g. Simulink), other programs require a specific mathematical description of programming (Matlab, ACSL). Nevertheless, the essential core of a simulation is the mathematical description which is completely platform independent. The simulation provides a numerical experiment on a suitably prepared model. Each experiment must provide the same result under the same conditions regardless of experimenter, time and place of performing. But all experiment defining parameters must be known. Therefore, it is particularly important the simulation parameters such as initial conditions, integration algorithm, step size, tolerances, etc. to be saved and reproducible. TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

22

MODELING AND SIMULATION OF MECHATRONIC SYSTEMS 3. INTRODUCTION TO MATLAB, Simulink and LabVIEW

TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

INTRODUCTION TO MATLAB, SIMULINK AND LABVIEW

INTRODUCTION TO MATLAB MATLAB Environment ™ MATLAB, coined from MATrix LABoratory, is a mathematical computing software developed by MathWorks. MathWorks MATLAB is supported on Unix, Unix Macintosh, Macintosh and Windows environments; a student version of MATLAB is available for personal computers. For more information on MATLAB, contact the MathWorks ™ Simply speaking, MATLAB can be thought as a calculator which is powerful in matrix operations. To a further extent, it is a powerful programming language equipped with various built-in functions and (optional) tool boxes and can be used to build a customized program. ™ MATLAB is an interactive system y and pprogramming g g language g g for ggeneral scientific and engineering computation. Its basic element is a matrix (array). It excels at numerical calculations and graphics. ™ MATLAB has tools (functions) to solve common problems plus toolboxes (collections of specialized programs) for specific types of problems. TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

23

INTRODUCTION TO MATLAB, SIMULINK AND LABVIEW

INTRODUCTION TO MATLAB MATLAB Environment Command window Click on the MATLAB icon/start menu initialises the Matlab environment:

Variable browser

The main window is the dynamic command interpreter which allows the user to issue Matlab commands The variable browser shows which variables currently exist in the workspace Command history TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

INTRODUCTION TO MATLAB, SIMULINK AND LABVIEW

INTRODUCTION TO MATLAB Vectors ™ Let's start off by creating something simple, like a vector ™ Enter each element of the vector (separated by a space) between brackets brackets, and set it equal to a variable. • For example, to create the vector a, enter  into the MATLAB command window a = [1 2 3 4 5 6 9 8 7]

MATLAB should return: a=

123456987

• Let's say you want to create a vector  with elements between 0 and 20 evenly  ih l b 0 d 20 l spaced in increments of 2 (this method is  frequently used to create a time vector): t = 0:2:20

t=

0 2 4 6 8 10 12 14 16 18 20 TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

24

INTRODUCTION TO MATLAB, SIMULINK AND LABVIEW

INTRODUCTION TO MATLAB Vectors ™ Basic operations on vectors: Manipulating vectors is almost as easy as creating them. • For example, suppose you would like to add a constant (e.g. 3) to each of the elements in  vector 'a'. The equation for that looks like: b=a+3

MATLAB should return: b=

4 5 6 7 8 9 12 11 10

• Now suppose, you would like to add two  vectors together. If the two vectors are  the same length, it is easy. Simply add the the same length, it is easy. Simply add the  two as shown below: c=a+b

c=

5 7 9 11 13 15 21 19 17

• Subtraction of vectors of the same length works exactly the same way TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

INTRODUCTION TO MATLAB, SIMULINK AND LABVIEW

INTRODUCTION TO MATLAB Functions ™ To make life easier, MATLAB includes many standard functions. Each function is a block of code that accomplishes a specific task ™ Matlab contains all of the standard functions such as sin, cos, log, exp, sqrt, as well as many others. ™ Commonly used constants such as pi, and i or j for the square root of -1, are also incorporated into Matlab.

sin(pi/4) ans = 0.7071 ™ To determine the usage of any function, type help [function name] at the Matlab command window. TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

25

INTRODUCTION TO MATLAB, SIMULINK AND LABVIEW

INTRODUCTION TO MATLAB Plotting ™ Suppose you wanted to plot a sine wave as a function of time. ¾ First make a time vector t=0:0.25:7; ¾ compute the sin value at each time y = sin(t); plot(t,y) ™ The plot command has extensive add-on capabilities Recommendation: visit the plotting page to learn more about it ™ Two Useful Symbols: ¾ Semicolon ; (If a semicolon is typed at the end of a command, the output of the command is not displayed). ¾ Percent Sign % (When the % is typed in the beginning of a line, the line is designated as a comment. Comments are frequently used in programs to add explanations or descriptions). TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

INTRODUCTION TO MATLAB, SIMULINK AND LABVIEW

INTRODUCTION TO MATLAB Polynomials ™ In MATLAB, a polynomial is represented by a vector. To create a polynomial in p y enter each coefficient of the ppolynomial y into the vector in MATLAB, simply descending order. x = [1 3 -15 -2 9]

x=

1 3 -15 -2 9

™ If the polynomial is missing any coefficients, you must enter zeros in the appropriate place in the vector. y = [1 0 0 0 1]

™ polyval function - gives the polynomial value at certain value of independent variable. For example, the value of the above polynomial at s=2 z = polyval([1 0 0 0 1],2) z = 17 TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

26

INTRODUCTION TO MATLAB, SIMULINK AND LABVIEW

INTRODUCTION TO MATLAB Polynomials ™ The pproduct of two ppolynomials y is found byy taking the convolution of their coefficients. MATLAB's function conv is doing this.

x y z z

™ The deconv function is using to divide two polynomials. It will return the remainder as well as the result result.

TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

= [1 2]; = [1 4 8]; = conv(x,y) = 1 6 16

16

Let's divide z by y and see if we get x. [xx, R] = deconv(z,y) xx = 1 2 R = 0 0 0 0

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

INTRODUCTION TO MATLAB, SIMULINK AND LABVIEW

INTRODUCTION TO MATLAB Matrices ™ Entering matrices into MATLAB is the same as entering a vector, p each row of elements is separated p byy a semicolon (;) or a return except B = [1 2 3 4;5 6 7 8;9 10 11 12] B = 1 5 9

2 6 10

3 7 11

4 8 12

B = [ 1 2 3 4 5 6 7 8 9 10 11 12] B = 1 5 9 TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

2 6 10

3 7 11

4 8 12

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

27

INTRODUCTION TO MATLAB, SIMULINK AND LABVIEW

INTRODUCTION TO MATLAB C = B'

Matrices

C = 1 2 3 4

™ Transpose The transpose of a matrix can be found using the apostrophe key

9 10 11 12

E = [1 2;3 4]

™ Matrix Inverse In MatLab, we execute inv(E) to find the inverse of the matrix E

X = inv(E) X = -2.0000 1 5000 1.5000

1.0000 -0.5000 -0 5000

E = [1 2;3 4]

™ Determinant In MatLab, we execute det(E) to find the determinant of the matrix E TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

5 6 7 8

det(E) ans = -2

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

INTRODUCTION TO MATLAB, SIMULINK AND LABVIEW

INTRODUCTION TO MATLAB B = Matrices C =

[1 2 3 4;5 6 7 8;9 10 11 12] B’

D = B * C

™ Matrix Multiplication Remember that order matters when multiplying matrices

D = 30 70 110

Another option for matrix manipulation is that you can multiply the corresponding elements of two matrices using the .* operator (the matrices must be the same E = [1 2;3 4]; size i to t do d this). thi )

70 174 278

110 278 446

F = C * B F = 107 122 137 152

122 140 158 176

137 158 179 200

152 176 200 224

G = [2 3;4 5]; M = E.* F M = 2 12 TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

6 20 MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

28

INTRODUCTION TO MATLAB, SIMULINK AND LABVIEW

INTRODUCTION TO MATLAB Matrices ™ Matrix Powers If E is a matrix matrix, the operation E. E ^2 2 squares each element in E. To square the matrix, i.e., compute E*E, E must be a square matrix and we use the operation E^2. If you have a square matrix, like E, you can also multiply it by itself as many times as you like by raising it to a given power.

E = [1 2;3 4]; E.^3 % element-by-element cubing ans = 1 8 27 64 E^3 % multiply matrix by itself ans = 37 54 81 118 eig(E) ans = -0.3723 5.3723

™ You can also find the eigenvalues of a matrix.

p = poly(E)

™ The "poly" function creates a vector that p = includes the coefficients of the characteristic 1.0000 -5.0000 -2.0000 polynomial. Remember that the eigenvalues roots(p) of a matrix are the same as the roots of its ans = 5.3723 characteristic polynomial. -0.3723 TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

INTRODUCTION TO MATLAB, SIMULINK AND LABVIEW

INTRODUCTION TO MATLAB Script Files or M M--Files ™ Rather than entering commands in the non-interactive command window, where the commands cannot be saved and executed again, it is better to first create a file with a list of commands (a program), save it, and then run (execute) the file. ™ Commands in the file can be corrected or changed and the file can be saved and run again. The commands in the file are executed in the order listed. ™ Files used for this purpose are called script files or m-files (extension .m is used when the file is saved). ™ To create a M-File: File →New →M-File. ™ The file must be saved before it can be executed. To execute it, chose the Run icon, or type the file name in the Command Window and press Enter.

TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

29

INTRODUCTION TO MATLAB, SIMULINK AND LABVIEW

INTRODUCTION TO MATLAB Getting help in MATLAB ™ MATLAB has a fairly good on on-line line help; type: help commandname for more information on any given command. You do need to know the name of the command that you are looking for. ™ MatLab includes extensive help tools, which are especially useful for interpreting function syntax. y to get g help p from within MatLab: ™ There are 3 ways ¾ Command-line help function – help ¾ Windowed help screen – Help →MatLab Help ¾ MatLab’s Internet help

TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

INTRODUCTION TO MATLAB, SIMULINK AND LABVIEW

INTRODUCTION TO SIMULINK ™ Simulink is a graphical extension to MATLAB for modeling and simulation y Simulink is supported pp on Unix, Macintosh, and Windows of systems. environments; and is included in the student version of MATLAB for personal computers. For more information on Simulink, contact the MathWorks. ™ Simulink is an extension to MatLab that allows engineers to rapidly and accurately build computer models of dynamic physical systems using block diagram notation. ™ In Simulink, systems are drawn on screen as block diagrams. Many elements off bl blockk diagrams di are available, il bl suchh as transfer t f functions, f ti summing i junctions, etc., as well as virtual input and output devices such as function generators and oscilloscopes. ™ Simulink is integrated with MATLAB and data can be easily transferred between the programs. TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

30

INTRODUCTION TO MATLAB, SIMULINK AND LABVIEW

INTRODUCTION TO SIMULINK Starting SIMULINK ™ Simulink is started from the MATLAB command prompt by entering the command: simulink ™ Alternatively, you can hit the New Simulink Model button at the top of the MATLAB command window.

TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

INTRODUCTION TO MATLAB, SIMULINK AND LABVIEW

INTRODUCTION TO SIMULINK Starting SIMULINK ™ When it starts, SIMULINK brings up two windows. ¾ The first is the main Simulink window ¾ The second window is a blank, untitled, model window. This is the window into which a new model can be drawn

TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

31

INTRODUCTION TO MATLAB, SIMULINK AND LABVIEW

INTRODUCTION TO SIMULINK Basic Elements ™ There are two major classes of items in Simulink: y, combine,, output, p , and display p y signals; g ; and ¾ Blocks are used to ggenerate,, modify, ¾ Lines are used to transfer signals from one block to another. ™ Blocks - There are several general classes of blocks: ¾ Sources: Used to generate various signals ¾ Sinks: Used to output or display signals ¾ Discrete: Linear, discrete-time system elements (transfer functions, state-space models, etc.) ¾ Linear: Linear, continuous-time system elements and connections (summing junctions, gains, etc.) ¾ Nonlinear: Nonlinear operators (arbitrary functions, saturation, delay, etc.) ¾ Connections: Multiplex, Demultiplex, System Macros, etc. ™ Lines - transmit signals in the direction indicated by the arrow. Lines must always transmit signals from the output terminal of one block to the input terminal of another block. TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

INTRODUCTION TO MATLAB, SIMULINK AND LABVIEW

INTRODUCTION TO SIMULINK Basic Elements

TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

32

INTRODUCTION TO MATLAB, SIMULINK AND LABVIEW

INTRODUCTION TO SIMULINK Simple Example The simple model consists of three blocks: Step, Transfer Fcn, and Scope. The Step is a source block from which a step input signal originates. originates This signal is transferred through the line in the direction indicated by the arrow to the Transfer Function linear block. The Transfer Function modifies its input signal and outputs a new signal on a line to the Scope. The Scope is a sink block used to display a signal much like an oscilloscope.

TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

INTRODUCTION TO MATLAB, SIMULINK AND LABVIEW

INTRODUCTION TO SIMULINK Simple Example ™ Modifying Blocks A block can be modified by double-clicking on it. F example, For l if you double-click d bl li k on the th "Transfer "T f Fcn" block in the simple model, you will see the following dialog box.

This dialog box contains fields for the numerator and the denominator of the block's transfer function. By entering a vector containing the coefficients of the desired numerator or denominator polynomial, the desired transfer function can be entered. For example, to change the denominator to s^2+2s+1, enter the following into the denominator field: [1 2 1]. TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

33

INTRODUCTION TO MATLAB, SIMULINK AND LABVIEW

INTRODUCTION TO SIMULINK Simple Example ™ Modifying Blocks The "step" block can also be double-clicked, bringing up the following dialog box. The default parameters in this dialog box generate a step function occurring at time=1 sec, from an initial level of zero to a level of 1. (in other words, a unit step at t=1). Each of these parameters can be changed.

The most complicated of these three blocks is the "Scope" Scope block. block Double clicking on this brings up a blank oscilloscope screen. When a simulation is performed, the signal which feeds into the scope will be displayed in this window.

TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

INTRODUCTION TO MATLAB, SIMULINK AND LABVIEW

INTRODUCTION TO SIMULINK Simple Example ™ Running Simulations Before running a simulation of this system, first open the scope window by double-clicking on the scope block. Then, to start the simulation, either select Start from the Simulation menu or click the “Start simulation” button in the model window. The simulation should run very quickly and the scope window will appear as shown.

Start Simulation

Note that the simulation output (shown in yellow) is at a very low level relative to the axes of the scope. To fix this, hit the autoscale button (binoculars), which will rescale the axes. TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

34

INTRODUCTION TO MATLAB, SIMULINK AND LABVIEW

INTRODUCTION TO SIMULINK Simple Example ™ Configuration Parameters Now, we will change the parameters of the system and simulate the system again. Double-click on the "Transfer Fcn" block in the model window and change the denominator to [1 20 400] Re-run the simulation and you should see what appears as a flat line in the scope window. Hit the autoscale button, and you should see the following in the scope window. Notice that the autoscale button only changes the vertical axis. Since the new transfer function has a very fast response, it is compressed into a very narrow part of the scope window. This is not really a problem with the scope, but with the simulation itself. Simulink simulated the system for a full ten seconds even though the system had reached steady state shortly after one second.

To correct this, you need to change the parameters of the simulation itself. In the model window, select Configuration Parameters from the Simulation menu. TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

INTRODUCTION TO MATLAB, SIMULINK AND LABVIEW

INTRODUCTION TO SIMULINK Simple Example ™ Configuration Parameters There are many simulation parameter options; we will only be concerned with the start and stop times, which tell Simulink over what time period to perform the simulation. Change Start time from 0.0 to 0.8 (since the step doesn't occur until t=1.0. Change Stop time from 10.0 to 2.0, which should be only shortly after the system settles. After rerunning the simulation and hitting the autoscale button, the scope window should provide a much better display of the step response.

TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

35

INTRODUCTION TO MATLAB, SIMULINK AND LABVIEW

INTRODUCTION TO LABVIEW ™ LabVIEW (Laboratory Virtual Instrument Engineering Workbench) relies on graphical symbols rather than textual language to describe programming actions. ™ LabVIEW is a software, which uses graphical programming language for data acquisition, data analysis, presentation of result and instrument control. The principle of dataflow, in which functions execute only after receiving the necessary data, governs execution in a straightforward manner. ™ LabVIEW programs are called: Virtual Instruments (VIs) because their appearance and operation imitate actual instruments, such as oscilloscopes and multimeters. However, they are analogous to main programs, functions and subroutines from popular language like C, Fortran, Pascal, . . . ™ Each VI contains three main parts: ¾ Front Panel – an interactive user interface of a VI, so named because it can simulates the front panel of a physical instrument. ¾ Block Diagram – VI’s source code, constructed in LabVIEW’s graphical programming language, G. It is the actual executable program ¾ Icon/Connector – means of connecting a VI to other VIs. TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

INTRODUCTION TO MATLAB, SIMULINK AND LABVIEW

INTRODUCTION TO LABVIEW ™ VI Front Panel ¾ The front panel is the user interface of the VI A front panel contains controls for input and indicators for output or data presentation. The Front Panel is used to interact with the user when the program is running. Users can control the program, change inputs, and see data updated in real time. ¾ Controls are knobs, pushbuttons, dials, and other input devices Controls simulate instrument input devices and supply data to the block diagram of the VI. Stress that controls are used for inputs- adjusting a slide control to set an alarm value, turning a switch on or off, or stopping a program. ¾ Indicators are graphs, LEDs, and other displays Indicators simulate instrument output devices and display data the block diagram acquires or generates. Indicators are used as outputs. Thermometers, lights, and other indicators indicate values from the program. These may include data, program states, and other information. TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

36

INTRODUCTION TO MATLAB, SIMULINK AND LABVIEW

INTRODUCTION TO LABVIEW VI Front Panel •



When you run a VI, you must have the front panel open so that you can input data to the executing program. The front panel is where you see your program’s output. Front Panel • Controls = Inputs • Indicators = Outputs

Front Panel Toolbar

Icon

Boolean Control

Graph Legend

Waveform Graph Scale Legend

Plot Legend g

In this picture, the Power switch is a boolean control. A boolean contains either a true or false value. The value is false until the switch is pressed. When the switch is pressed, the value becomes true. The temperature history indicator is a waveform graph. It displays multiple numbers. In this case, the graph will plot Deg F versus Time (sec). The front panel also contains a toolbar. TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

INTRODUCTION TO MATLAB, SIMULINK AND LABVIEW

INTRODUCTION TO LABVIEW ™ Block diagram ¾ Every front panel control or indicator has a corresponding terminal on the block diagram When a VI is run diagram. run, values from controls flow through the block diagram, diagram where they are used in the functions on the diagram, and the results are passed into other functions or indicators. ¾ The block diagram contains this graphical source code. Front panel objects appear as terminals on the block diagram. Additionally, the block diagram contains functions and structures from built-in LabVIEW VI libraries. Wires connect each of the nodes on the block diagram, including control and indicator terminals, functions, and structures ¾ Block Diagram • Accompanying “program” for front panel • Components “wired” together.

TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

37

INTRODUCTION TO MATLAB, SIMULINK AND LABVIEW

INTRODUCTION TO LABVIEW ™ Block diagram The block diagram window h ld the holds h graphical hi l source code of a LabVIEW VI – it is the actual executable code • You construct the block diagram by wiring together objects that perform specific functions. • The various components of a block diagram are terminals, nodes and wires.

TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

Block Diagram Toolbar

Divide de Function

SubVI Graph Terminal Wire Data Numeric Constant

While Loop Structure

Timing Function

Boolean Control Terminal

In this block diagram, the subVI Temp calls the subroutine which retrieves a temperature from a Data Acquisition (DAQ) board. This temperature is plotted along with the running average temperature on the waveform graph Temperature History. The Power switch is a boolean control on the Front Panel which will stop execution of the While Loop. The While Loop also contains a Timing Function to control how frequently the loop iterates. MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

INTRODUCTION TO MATLAB, SIMULINK AND LABVIEW

INTRODUCTION TO LABVIEW ™ Icon and connector pane Identifies the VI so that you can use the VI in another VI. A VI within another VI is called a sub-VI Provide the connectors for wiring.

TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

38

INTRODUCTION TO MATLAB, SIMULINK AND LABVIEW

INTRODUCTION TO LABVIEW ™ Three LabVIEW Palettes ¾ The Tools palette is available on the front panel and the block diagram. A tool is a special operating mode of the mouse cursor. ¾ The Controls palette is available only on the front panel The Controls palette contains the controls and indicators you use to create the front panel. ¾ The Functions palette is available only on the block diagram. The Functions palette contains the VIs and functions you use to build the block diagram.

TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

INTRODUCTION TO MATLAB, SIMULINK AND LABVIEW

INTRODUCTION TO LABVIEW ™ LabVIEW Palettes ¾ The Tools palette is available on the front panel and the block diagram. A tool is a special operating mode of the mouse cursor. Select View » Show Tools Palette to display the Tools palette • Floating Palette • Used to operate and modify front panel and block diagram objects. Automatic Selection Tool Scrolling Tool

Operating Tool Positioning/Resizing Tool

TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

Breakpoint Tool

Labeling Tool

Probe Tool

Wiring Tool

Color Copy Tool

Shortcut Menu Tool

Coloring Tool

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

39

INTRODUCTION TO MATLAB, SIMULINK AND LABVIEW

INTRODUCTION TO LABVIEW ™ LabVIEW Palettes ¾ The Controls palette Use the Controls palette to place controls and indicators on the front panel. •



Select View » Show Controls Palette or right-click the front panel workspace to display the Controls palette I th In the front f t panell mode, d right i ht click any empty place, the “control palette” will be shown. After you choose proper screen, you can pin that screen TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

INTRODUCTION TO MATLAB, SIMULINK AND LABVIEW

INTRODUCTION TO LABVIEW ™ LabVIEW Palettes ¾ Functions Palette - Use the Functions palette, to build the block diagram. g the block diagram g ƒ Select View » Show Functions Palette or right-click workspace to display the Functions palette. ƒ In the Block diagram mode, right click any empty place, the “function palette” will be shown. After you choose proper screen, you can pin that screen.

TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

40

INTRODUCTION TO MATLAB, SIMULINK AND LABVIEW

INTRODUCTION TO LABVIEW ™ Status Toolbar

Run Button 

Additi Additional l Buttons B tt on the th Di Diagram Toolbar T lb Execution Highlighting Button

Continuous Run Button

Retain Wire Values Button

Abort Execution

Step Function Buttons • • • • • • • •

Click the Run button to run the VI. While the VI runs, the Run button appears with a black arrow if the VI is a top-level VI, meaning it has no callers and therefore is not a subVI. Click the Continuous Run button to run the VI until you abort or pause it. You also can click the button again to disable continuous running. While the VI runs, the Abort Execution button appears. Click this button to stop the VI immediately. Click the Pause button to pause a running VI. When you click the Pause button, LabVIEW highlights on the block diagram the location where you paused execution. Click the Pause button again to continue running the VI. Select the Text Settings pull-down menu to change the font settings for the VI, including size, style, and color. Select the Align Objects pull-down menu to align objects along axes, including vertical, top edge, left, and so on. Select the Distribute Objects pull-down menu to space objects evenly, including gaps, compression, and so on. Select the Resize Objects pull-down menu to change the width and height of front panel objects. TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

INTRODUCTION TO MATLAB, SIMULINK AND LABVIEW

INTRODUCTION TO LABVIEW ™ Show context Help

When you point at any icon (graphical code), the description of the icon will be shown if the “show context help” is checked.

TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

41

INTRODUCTION TO MATLAB, SIMULINK AND LABVIEW

INTRODUCTION TO LABVIEW ™ Help Options

Context Help • • • •

Online help Lock help Simple/Complex Diagram help Ctrl + H

Online reference • All menus online • Pop up on functions in diagram to access online info directly

TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

42

MODELING AND SIMULATION OF MECHATRONIC SYSTEMS 4. THEORETICAL MODELING

TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

THEORETICAL MODELING

MODEL PARAMETERS AND SIGNALS ™ A model of a dynamic system contains a number of quantities of different types. ™ Certain quantities in the model which do not vary in time are called Constant. ™ Those quantities that vary in time are called variables or signals. ™ It is practical to distinguish two types of constants in models: ¾ System parameters are constants that are considered given by y and cannot be chosen by y the designer. g the system ¾ Design parameters are constants that can be chosen in order to give the system / model desired properties. The purpose of the simulation study is often to decide suitable values for the design parameters. TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

43

THEORETICAL MODELING

MODEL PARAMETERS AND SIGNALS ™ In systems/models, there are usually signals and variables that influence other variables in the system, but are not themselves influenced by the behavior of the system. Those variables are called external signals signals. In a block diagram the external signals are always marked by arrows coming from outside. ™ An external signal can be one of two types: ¾ Input or control signal: An external signal in the system whose time variations we can choose. Denoted by u1(t), u2(t) ... uR(t). If we assign these inputs in vector form, we obtain the input vector u(t) ¾ Disturbance signal: An external signal in the system y that we cannot influence. Denoted by z1(t), z2(t) . . . zQ(t) , respectively

Disturbance Inputs Subsystem

Control Inputs TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

System Outputs

System

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

THEORETICAL MODELING

MODEL PARAMETERS AND SIGNALS ™ A model and a dynamic system always contain a number of variables, or signals, whose behavior is our primary interest. Such signals are called ll d outputs andd usually ll denoted d d by b yl(t), ( ) y2(t),..., () yM(t). ( ) The h individual signals can be combined to form an output vector y(t) It is important to emphasize that the outputs of a model are not defined by the model itself, but that can be freely determined depending on the question what is going to be considered as output.

™ Internal variable: A variable in the system that is neither an output nor an external signal. In a system there is always a (not unique) number of internal or system state variables that allow a complete description Disturbance off system t dynamics. d i If we assign i these th System Inputs states in vector form, we obtain the state Outputs Subsystem vector x(t) Control Inputs TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

System

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

44

THEORETICAL MODELING

PHASES OF MODELING ™ Modeling is, in common with other scientific and engineering activities, as much an art as a science. Successful modeling is based as much on a good f li for feeling f the h problem bl and d common sense as on the h formal f l aspects that h can be taught. ™ In order to achieve purposeful mathematical descriptions the process of modeling can be divided into three phases: 1. The problem is structured and broken down 2. The basic equations are formulated 3. By rearranging, the state-space or transfer function model will be achieved hi d ™ One difficulty is that the modeling sometimes ranges over completely different types of physical systems. It is then useful to draw on the analogies that exist between different physical phenomena. The general structuring of the modeling into three phases will also be relevant in that context. TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

THEORETICAL MODELING

PHASES OF MODELING Phase 1: Structuring the Problem ™ Phase 1 consists of an attempt to divide the system into subsystems, an effort to determine cause and effect effect, what variables are important and how they interact. interact When doing this work, it is important to know the intended use of the model. The result of phase 1 is a block diagram or some similar description. This phase puts the greatest demands on the modeler in terms of the understanding of and intuition for the physical system. It is also in this phase that the level of complexity and degree of approximation are determine. ™ In summary, Phase 1 can be formulated by the following requirements: ¾ Determine the external signals and outputs of the system. Decide what internal variables are important for the system description ¾ Formulate the interaction between external signals, internal variables and outputs using a block diagram For more complex systems, it is more efficient to first divide the system into subsystems and then divide the subsystems further into blocks. TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

45

THEORETICAL MODELING

PHASES OF MODELING Phase 2: Setting up the Basic Equations ™ Phase 2 involves the examination of the subsystems, the blocks, that the structuringg of pphase 1 pproduced. The relationships p between constants and variables in the subsystems have to be formulated. For this purpose, those laws of nature and basic physical equations that are assumed to hold in the appropriate areas are used. This often means that certain approximations and idealizations (point mass, ideal gas, and the like) have to be made in order to avoid too complicated expressions. For non technical systems, for which generally accepted basic equations are often lacking, this phase gives the opportunity for new hypotheses and innovative thinking. ™ A proven approach in formulating the basic equations of a block or subsystem is : ¾ Writing down the conservation laws that are relevant for the particular block ¾ Using appropriate constitutive relations to express the conservation laws by means of the model variables. A dimension control at this point eliminates tedious debugging later ¾ It may be possible to carry out a linearization of the equations at this point TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

THEORETICAL MODELING

PHASES OF MODELING Phase 3: Forming the final model ™ Phase 3 in contrast to the other phases, is a more formal step aiming at the suitable organization of the equations and relationships left by phase 2. Even if the model in some sense is i ddefined fi d already l d after ft phase h 2, 2 this thi step t is i usually ll necessary to t give i a model d l suitable it bl for analysis and simulation. It is not always necessary to carry the work all the way to an explicit form. For the purpose of simulation it might be enough to achieve state-space models for the subsystems together with instructions for the interconnection.

1. 2.

3.

™ State-Space Model Suitable choice of state variables (state vector x(t)) Express the time derivative of the state vector dx(t)/dt by the state vector x(t) itself and the input vector u(t) Express the output vector y(t) by the state vector x(t) and input vector u(t) TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

1. 2. 3.

4.

™ Transfer Function Selection of input signal ui(t) and output signal yj(t) Laplace transform of differential equations Forming the (algebraic) equations with elimination of all variables except Ui(s) and Yj(s) Formulate the transfer function

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

46

THEORETICAL MODELING

SOME BASIC RELATIONSHIPS IN PHYSICS Electrical Systems ™ For many engineering applications it turns out that the same type of equations appear despite the diversity of the physical systems Starting from these analogies it is possible to do systematic modeling for a broad class of systems. Because of these analogies, the electrical systems are discussed here in the first place. ™ Consider electrical circuits consisting of resistors, capacitors, inductors, and transformers. The basic equations used to describe such circuits consist of relationships between the fundamental quantities: ¾ Voltage u (volt, V) ¾ Current C t i (ampere, ( A) Electrical components are described in terms of their voltage / current relations. RLC parallel circuit RLC series circuit TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

THEORETICAL MODELING

SOME BASIC RELATIONSHIPS IN PHYSICS Electrical Systems ™ Memory elements ¾ In these (idealized) elements, elements energy can be stored. stored ¾ An ideal inductor is described by:

¾ An ideal capacitor is described by:

where u(t) and i(t) are voltage and current at time t. The constant L is the inductance (henry, h). The relationship is sometimes called the law of inductance and it can also be written as:

Energy stored in a capacity EC is expressed by:

Energy stored in an inductor EL [J] is defined by: TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

where C is the capacitance (farad, F) . The relationship can also be written as:

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

47

THEORETICAL MODELING

SOME BASIC RELATIONSHIPS IN PHYSICS Electrical Systems ™ Resistance element

™ Transformer

For a linear resistor with resistance R (ohm, Ω) the relationship between current and voltage is given by the well known Ohm's law:

An ideal transformer transforms voltage and current in such a way that their product is constant:

In general, a resistance can also be a non-linear resistance described by the form: where α is the ratio of the number of turns on each side

In the resistor, energy is lost (as heat). The power is: (P is measured in watts, 1 W = 1 J/s.) TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

THEORETICAL MODELING

SOME BASIC RELATIONSHIPS IN PHYSICS Electrical Systems ™ Other basic laws Kirchhoff's Ki hh ff' laws l are basic b i tto th the analyses l off electrical circuits: a) Kirchhoff's Current Node Law

RLC parallel circuit

In a given node the sum of currents must be zero:

RLC series circuit

b) Kirchhoff's Voltage Loop Law The summation of voltage drops around a closed loop must be zero:

TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

48

THEORETICAL MODELING

SOME BASIC RELATIONSHIPS IN PHYSICS Mechanical Systems ™ Motion and force are concepts used to describe the behavior of engineering systems that employ mechanical components aspects that can be taught taught. Motion is a term used to describe the movement of a point relative to another and it is described using the terms distance, velocity, and acceleration. ™ Motion in mechanical systems can be: ¾ Translational ¾ Rotational, or ¾ Combination of above

™ Mechanical systems can be of two types: ¾ Translational systems. ¾ Rotational system.

™ The three basic mechanical elements are: ¾ Spring (elastic) element ¾ Damper (frictional) element ¾ Mass (inertia) element TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

THEORETICAL MODELING

SOME BASIC RELATIONSHIPS IN PHYSICS Mechanical Systems ™ Translational Mechanical Systems Mechanical translation is governed by the laws of mechanics, mechanics which are relationships between the variables: Force F (newton, N) Velocity v (meters per second, m/s) In general, these quantities are three dimensional vectors. Most of the following relationships can be formulated as vector equations, but for simplicity here are limited to the representation of scalar relations. Each of the elements has one of two ppossible energy gy behaviors: ¾ stores all the energy supplied to it ¾ dissipates all energy into heat by some kind of “frictional” effect ƒ Spring stores energy as potential energy ƒ Mass stores energy as kinetic energy ƒ Damper dissipates energy into heat TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

49

THEORETICAL MODELING

SOME BASIC RELATIONSHIPS IN PHYSICS Mechanical Systems ™ Translational Mechanical Systems Memory elements ¾ Even with mechanical translational elements, energy can be saved; the ideal inductance here is obviously the mass m [kg] . Newton's second law gives: The above equation can also be written as In the previous equations, F(t) has to be understood as a sum of forces acting on a body Energy stored in a moving mass is kinetic energy Ek [J] : TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

¾ For an ideal (linear) spring, the reciprocal value of spring constant 1/k [m/N] can be considered as capacity. The spring force is proportional to the elongation (or compression), i.e. it is proportional to the integral of the difference in velocity between the end points: i t

Energy stored in a spring is potential energy Ep [J] :

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

THEORETICAL MODELING

SOME BASIC RELATIONSHIPS IN PHYSICS Mechanical Systems ™ Translational Mechanical Systems ¾ Resistance element ¾ Transformer At translational motion in real systems, friction is always present. In general, friction is described by:

The ideal transformer corresponds to a rigid lever. For an ideal transformer with the lever ratio α, therefore, the following equations can be applied:

The most common case perhaps is dry friction: Air resistance is often described by : and viscous friction :

Rigid lever as an ideal mechanicaltranslational transformer

The power lost as heat through friction is : TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

50

THEORETICAL MODELING

SOME BASIC RELATIONSHIPS IN PHYSICS Mechanical Systems ™ Translational Mechanical Systems ¾ Other Oth basic b i llaws For a translational mechanical system at rest, the sum of attacking forces is always zero: This is the equivalent of Kirchhoff's voltage law; an analogous relationship for the velocities does not exist! Law of reaction forces (Newton’s 3rd law) All forces occur in equal and opposite pairs (action/reaction). Force exerted by an element is equal and opposite to the force on the element.

TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

If the ends of two elements are connected connected, these ends are forced to move with the same displacement, velocity, and acceleration

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

THEORETICAL MODELING

SOME BASIC RELATIONSHIPS IN PHYSICS Mechanical Systems ™ Rotational Mechanical Systems Mechanical systems with rotational parts like motor and gear boxes, are very common. For these systems the laws of mechanics relate the basic variables: Torque M (newton-meter, Nm) Angular velocity ω (radians per second, s-1)

M,θ M,θ

¾ Memory elements The ideal inductance here is the moment of inertia J [Nm/s2], while the torque on the axis is proportional to the angular acceleration, i.e.:

M,θ

This can be written as: Energy stored in a rotating mass Ek [J] is given by: TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

51

THEORETICAL MODELING

SOME BASIC RELATIONSHIPS IN PHYSICS Mechanical Systems ™ Rotational Mechanical Systems ¾ Memory elements Torsion is the twisting of an object due to an applied torque. The torsional stiffness k [Nm] is defined by the relationship between the angular velocity and the torque:

M,θ M,θ

The torsion of an axis gives rise to a torque described by:

The integral corresponds to the angular displacement between the ends. M,θ

Due to torsion, energy is stored as a potential energy Ep [J] expressed by: TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

THEORETICAL MODELING

SOME BASIC RELATIONSHIPS IN PHYSICS Mechanical Systems

™ Rotational Mechanical Systems

¾ Resistance element The rotational friction is a function of the angular velocity: with different functions r analogous to translational friction. The power dissipation at rotation is:

¾ Transformer The ideal transformer corresponds to a friction-free pair of gears. For an ideal transformer with the ratio α, therefore, the following equations can be applied: Friction-free pair of gears as an ideal mechanical-rotational transformer

¾ Other basic laws For a rotational mechanical system at rest, the sum of all torques must be zero: TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

52

THEORETICAL MODELING

SOME BASIC RELATIONSHIPS IN PHYSICS Fluid Systems ™ The fluid systems discussed here are limited to flows of incompressible fluids in pipes and tanks. (Incompressible fluids are those for which the volume is unaffected by the pressure.) Typical applications are in chemical industrial systems and hydraulic systems. The treatment of compressible fluids is more complicated, partly because there are temperature changes when the volume is altered. ™ Fluid systems are described by two basic quantities: ¾ Pressure p (newtons per square meter, N/m2) ¾ Flow Q (cubic meters per second, m3/s) Volume flow Q multiplied by the density gives a mass flow in [kg/s]. For incompressible flows there is no essential difference.

TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

THEORETICAL MODELING

SOME BASIC RELATIONSHIPS IN PHYSICS Fluid Systems

™ Memory elements

¾ For a fluid flow through a tube, the pressure difference p between the end points of the tube results in a force that accelerates the fluid. fluid The force is where A is the cross-sectional area. If the density of the fluid is ρ, than the mass to be accelerated is ρlA. Newton's force law gives:

Flow through a tube. p1 and p2 are the pressures at the end points of the tube

where v(t) is the velocity of the fluid. The velocity corresponds to a fluid flow Q = v(t)A, therefore the above equation can be written as: or in integral notation: where is the fluid inertia [kg/m4] represents the pipe. TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

The frictionless flow through a tube corresponds to a stored kinetic energy E [J] defined by

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

53

THEORETICAL MODELING

SOME BASIC RELATIONSHIPS IN PHYSICS Fluid Systems

™ Memory elements

¾ Consider a fluid that is accumulated in a tank. The volume V in the tank is the integral of the flow: The pressure at the bottom of the tank is equal to the level h (h = V/A) multiplied by the density ρ and the gravitational acceleration g :

A tank as a fluid store

The parameter: Cf = A/ρg [m4s2/kg] is called the fluid capacitance. The potential energy E [J] stored in the tank is expressed by:

TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

THEORETICAL MODELING

SOME BASIC RELATIONSHIPS IN PHYSICS Fluid Systems ™ Resistance element When liquid flows through a tube there is normally a loss of power through friction against g the walls and internal friction in the fluid. This leads to a ppressure drop over the tube. Conversely, it can be said that a pressure drop is needed to maintain a certain flow. The pressure drop depends on the flow. In general it can be written: The function r(Q) depends on the tube geometry. If the tube is thin or filled with a porous medium, d'Arcy's law applies: where Rf [kg/m4s] is called the flow resistance. If the tube contains a sudden change in area (an orifice or a valve), than: with a constant H.

Q

p2

p = p1 − p 2

The energy loss through friction phenomena is given by: TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

p1

Flow through an orifice

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

54

THEORETICAL MODELING

SOME BASIC RELATIONSHIPS IN PHYSICS Fluid Systems ™ Transformer The ideal transformer f corresponds p to a friction-free double piston. For an ideal transformer with the ratio α, therefore, the following equations can be applied:

Friction-free double piston as an ideal flow transformer

™ Other basic laws F incompressible For i ibl fluid fl id completely l t l analogous l laws l apply l as for f electric l t i circuits, i it so that Kirchhoff's laws can be adapted accordingly. The total pressure over a series When flows are connected in a junction connected pipes must be the their sum must be zero: sum of the pressure drops TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

THEORETICAL MODELING

SOME BASIC RELATIONSHIPS IN PHYSICS Thermal Systems Thermal systems involve heating of objects and transport of thermal energy. The laws governing these phenomena are typically expressed as relationships between the quantities: Temperature T (kelvin, K) Heat flow rate q (watt, W)

™ Other basic laws

™ Memory elements Heating of a body means that the temperature increases as heat flows into it. C [J/K] is the thermal capacity This relationship Thi l ti hi can bbe written itt as:

Heat transfer between two bodies with temperatures T1 and T2 is often assumed to be proportional to the temperature difference ∆T = T2 − T1 : W [J/Ks] is called the heat transfer coefficient Furthermore, the sum of all heat flow rates at one point must be zero:

In thermal systems, the heat flow corresponds to a self-resistance (energy dissipation). A transformer is indeed realized in thermal systems (heat pumps, refrigeration unit), but can not be discussed even in a rough approximation as an ideal transformer. TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

55

THEORETICAL MODELING

SOME BASIC RELATIONSHIPS IN PHYSICS Analogies between physical subsub-areas ™ Obviously there are strong analogies between the different areas of modeling. A common basic structure can therefore be found in all areas: ¾ There are always two variables sufficient to completely describe the systems, which are commonly used as: ƒ Effort variables e ƒ Flow variables f ¾ The relationships between these variables have the following forms: ƒ

Effort storage:

ƒ

Flow storage:

ƒ

Static relationship:

ƒ

Inductive energy storage:

ƒ

Capacitive energy storage: TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

ƒ

Power dissipation:

ƒ

S Sum off fl flows equall to t zero:

ƒ

Sum of efforts (with signs) equal to zero:

ƒ

Transformation of variables:

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

THEORETICAL MODELING

SOME BASIC RELATIONSHIPS IN PHYSICS Analogies between physical subsub-areas Some Physical Analogies System

Effort

Flow

Inductance

Capacitance

Resistance

Electrical

Voltage

Current

Inductor (coil)

Capacitor

Resistor

Translational

Force

Velocity

Mass

Spring

Friction

Rotational

Torque

Angular velocity

Moment of inertia

Torsion spring

Friction

Hydraulic

Pressure

Flow

Tube

Tank

Orifice

Thermal

Temperature

Heat flow rate

-

Heating

Heat flow

Mechanical:

TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

56

THEORETICAL MODELING

MODEL SIMPLIFICATION ™ All models contain simplifications of the real processes. The model must be manageable for our purposes. A model with thousands of variables is impossible to use for f analysis l i and d requires i llong execution i times i ffor simulation. i l i Simple i l model d l primarily means a model whose order (the dimension of the state vector) is small. Simple could also mean that the relationships between variables are easily computable or that the model is linear rather than nonlinear. ™ The model simplification can be done under the first two phases of modeling but also in the completed model to reduce complexity. The model simplification can be done by: 1. Neglect of small effects - Approximations 2. Separation of time constants Hierarchy of Models, depending on the particular need for the model   more‐complex, more‐realistic, less‐easily‐solved 3. Aggregation of State Variables 4. Linearization Design Truth Model Model 5. Model reduction for linear systems less ‐complex, less‐realistic, more‐easily‐solved TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

THEORETICAL MODELING

MODEL SIMPLIFICATION ™ Neglect of small effects - Approximations It is often clear that certain effects are more important p than others. The decisions which effects can be neglected may be done after an extensive expertise or after detailed preliminary investigations. Many relationships between variables in an engineering system are complicated and do not fit the idealized situations for which physical laws are formulated. Real gases are not ideal, real liquids are not incompressible, real flow is not laminar, and so on. When modeling a nontechnical system, the difficulties of getting a reliable description are even greater. In practice, practice we have to accept working with approximate relationships. The degree of approximation that we can tolerate depends on the desired accuracy of the model. We must also have some balance between approximations in different subsystems. TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

Hierarchy of Models, depending on the particular need for the model   more‐complex, more‐realistic, less‐easily‐solved Truth Model

Design

Model

less ‐complex, less‐realistic, more‐easily‐solved

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

57

THEORETICAL MODELING

MODEL SIMPLIFICATION ™ Separation of Time Constant In the same system there are often time constants of different orders of magnitude. Still, the interest might be focused on a certain time scale. The following rules can be applied: 9 Concentrate the modeling on phenomena whose time constants are of interest when considering the intended use of the model 9 Subsystems whose dynamics are considerably faster are approximated with static relationships 9 Variables of subsystems whose dynamics are appreciably slower are approximated as constant By observing these rules, rules there are two major advantages: 1. Due to the neglect of very fast and very slow dynamics, the order of the model is lower 2. A model with time constants of the same magnitude is easier to simulate numerically For some systems there might really be interest in time constants of quite different magnitude. In such a case, the possibility of using two different models (one for each time scale) should be considered, and each one of them should be simplified using the preceding procedure. TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

THEORETICAL MODELING

MODEL SIMPLIFICATION ™ Aggregation of State Variables An example of aggregation of state variables: g several similar variables into one state variable. To merge Often this variable plays the role of average or total value. Aggregation is a very common method for reducing the number of state variables in a model. A typical example is thermodynamics. To know the state of a volume of gas, we would strictly speaking have to know the speed and position of every molecule. Instead we use pressure and temperature when dealing with a gas on a macro level. Those variables are aggregated state variables connected to the average distance between molecules and the average velocity.

A number of physical phenomena are described by partial differential equations (PDE). Typical examples are field equations, waves, flow, and heat conduction problems. In mathematical models of dynamic systems to be used in simulation, PDEs are often unsuitable. Often partial differential equations are reduced to ordinary differential equations via difference approximations of the spatial variables. This corresponds to aggregation. TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

58

THEORETICAL MODELING

MODEL SIMPLIFICATION ™ Aggregation of State Variables Example: Heat Conduction Consider a metal rod whose left end point is heated by an external source. Model with distributed parameters The third-order model with lumped parameters

- temperature at time t at the distance x a - heat conductivity coefficient of the metal Boundary conditions:

The mathematical model does not define a state, but a continuous function T (x, t) in two variables. Therefore, systems described by partial differential equations are often called infinite-dimensional systems. TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

The linear state-space model - the state vector

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

THEORETICAL MODELING

MODEL SIMPLIFICATION ™ Linearization The linearization of a mathematical model is often used simplification when deviations are viewed from an operating point (steady state, time derivatives equal to zero). The linearization of a nonlinear dynamical system can be done analytically or numerically.

Analytical linearization If the analytical description of a nonlinear dynamical system is given by a nonlinear ordinary differential equation, a Taylor series expansion can be calculated, and than higher derivatives can be neglected (this applies to the continuous non-linearities). ( kn ) ( k1 ) ( k2 ) ⎡ ⎤ F ⎢ x1 , x&1 ,..., x1 , x2 , x& 2 ,..., x2 ,......., x& n ,..., xn ⎥ = 0 ⎣ ⎦

Taylor series around the operating point is F = F0 +

( k1 ) ∂F ∂F ∂F ∆x1 + ∆x&1 + ........ + ( k1 ) ∆ x1 + ∂x1 0 ∂x&1 0 ∂ x1 0

( k2 ) ∂F ∂F ∂F + ∆x 2 + ∆x& 2 + ........ + ( k 2 ) ∆ x 2 + ∂x 2 0 ∂x& 2 0 ∂ x2 0

+

∂F ∂F ∂F ∆x n + ∆x& n + ........ + ( k ) ∆ x n = 0 n ∂x n 0 ∂x& n 0 ∂ x2 0 ( kn )

TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

Linear differential equation:

( k1 )

F = a10 ∆x1 + a11 ∆x&1 + . . . . + a1k1 ∆ x1 + ( k ) 2 + a 20 ∆x 2 + a 21 ∆x& 2 + . . . . + a 2 k2 ∆ x 2 +

( kn )

+ a n 0 ∆x n + a n1 ∆x& n + . . . . + a nk n ∆ x n = 0

where the coefficients aij apparently arising from the partial derivatives in the operating point a ij =

∂F ( j)

∂ xi

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

59

0

THEORETICAL MODELING

MODEL SIMPLIFICATION ™ Linearization Example A simple model for an air heating The formal linearization yields to the equation T - output temperature q - supplied heat flux c - specific heat capacity of air - mass flow Te input temperature

Now we calculate the partial derivatives and remembering that we obtain the linearized differential equation

The implicit form of the equation:

TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

THEORETICAL MODELING

MODEL SIMPLIFICATION ™ Linearization Numerical linearization Prerequisite is the existence of a nonlinear simulation model. The linearization procedure than is applying to each state and each input of the model as follows: 1. The value of the state vector in the operation point is sets as initial condition 2. All inputs are equal to zero 3. A single state or input is excited by a disturbance of small amplitude. To do this, the model should be integrated numerically 4. From the recorded changes in the remaining states, the corresponding difference quotient between excited variable and the remaining variables is determined numerically This process leads to discrete linear state space model describing the dynamics for small deviations around the operating point.

TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies - DRIMS

MODELING AND SIMULTION OF MECHATRONIC SYSTEMS

60

THEORETICAL MODELING

MODEL SIMPLIFICATION ™ Model reduction for linear systems For linear, stable and observable systems there is possibility to transform originally received state-space model into special form so-called ‘balanced realization’. In this state representation, the system states are treated by an energy criterion in their meaning, i.e. using a weight the significance of the individual states can be determine. This choice of weights is therefore a quantitative criterion for deciding which states you can omit. Even very large order systems (n> 100) can thus be efficientlyy reduced to small models ((n