Physical Mo deling with Mo delica and and

Real-Time Simulation with and Real Time Workshop

1 2 2

H. Elmqvist , M. Otter , and C. Schlegel

1

Dynasim AB, ResearchPark Ideon, S{223 70 Lund, Sweden, email: [email protected]

2

DLR, P.O.B. 1116, D-82230 Wessling, Germany, email: [email protected]/[email protected]

1 Intro duction

A new language for physical mo deling called Mo delica has b een develop ed in an international e ort. An

overview of the Mo delica language will b e given in the context of mo deling and simulating a complex industrial

system: hardware-in-the-lo op simulation of an automatic gearb ox. The electronic control unit hardware has

b een tested against a simulated mo del of the gearb ox.

Several to ols have b een used to solve the problem. The rst issue is the mo deling. Writing the equations from

scratchwould be very tedious. A structuring of the mo del according to the physical comp onents and b eing

able to reuse available submo dels is essential. The new Mo delica mo deling language and a mo del library for

drive trains have b een used.

The graphical environment of Dymola has b een used for comp osing the mo del. The natural graphical repre-

sentations are shown b elow. Ecient co de is essential for real-time simulation. The Mo delica translator of

Dymola has b een used to symb olically translate the di erential-algebraic equations DAE to explicit state

space form and to generate C co de in S function MEX le format.

The S-function has b een used for oine simulation in Simulink whichwas also used for con guring the interface

to the control hardware. Real Time Workshop has b een used for generation of the co de for dSPACE hardware.

The time for the evaluation of one Euler step is 0.65 ms on a 300 MHz DEC alpha pro cessor.

2 Mo delica - A Uni ed Ob ject-Oriented Language for Physical Sys-

tems Mo deling

A new language for physical mo deling called Mo delica has b een develop ed in an international e ort. The main

ob jectiveistomake it easy to exchange mo dels and mo del libraries. The design approach builds on non-casual

mo deling with true ordinary di erential and algebraic equations and the use of ob ject-oriented constructs to

facilitate reuse of mo deling knowledge. There are already several mo deling language based on these ideas

available from universities and small companies. There is also signi cant exp erience of using them in various

applications. The aim of the Mo delica e ort is to unify the concepts and design a new uniform language for

mo del representation.

The work started in the continuous time domain since there is a common mathematical framework in the form

of di erential-algebraic equation DAE systems. The short range goal was to design a mo deling language

based on DAE systems with some discrete event features to handle discontinuities and sampled systems. The

design should allowanevolution to a multi-formalism, multi-domain, general-purp ose mo deling language.

There are presently ab out 15 memb ers from 13 universities and industries in six countries in the Mo delica design

group. H. Elmqvist is the chairman. Information on the Mo delica e ort, including mo deling requirements,

rationale and de nition of the Mo delica language, is available on WWW at http://www.Dynasim.se/Mo delica/.

The activity started in Septemb er 1996 as an e ort within the ESPRIT pro ject "Simulation in Europ e Basic

ResearchWorking Group SiE-WG". In February 1997 the Mo delica design e ort b ecame a Technical Com-

mittee within the Federation of Europ ean Simulation So cieties, EUROSIM. The rst version of the Mo delica

language de nition was nished in Septemb er 1997. The work is now fo cused on the design of standard function

and mo del libraries.

An overview of the Mo delica language will b e given in the context of mo delling an automatic gearb ox. 1

3 Hardware-in-the-lo op Simulation of Gearb oxes

Comfort standards regarding gearshift of automatic gearb oxes of vehicles increase p ermanently. Gearshift

comfort is mainly in uenced by control of the switching elements of a gearb ox: Clutches and freewheels.

Control is p erformed mostly by an electronic control unit ECU. Fine tuning of the ECU and the switching

elements is essential to optimize gearshift comfort.

Hardware-in-the-lo op HIL simulation is used more and more in order to sp eed up the development cycle.

For the problem treated, such a setup consists of the ECU-hardware and a realtime simulation of all other

comp onents interacting dynamically with it: The whole drive train of engine, hydro dynamic torque converter,

gearb ox, di erential gearb ox and longitudinal dynamics of the vehicle.

Mo deling such a system is dicult since the structure of the system varies during each gearshift: Dep ending on

the actual control, di erent wheels and freewheels are engaged or disengaged. The integrator has to b e stopp ed

and the new structure has to b e determined in accordance to the actual forces imp osed on the gearwheels by

the switching elements. In the example treated, the automatic gearb ox has 6 switching elements leading to

6

2 = 64 p ossible con gurations of the system.

It is shown how suchavariable structure system can b e mo deled with Mo delica. The Mo delica-translator of

the simulation environment Dymola, together with Dymola's symb olic engine, is used to generate ecientcode

suited for realtime simulation which e.g. requires a state space form of the mo del. A new technique, which meets

the realtime requirements like xed sampling time, is used to iteratively nd a consistent con guration after

a gearshift. Therefore a hardware-in-the-lo op HIL simulation of automatic gearb oxes b ecomes p ossible. The

eciency of the generated co de and the sampling frequency necessary to repro duce oine simulation results

enables the usage of digital signal pro cessors.

4 Mo del of Automatic Gearb ox

Gearshift dynamics can only be simulated if the input- and output-torques of the gearb ox represent a real-

life vehicle maneuver. Therefore, at least the engine and the longitudinal dynamics of the vehicle has to b e

mo deled. A Mo delica mo del of such a system is given in gure 1as a comp osition or ob ject diagram using

Dymolas ob ject diagram editor. Every icon in the comp osition diagram is an instance of a Mo delica class and

represents a comp onentof the drive train. Mechanical anges of the comp onents are mo delled by Mo delica

connector classes and are characterized by small square boxes in the icons. A line between two connectors

de nes a rigid, mechanical coupling between the resp ective comp onents. Dashed lines respresent directed

signal ow connections.

car=1700 gear=13.5 FS Wind: cw=0.33

AutoGear ThrottlePos JMotorPump=0.28 Jturbine=0.034 1 TS TS Engine converter

ECU

ControlBox

Figure 1: Comp osition diagram of vehicle drive train.

The driving part of the system in gure 1 consists of the engine, the torque converter and appropriate inertias.

Engine and converter are mo deled by tables. The driven part incorp orates the automatic gearb ox, the mass of 2

the car, and aero dynamic forces. Comp onent \ControlBox" represents the ECU which generates the gearshift

signals. For oine simulations simple ramp functions are used. During HIL simulations these signals are

generated by the hardware ECU and fed to the simulation pro cessor via appropriate interfaces like digital IO and CAN bus.

Fix1 Fix2 Fix3 C8=0.12 C6=0.12 C12=0.12

Shaft1=2e-3 Shaft2=2e-3 S S C4=0.12 C5=0.12 C11=0.12

P1=110/50 P2=110/50 P3=120/44

Figure 2: Comp osition diagram of automatic gear b ox \AutoGear".

In gure 2 the Mo delica mo del of the automatic gearb ox comp onent \AutoGear" is shown. It is set up by three

standard planetary wheelsets, by shafts to mo del wheel inertias, by clutches and by combined clutch/freewheel

elements = one-way clutches.

5 Mo delica Mo dels of Basic Drive Train Library Comp onents

In the previous section the vehicle drive train mo del was built up by the connection of basic comp onents, like

shafts and clutches, using comp osition diagrams. The most imp ortant comp onents from the available drive

train library are now discussed in more detail. All drive train comp onents have mechanical anges which are

used to connect comp onents rigidly together and which are de ned by the following Mo delica connector class

a connector class is a class usable in connections:

connector DriveCut

Ang ul ar V el ocity : w "angular velo city of cut";

Ang ul ar Accel er ation: a "angular acceleration of cut";

ow T orque : t "cut-torque";

end DriveCut;

The keyword ow indicates that the Torque variables should be summed to zero at a connection p oint. In

other words, Torques are through variables. Connector class DriveCut de nes the three variables \w,a,t" using

basic typ e classes de ned in the Mo delica base library typ e classes are classes which do not have equations:

typ e Ang ul ar V el ocity = Real q uantity =\AngularVelo city", unit =\1/s";

typ e Ang ul ar Accel er ation = Real q uantity =\AngularAcceleration", unit =\1=s2";

typ e T orque = Real q uantity =\Torque", unit ="N.m";

All the three variable typ es are real variables with a de ned quantity and unit. Some typical comp onents using

this connector class are shown in table 1.

Mo del class Shaft describ es a shaft with inertia and two mechanical anges p and n. The rst two equations

contain the relationship b etween the kinematic variables of the two anges. The last equation is Newtons law.

The third equation dep ends on a Bo olean parameter and de nes whether the angular velo city of the element

is used as a state variable or not. This is e.g. needed if two shafts are connected rigidly together by a gearb ox,

since only one of the two shafts can have state variables in such a case in order to b e able to transform the

overall system to state space form. Mo del class Gear is an ideal gearb ox without inertia and nally mo del class

DriveSpringS is a rotational spring where the spring torque is used as state variable. 3

Graphical Representation Mo delica description

model Shaft

parameter I ner tia J \shaft inertia";

parameter B ool ean state = tr ue; ; cut p cut n DriveC ut p; n

p.t n.t equation

n.w + n:w =0;

p.w p:w

p:a + n:a =0;

if state then

derp:w =p:a;

end if

J  p:a = p:t n:t;

end Shaft;

model Gear

parameter r eal r atio \gear ratio";

DriveC ut p; n; equation

cut p cut n

+ r atio  n:w =0;

p.t n.t p:w

+ r atio  n:a =0;

p.w n.w p:a

r atio  p:t = n:t;

end Gear

model DriveSpringS

parameter Real c \spring constant"

cut p cut n ; p.t n.t DriveC ut p; n

p.w n.w equation

derp:t=cp:w + n:w ;

p:t = n:t;

end DriveSpringS;

Table 1: Comp onents of Mo delica drive train library.

6 Realtime Simulation of Automatic Gearb ox

The Mo delica translator of the Dymola mo delling and simulation environment takes the describ ed Mo delica

mo del of the vehicle drive train and the automatic gearb ox as an input, generates a di erential-algebraic

equation system DAE and transforms the DAE to state space form by symb olic manipulation and graph

theoretical algorithms. The original sorted equations contain a linear system of 49 simultaneous equations,

due to the shafts connected via rigid gearb oxes and due to the clutch equations. Via tearing this system of

equations is reduced to 10 linear equations which are solved by standard numerical pro cedures whenever the

mo del is evaluated. The nal equations are stored as C co de whichis compiled and linked as an S-function

MEX le.

The simulation results from SIMULINK can be imp orted to the 3D animation mo dule of Dymola. Dymola

presents a 3D view with hidden surfaces removed and shading as shown in gure 3. Dymola uses the Op enGL

standard, i.e. hardware accelerators on graphics b oards are utilized. The visual 3D mo del is automatically

generated from the comp osition diagrams of gure 1 b ecause the comp onents of the drive train library contain

instances of built-in visual shap es like cylinders and gear wheels. The drive train comp onents have some

additional visual parameters like radius and p osition along the shaft.

For realtime simulation Matlab CMEX co de can be generated and used in Mathworks Realtime Workshop.

The time for the evaluation of one Euler step was measured as 4.7 ms on a 50 MHz Texas Instruments C40

DSP and 0.65 ms on a 300 MHz DEC alpha pro cessor b oth PC plugin cards by dSPACE Inc.. A typical

gearb ox ECU sampling time is 10 ms. This o ers enough margin for mo del re nement and IO using to days

typical HIL simulation pro cessors. 4

Figure 3: Automatically created animation of gear b ox comp onents.

References

[1] Elmqvist H., Bruc  kD. and Otter M.: Dymola { User's Manual,Version 3.0, Dynasim AB, Lund, Sweden, 1996.

[2] Elmqvist H., Mattsson S.E.: An introduction to the physical Modelica. Pro c. ESS '97 Europ ean Simulation

Symp osium, Passau, Germany, Octob er 19-22, 1997.

[3] Mo delica: A Uni ed Object-Oriented Language for Physical Systems Modeling. Mo delica homepage:

http://www.dynasim.se/Mo delica/.

[4] Otter M.: Object-OrientedModeling of Drive Trains with Friction, Clutches and Brakes. Pro c. ESM'94 Europ ean Simulation

Multiconference, Barcelona, Spain, June 1.-3., pp. 335-340, 1994.

[5] Otter M., Schlegel C. and Elmqvist H.: Modeling and Realtime Simulation of an Automatic Gearbox using Modelica. Pro c.

ESS '97 Europ ean Simulation Symp osium, Passau, Germany, Octob er 19-22, 1997. 5