
Proceedings of the 3rd International Modelica Conference, Linköping, November 3-4, 2003, Peter Fritzson (editor) Mike Dempsey Claytex Services Limited: Automatic translation of Simulink models into Modelica using Simelica and the AdvancedBlocks library pp. 115-124 Paper presented at the 3rd International Modelica Conference, November 3-4, 2003, Linköpings Universitet, Linköping, Sweden, organized by The Modelica Association and Institutionen för datavetenskap, Linköpings universitet All papers of this conference can be downloaded from http://www.Modelica.org/Conference2003/papers.shtml Program Committee Peter Fritzson, PELAB, Department of Computer and Information Science, Linköping University, Sweden (Chairman of the committee). Bernhard Bachmann, Fachhochschule Bielefeld, Bielefeld, Germany. Hilding Elmqvist, Dynasim AB, Sweden. Martin Otter, Institute of Robotics and Mechatronics at DLR Research Center, Oberpfaffenhofen, Germany. Michael Tiller, Ford Motor Company, Dearborn, USA. Hubertus Tummescheit, UTRC, Hartford, USA, and PELAB, Department of Computer and Information Science, Linköping University, Sweden. Local Organization: Vadim Engelson (Chairman of local organization), Bodil Mattsson-Kihlström, Peter Fritzson. M. Dempsey Automatic translation of Simulink models into Modelica using Simelica and the AdvancedBlocks library A utomatic translation of Simulink models into Modelica using Simelica and the AdvancedBlocks library Mike Dempsey Claytex Services Limited 5 Marston Close, Leamington Spa, UK [email protected] http://www.claytex.com/ Abstract For many years Simulink has been the tool of choice for much of the automotive industry to A new tool, Simelica™, is presented for converting develop both physical and control system Simulink® models into equivalent Modelica® models[1,2,3]. The main attraction of Simulink models. The conversion is achieved while has been its flexibility and the range of toolboxes retaining the original structure of the Simulink available to aid control system design, model. The equivalent Modelica models are built development and calibration. However, many from a new library of components, the users of Simulink are finding that as the physical system models increase in complexity, the task of AdvancedBlocks™ library. developing these models further is becoming increasingly difficult and time consuming. Many The AdvancedBlocks library is designed to work are now looking at alternative systems and with Simelica but also brings a new range of Modelica based tools are well placed in the market control system component models to the Modelica to meet these needs. environment. The blocks are designed to enable the calculation method used to be varied in each The adoption of the Modelica tools is currently particular instance that the block is required. For limited to those departments within automotive example, in the DiscreteIntegrator block you can manufacturers that are currently pushing forward choose from 3 different integration algorithms, the development of complex physical system whether to apply limits to the integrator or not, and models[4,5]. This is leading to problems within how the initial condition is specified amongst these companies where the control system many other options. The main focus is on engineers are still developing models in Simulink delivering a user-friendly library to aid control while the design engineers are developing physical system modelling. system models using Modelica. Some example applications will be discussed to ™ illustrate how effective the translation process can Currently tools such as Dymola provide methods be. to generate S-functions from the Modelica models[6] and this then enables the models to be simulated together in one environment. In our 1 Motivation experience this method has not been completely successful. We have found that, with our more The use of system modeling and simulation is complex physical models, the Simulink solvers are increasing in the automotive industry as we strive unable to cope reliably with the generated S- to reduce product development times whilst function models. This has led to simulations increasing the complexity and quality of the effectively stalling where the time step becomes so product. As the use of these simulation techniques small that the simulation is no longer making increases so does the requirement to include more progress. and more detail into the models and to ensure that the interaction between the different systems is We then simply asked ourselves, why don't we being modeled adequately. make the process work the other way round? Why not convert the control system model into The Modelica Association Modelica 2003, November 3-4, 2003 M. Dempsey Automatic translation of Simulink models into Modelica using Simelica and the AdvancedBlocks library Modelic a and use that environment to simulate the Following translation, a log of the work done is interactions between control system and physical produced. This will list any problem blocks system. After all Modelica can support a block encountered and include their full path in the diagram modeling style and our physical models model. The user can then easily see what, if any, are working reliably in the Modelica environment. parts of the translated model need further attention before it can be used. 2 Simelica Figure 1: Screen shot of Simelica 2.1 Overview Simelica is a translation tool for converting Simulink models into equivalent Modelica models. It works as both a command line tool so that its use can be incorporated into scripts and also as a windows tool complete with graphical user interface (GUI). The translation works by reading the Simulink .mdl file and interpreting this into a Modelica model based on the AdvancedBlocks library. Simelica is capable of dealing with all the As well as the need to translate a model it is also modeling methods used in Simulink including: essential to translate the data from the Simulink • From-goto systems environment into the Modelica environment. Data • Signal Bus systems can be imported and incorporated into a translated model using Simelica. The model data has to be • Muxed signals ® • Data store read/write/memory systems stored as a Matlab binary file, which can then be read by Simelica and the data incorporated into the The majority of the standard Simulink library can model through the use of a record that is available be automatically translated into an equivalent in every subsystem. Modelica block although there are some exceptions including the MatlabFcn, S-function and An additional consideration in the translation of data is that Simulink can load different data files Stateflow® blocks. into different points of the model through the use of masked subsystems. In Simelica, masked 2.2 Using Simelica subsystems are identified and the user is given the option of incorporating a data file directly into The command line version of Simelica provides each masked subsystem. In this case each masked simple functions to translate a single Simulink file subsystem gains its own unique workspace record or all the Simulink files contained in a specified to replicate the fact that Simulink defines local directory. This version is useful for incorporation workspaces for masked subsystems. into scripts but it does not provide many of the features available through the GUI that most users The Modelica models generated by Simelica are will find useful, such as highlighting unsupported based on the AdvancedBlocks library rather than blocks. Figure 1 shows a screen shot of Simelica. interpreting the model into a flat model file. This ensures that the model appears similar and When running in GUI mode after the Simulink file maintains the same structure as the original is read into the tool the structure of the model is Simulink model. Figure 2 shows a comparison of presented to the user. Any unsupported blocks are a translated model in Simulink and Dymola. It highlighted to the user at this point along with a shows that the model structure is preserved and the brief explanation of what action the user must take layout and connection of blocks in the Modelica either now, or after the Modelica file is generated version is similar to the original model. to ensure that the translated model can be used. The Modelica Association Modelica 2003, November 3-4, 2003 M. Dempsey Automatic translation of Simulink models into Modelica using Simelica and the AdvancedBlocks library Fig ure 2: Comparison of a translated 3.2 Connector Definition model in Simulink (top) and Dymola The first step in developing the new library was to define the connector for the blocks. A new connector was required for a number of reasons; firstly, Simulink supports the use of matrix, vector and scalar signals whilst the original Modelica.Blocks.Interface.InPort and OutPort connectors[7] only support vector signals. Therefore we needed to change the connector definition to support matrix signals. During the translation process Simulink scalar signals are converted into Modelica matrices with only one value and vector signals are converted into Modelica matrices with only 1 row. A second consideration was that Simulink cascades sample times along the connections. This means that a block can inherit a sample time from its driving block. To achieve this in Modelica we needed to add an additional signal to our connector to carry the sample times from block to block. It is necessary for this sample time signal to be a matrix because when muxed signals are used in Simulink it is possible for each signal to be carrying with it a different sample time. To replicate this behavior in the AdvancedBlocks library we actually pass a sample trigger along the connections that tells the connected block at which point in time it should calculate its output. The final consideration for designing the connector was that Simulink signals could be different data types. We therefore needed to find a way to define a connector in which we could easily change the data type. We also needed to find a structure that 3 AdvancedBlocks Library would allow the connectors to be replaced even though the basic data type of the signal might be changing.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages11 Page
-
File Size-