Home

Simulink Interface

image

Contents

1. Notice that in this figure there is a field with the label Adams in it This must be changed by clicking on the arrow in the right of the field and by selecting Simulink as in Figure 5 There is currently no input and output variable By selecting the arrow buttons in the top corners the number of input or output variables can be adjusted You can have any number including 0 but a reasonable upper limit is 10 If you want more than this it is better to use more than one interface block In our example we require two input variables and one output variables so ensure that the fields have the values 2 and 3 respectively The next stage is to get AMESim to create a specific icon for the interface The number of ports is now specified but it is also necessary to add a label to each port Hence we will add text to give a name to the variables In addition we will give a general name for the whole interface block Figure 5 shows text added in this way Select each field and type an Using the AMESim MATLAB Simulink Interface 10 appropriate text string Figure 5 Specifying the interface block Al Interface Icon Creation 24 x Common Number of inputs Type of interface Number of outputs 2 Simulink fi Bspeed gt Command Law Force wspeed gt Clear all text Note the three buttons labeled Clear all text OK and Cancel e Click on Cancel to abandon the process e Click on Clear all text to remove
2. This used to be a common problem but the solution has been partially automated and fortunately now is much rarer Versions Matlab r11 r12 and r13 under Unix Linux and Windows Situation e A Simulink model containing the S Function corresponding to an AMESim model DLL mexsol is opened The first simulation in Simulink works fine e When running a new simulation the following error message mdIInitializeConditions is systematically displayed Block error S Function cosim S Simulink Error in block Error in block cosim S Function while executing C MEX S function cosim_ mdlintializeCondtions at time 0 MATLAB error message In AMESim mexfunction cosim_ AMESim error Fatal error EXIT Solutions Under most circumstances it is necessary to force Simulink to reload the AMESim model for each new simulation To avoid any problem it is recommended that this is done always One way to achieve this is to clear the AMESim mex function from Matlab memory before starting a new simulation This can be done in three ways manually or 27 Using the AMESim MATLAB Simulink Interface 28 automatically e The manual way is to type clear mex or clear xxxx_ where xxxx is the AMESim system name This needs to be done before each new simulation starts or after each simulation e In Simulink version 2 and higher it is possible to specify a command to be executed after each simulation Taki
3. User Manual HHHEHHHRA EHH HEE THHH RATHER HH HERRERA EHH HER EHH HEATH HERE This file specifies the AMESim export facility to Simulink The entries are as follows the template to use for an explicit system the template to use for an implicit system the makefile to use the button title the script file to launch the companion software OB WNP sh oth th oth oh OE Ot Ht HE H OH AERAR AAHH HH HERE HH ARE H HERP HEATH HH ERE HH AEH HERE SAME 1ib imulink etemp NULL SAME 1ib simulink make Simulink nInterface SAME 1ib simulink launch The lines beginning with are comments The line that all local configurations needs to change is the 3rd non comment line currently reading SAME ib simulink make This is the name of a file with instructions on how to create the Simulink S Function If you want AMESim to use your local configuration change this line to simulink make for instance In the standard distribution this file 4 ME lib simulink make contains two lines as in Using Unix AME lib amemex c g IS AME lib AME 1lib amemex Using Windows CC c g DWIN32 I MATLAB extern include 1I MATLAB simulink include AME 1lib amemex The first line is the command for compiling the AMESim generated C file This system is dependent and may therefore be different on your installation The second line specifies the comman
4. O AMERun 4 0 2 O AMERun 4 0 3 O AMERun 4 1 O AMESet all O AMESet 4 0 O AMESet 4 0 1 O AMESet 4 0 2 O AMESet 4 0 3 O AMESet 4 1 O AMECustom all O AMECustom 4 0 O AMECustom 4 0 1 O AMECustom 4 0 2 O AMECustom 4 0 3 O AMECustom 4 1 Web Site http www amesim com FRANCE ITALY SWITZERLAND SPAIN PORTUGAL BENELUX SCANDINAVIA IMAGINE s a 5 rue Brison 42300 ROANNE FRANCE Tel from France 04 77 23 60 30 Tel international 33 0 4 77 23 60 37 Fax 33 0 4 77 23 60 31 E mail hotline amesim com IMAGINE Park Farm Technology Centre Kirtlington Oxfordshire OX5 3JQ ENGLAND Tel 44 0 1869 351 994 Fax 44 0 1869 351 302 E mail support uk amesim com USA CANADA MEXICO IMAGINE Software Inc 44191 Plymouth Oaks Blvd Suite 900 PLYMOUTH MI 48170 USA Tel 1 734 207 5557 Fax 1 734 207 0117 E Mail support us amesim com GERMANY AUSTRIA IMAGINE software GmbH Elsenheimerstr 15 D 80687 Miinchen DEUTSCHLAND Tel 49 0 89 548495 35 Fax 49 0 89 548495 11 E Mail hotline germany amesim com JAPAN IMAGINE JAPAN K K Satokura Akenobonashi Bldg 2F 1 19 Sumiyoshi cho Shinjuku ku 162 0065 TOKYO JAPAN Tel 81 0 3 3351 9691 Fax 81 0 3 3351 9692 E mail imagine japan amesim com MATLAB Simulink interface 4 2 User Manual SOUTH KOREA SHINHO Systems Co Ltd 702 Ssyongyong IT Twin Tower 442 5
5. a simulation The integra tors used in AME are robust but no integrator can claim to be perfectly reliable From the view point of an integrator models vary enormously in their difficulty Usually when there is a problem it is because the equations being solved are badly conditioned This means that the solution is ill defined It is possible to write down sets of equations that have no solution In such circumstances it is not surprising that the integrator is unsuccessful Other sets of equations have very clearly defined solutions Between these extremes there is a whole spectrum of problems Some of these will be the mar ginal problems for the integrator If computers were able to do exact arithmetic with real numbers these marginal prob lems would not create any difficulties Unfortunately computers do real arithmetic to a limited accuracy and hence there will be times when the integrator will be forced to give up Simulation is a skill which has to be learnt slowly An experienced person will be aware that certain situations can create difficulties Thus very small hydraulic vol umes and very small masses subject to large forces can cause problems The State count facility can be useful in identifying the cause of a slow simulation An eigenval ue analysis can also be useful The author remembers spending many hours trying to understand why a simulation failed Eventually he discovered that he had mistyped a parameter A hydraulic motor si
6. are automatically passed to the S function by Simulink Extra parameters may be specified in the S function parameters field Parameters S function name fskyhookcosim_ S function parameters 0 01 0 001 1e Cancel Help Apply The list of parameters of the S Function is shown in the following table Note that if we want to set a value for the 4th parameter it is necessary to give a value to all parameters before this one 20 MATLAB Simulink interface 4 2 User Manual Parameter Description Default value Sample time Time between exchange of values between AMESim and Simulink Required no default value AMESim communication As in AMESim Required no default value interval Tolerance the same as in the AMESim run parameters 1 0e 5 popup Max time step the same as in the AMESim run parameters 1 0e20 s popup Time range Helps DASSL to decide initialize the time step 100 s do not change Show run statistics Oor 1 1 for displaying run ae 1 statistics Extra discontinuity points 0 or 1 1 for extra 0 discontinuity printouts Output details 0 or 1 1 for output of time on screen not useful on 0 PC The chosen sample time is on purpose chosen fairly large in this example to make the effects of the sampling more obvious The chosen sample time is for this case the maximal sampling time possible to use The damping force calcu
7. s 0 1 output at start of stage 2 null 0 1 UDOO output at end of stage 2 null 0 1 duration of stage 2 s 3 When you change from Parameter mode to Run mode special data files containing the parameters are written When you run the S Function within Simulink these files will be read Hence when you change any parameters ensure you enter the Run mode If not your changes will not be seen by Simulink At this point you are ready to run the AMESim model within Simulink In order to start Simulink you have two possibilities e Inthe normal way from a suitable shell window Unix or by double clicking on its associated icon Windows If you do this you must ensure that the Matlab Current Directory is set to the directory where the AMESim model is stored A browser button can help you for this Current Directory paMeTest x Ri e Alternatively you can use the Tools gt Start Matlab menu from AMESim In this case the Matlab Current Directory is automatically set to the directory where the AMESim model is stored Importing the model into Simulink The AMESim model at this stage exists as an S Function It must be imported into Simulink Remember that when you quit AMESim the files defining your system are compressed into a single file This means that Simulink would not have access to the S Function For this reason it is normal to have AMESim and Simulink running simultaneously when using the interface This w
8. submodels win32 LC01 obj p amesim v4 1 0 submodels win32 UDO00 obj PAME Sim v4 1 0 Mlib win32 4ME lib user32 lib netapi32 lib adyapi32 lib gdi32 lib comdlg32 lib cometl32 lib System build completed 4 Next change to Parameter mode Normally AMESim would create an executable program that you would start in Run mode However because the system contains Simulink interface blocks an S Function is created The normal System Compilation window should appear as in Figure 7 and the Parameter mode should be entered If any error occurs it is likely that the MATLAB environment variable is not properly set In this case save the system exit from AMESim and carry out the instruction for setting this variable as described in section 2 Enter new parameters for the components to values shown in the table below leave all other parameters at their default values Submodel Name on Title Value sketch if any mass kg 400 MAS002 Body mass inclination 90 port 1 lowest 90 90 port 1 highest degree SPROOOA spring rate N m 15000 spring force with both 400 9 81 displacements zero N mass kg 40 MAS002 Wheel mass inclination 90 port 1 lowest 90 90 port highest degree SPROOO0A Tire stiffness spring rate N m 200000 spring force with both 440 9 81 displacements zero N 11 Using the AMESim MATLAB Simulink Interface 12 duration of stage 1
9. the ones most suitable Set the stop time to 5 seconds this will be quite enough to produce some interesting results Initiate the Simulink run and watch the output from the Scope block This will give the input force supplied to the car suspension as shown in Figure 13 Force in Simulink Figure 13 Force in Simulink Scope 48 P22 4BB G45 Time offset 0 Notice that after starting the first run from Simulink the appearance of the S Function icon is slightly altered the name of the ports are added If you want to see these names more 16 MATLAB Simulink interface 4 2 User Manual clearly you must adjust the size of this icon Function Figure 14 shows the same quantity plotted within AMESim If you chose to generate an AMESim result file it is possible from within AMESim to access the full range of variables of the AMESim model These can be plotted as from a normal AMESim simulation Figure 15 shows the body and wheel displacements Figure 14 Force in AMESim x10 Figure 15 Body and wheel displacements 1 Body displacement port 1 m 2 Wheel displacement port 1 m Co simulation interface Two possibilities are offered to create an interface with Simulink the standard interface and the co simulation interface Here we will explain what the differences are between the two and describe how to use the co simulation interface 17 Using the AMESim MATLAB Simulink Interface 5 1 18 Int
10. 3 line is if your submodels use user written utilities or other non standard files or libraries this would typically be a change that you would do locally For instance if you would like to include a library called myfuncs lib which is stored in C home my_name library add the following line link libpath C home my_name library myfuncs lib or c home my_name library myfuncs 1lib Each AMESim model remembers which simulink conf was specified when it was created This means that for any new simulation the corresponding simulink make will be used Hence it is necessary to rebuild the special icon created for the AMESim Simulink interface if you wish your model to use a different simulink make MATLAB Simulink interface 4 2 User Manual Constructing the model in AMESim Figure 1 The model in AMESim The process of constructing the AMESim model is described with the help of a simple example You will understand the process better if you create and run the system yourself The exercise can be completed within about an hour Create the system shown in Figure 1 The model in AMESim calling it skyhook It consists of two masses connected with a spring which represent a quarter car suspension Note Two transducers determine the positions of the wheel and the car body e Connected to the wheel is a spring to which the road profile is applied Using the AMESim MATLAB Simulink Interface e The system is inco
11. MATLAB Simulink interface Version 4 2 September 2004 IMAGINE Copyright IMAGINE S A 1995 2004 AMESim is the registered trademark of IMAGINE S A AMESet is the registered trademark of IMAGINE S A ADAMS is a registered United States trademark of Mechanical Dynamics Incorpo rated ADAMS Solver and ADAMS View are trademarks of Mechanical Dynamics Incorporated MATLAB and SIMULINK are registered trademarks of the Math Works Inc Netscape and Netscape Navigator are registered trademarks of Netscape Communi cations Corporation in the United States and other countries Netscape s logos and Netscape product and service names are also trademarks of Netscape Communications Corporation which may be registered in other countries PostScript is a trademark of Adobe Systems Inc UNIX is a registered trademark in the United States and other countries exclusively licensed by X Open Company Ltd Windows Windows NT Windows 2000 Windows XP and Visual C are regis tered trademarks of the Microsoft Corporation The GNU Compiler Collection GCC is a product of the Free Software Foundation See the GNU General Public License terms and conditions for copying distribution and modification in the license file X windows is a trademark of the Massachusetts Institute of Technology All other product names are trademarks or registered trademarks of their respective companies MATLAB Simulink interface 4 2 User Manu
12. MESim run a print interval is specified whereby the size of the results file can be controlled Simulink runs in a somewhat different way and consequently the AMESim result files can become unacceptably large To prevent this from occurring a special AMESim print interval is specified in the S Function The data added to the AMESim results file will be spaced with a time interval not less than this value The first parameter indicates whether an AMESim results file is to be created A value of 1 indicates it is to be created and any other number indicates it is not to be created e The second parameter indicates the special print interval If a zero or negative value is entered Simulink will add to the AMESim results file whenever it adds to its own results Add the values shown in Figure 9 so that there will be an AMESim results file but with a print interval restriction of 0 01 s Complete the system as shown in Figure 10 Note that there are gain blocks as well as summing junctions The outputs from the S Function are passed through the Demux block to split the output array from AMESim to form the two outputs Bspeed and Wspeed Users of previous versions of the AMESim Simulink interface should notice that the output dealing with discontinuities has been removed The discontinuities are now dealt 13 Using the AMESim MATLAB Simulink Interface with internally in the S Function Figure 10 The system ready to run s
13. Sangdaewon dong Jungwon gu Seongnam si Gyeonggi SOUTH KOREA lt 462 723 gt Tel 82 31 608 0434 Fax 82 31 608 0439 E Mail iclee shinho systems co kr BRAZIL KEOHPS Ltd CELTA Pare Tec ALFA Rod SC 401 km 01 CEP 88030 000 FLORIANOPOLIS SC BRAZIL Tel 55 48 239 2281 Fax 55 48 239 2282 E Mail info keohps com HUNGARY Budapest University of Technology amp Economics Department of Fluid Mechanics H 1111 BUDAPEST Bertalan L u 4 6 HUNGARY Tel 36 1 463 4072 463 2464 Fax 36 1 463 3464 E Mail vad simba ara bme hu CHINA United Right Technology Room 716 717 North Office Tower Beijing New World Center No 3 B Chong Wen MenWai dajie BEIJING 100062 P R CHINA Tel 86 10 67082450 52 53 54 Fax 86 10 67082449 E Mail urt urtgroup com
14. al Table of contents Using the AMESim MATLAB Simulink Interface 1 1 IntroductiON 2 24 4 0sa os Rha tReet Oh EEE he OE eb REE Seas 1 2 Preliminaries ro nonn in sho te ee ed Se wien aS ye SEE 2 2 1 C compiler requirements2 2 2 Supported versions of Simulink 0000 c eee 3 2 3 Setting up the environment 0 0 cee cette eee 3 2 4 Configuration files ccis c c4e8 vig deck hig ee sie cad ead pees each 5 3 Constructing the model in AMESim 0 00 cee cece eee 7 4 Importing the model into Simulink 0 0 00 c ee eee eee 12 5 Co simulation interface 0 eee eee nes 17 5 1 Introduction18 5 2 Usage of the co simulation interface 00 00 00 0 eee ee eee 19 6 Using more than one interface block 000 c eee eee 24 7 Concluding remarks and FAQS 0 cee cece eee eee 25 7 1 Concluding remarks25 7 2 Common problems and their solutions 0 000020 eee 26 Compilation failure with a Line too long error message 26 Compilation window is blocked during the first use of the interface 26 Not possible to run sequential simulations 04 27 Table of contents MATLAB Simulink interface 4 2 User Manual Using the AMESim MATLAB Simulink Interface 1 Introduction The AMESim MATLAB Simulink interface enables you to construct a model of a subsystem in AMESim and to convert it to a Simulink S Functio
15. any text you have entered e Click on OK to obtain the icon produced by AMESim An icon similar to that shown in Figure 6 will appear Note the port position is denoted by gt Figure 6 The completed interface block Bspeed Command Wespeed Force gt The pointer will take on the appearance of the icon and can be treated like a normal AMESim component icon Thus it can be mirrored rotated deleted or added to system sketch All AMESim interface blocks have signal type ports Connect the block inputs and output to the other components of the model as shown in Figure 2 It is worth mentioning 2 important points e You can have more than one interface block but if you do they must all be of the same type all Simulink standard interface blocks in the current example e the AMESim model must be explicit i e there cannot be any implicit variables unless the co simulation interface is used MATLAB Simulink interface 4 2 User Manual Change now to Submodel mode The interface block will automatically be associated with a special submodel and you are not allowed to change these For the other submodels select Premier submodel so as to get the simplest submodels Figure 7 Compilation to create the S Function System Compilation skyhook 21x Creating a simulation program for your system Number of states 5 Terminated Number of implicits 0 Messages p amesim v4 1 0 submodels win324S PLT 0 obj p amesimv4 1 O0
16. ate there is a loss of information Figure 16 The two AMESim Simulink interfaces exchange of information State derivatives AMESim Simulink tem subsystem Oumut variables subsystem uput varia es yt solver Input variables lt State variables Normal interface AMESim Simulink subsystem f subsystem solver Output variables p solver t Input variables Co simulation interface This can be compared with the difference between a continuous and a sampled controller Normally the smaller sample rate used the closer to the continuous result we get Another possible problem is that the we loose information about possible cross couplings between the system since we do not communicate information about states and state derivatives 5 2 MATLAB Simulink interface 4 2 User Manual All these factors mean that co simulation can be difficult to set up if the two separate systems are continuous You should in that case try to find an interface between the systems where the coupling is as weak as possible The obvious situation where co simulation may be used is of course when the interface between the system is sampled for instance when using a sampled controller Usage of the co simulation interface We will reuse the AMESim system created earlier Figure 1 The model in AMESim Save the system as skyhookcosim Now we add the interface block The process is similar to the process creating the stan
17. ay you can change the parameters in the AMESim model and restart the simulation very rapidly You can also examine the results in AMESim Another mode of working is to quit AMESim but then to type in a terminal Unix or DOS Windows window AMELoad skyhook to expand the single file into its constituent parts Simulink will then have access to all the files it needs For the rest of this exercise it will be assumed you employ the first mode of working Figure 8 The S Function in Simulink S Function MATLAB Simulink interface 4 2 User Manual From within Simulink select the S Function block Figure 8 and add it to the display area then set the parameters as shown in Figure 9 The name of the S Function is skyhook_ i e the name of the system with an _ added This name must be entered in the first box In the input box below this two parameters must be entered These are used to specify the characteristics of the AMESim result files Figure 9 The S Function parameters Block Parameters S Function x m Function User definable block Blocks may be written in M C Fortran or Ada and must conform to S function standards t x u and flag are automatically passed to the S function by Simulink Extra parameters may be specified in the S function parameters field m Parameters S function name skyhook_ S function parameters fi 0 01 OK Cancel Help Apply With a normal A
18. b type matlab for some versions of Bourne shells This will tell you the location of your version of MATLAB e g opt matlabr13 bin matlab Remove the last two parts from this pathname to get the value to set for MATLAB_ ROOT in this case opt matlabr13 If you are using the Unix C shell you can then set the environment variable as follows setenv MATLAB ROOT opt matlabr13 This statement can also be added to your cshrc file so that the environment variable is set every time you login For Bourne or Korn shells the corresponding would be MATLAB ROOT opt matlabr1i3 export MATLAB ROOT Add these statements to your profile file so that the environment variable is set every time you login Using the AMESim MATLAB Simulink Interface 2 4 Using Windows echo SMATLABS This should result in something like C MATLAB6p5 being printed on screen If the environment variable is not set MATLAB is printed and you need to set the MATLAB environment variable to point to the MATLAB installation directory This can be done from the Windows Control Panel Another important point is that your path must contain the directory Swindir s System32 where windir is the Windows installation directory a typical value for Y windir is C WINNT You can check the content of your path by typing the command below and you can change it from the Windows Control Panel echo Path Configuration files This section is i
19. d used for creating the Simulink mex S Function This is a small shell script amemex that runs the MATLAB utility mex All arguments are passed on to mex By modifying amemex more advanced customizations can be made than Using the AMESim MATLAB Simulink Interface are possible using lines 1 and 3 in simulink make Using Unix If your model includes Fortran code simulink make probably needs to be altered by 3rd adding a 3 line specifying the additional libraries needed An example on such a line is L opt SUNWspro SC3 0 1 lib 1F77 lsunmath This is highly system dependent and you probably need to ask your system administrator for the libraries used on your computer If many users are using Fortran it is probably a good idea to let your system administrator change the simulink make in the standard area SAME lib simulink make Another reason to add a 3 line is if your submodels use user written utilities or other non standard files or libraries this would typically be a change that you would do locally For instance if you would like to include a library called ibmyfuncs a which is stored in home my_name library add the following line L home my_name library lmyfuncs If there already is a 34 line in simulink make for instance for using Fortran add your files at the beginning of the line as in L home my_name library lmyfuncs L opt SUNWspro SC3 0 1 lib 1F77 lsunmath Using Windows A reason to add a
20. dard Simulink interface except that we select SimulCosim in the field labeled Type of interface instead of Simulink See Figure 17 Figure 17 Creating the icon for co simulation A Interface Icon Creation 2 x Common Number of inputs Type of interface Number of outputs 2 SimuCosim 7 fi Bspeed gt Command Law Force n Wspeed gt Clear all text Go into Parameter mode and then Run mode Next we create the Simulink system as shown in Figure 18 Simulink model Co simulation We use the same basic system as before with the difference that the name of the S Function is now skyhookcosim_ 19 Using the AMESim MATLAB Simulink Interface In Simulink the only difference is the number and type of parameters of the S Function Figure 18 Simulink model Co simulation E skyhookcosim Iof x File Edit View Simulation Format Tools Help DISES teel 2e amten Body velocity Damper force S Function Transfer Fen p Wheel velocity poz I be A Looking at the parameters for the S Function as shown in Figure 19 we can see that more than two parameters are used However it is possible to give it only two parameters in that case the other parameters will get default values Figure 19 The S Function Parameters Block Parameters S Function S Function User definable block Blocks may be written in M C Fortran or Ada and must conform to S function standards t x u and flag
21. inaries 2 1 C compiler requirements If you work on a UNIX or Linux platform you will need an ANSI C Compiler that is supported by Simulink for creating S Functions If you work on a PC with Windows NT Windows 2000 or Windows XP you must use Microsoft Visual C since it is the only compiler that can generate S Functions for Simulink The GNU gcc compiler supplied with AMESim cannot be used 2 2 2 3 MATLAB Simulink interface 4 2 User Manual Supported versions of Simulink MATLAB AMESim 6 1 112 1 6 5 r13 Simulink 4 1 Simulink 5 0 4 1 Yes Yes 4 2 Yes Yes Setting up the environment In order to use the AMESim MATLAB Simulink interface it is necessary to set an environment variable that points out the MATLAB installation directory If this is not set AMESim will not be able to find the files necessary to create S Functions To find out if this environment variable is set type the following line in a terminal window Using Unix echo SMATLAB ROOT This should result in something like opt matlabri13 being printed on screen If nothing is printed or the message MATLAB ROOT Undefined variable is displayed you must set this variable To do this you need to know where MATLAB is installed If your working environment is set up properly to run MATLAB type either if you are using Cshell or if you are using Korn shell ksh or Bourne shell sh or which matlab whence matla
22. ing has been removed For systems using the co simulation interface it is important to think of the following e Remember that the AMESim block is seen as a discrete block from Simulink e The parameters to the S Functions are as shown in the table in section 5 2 Usage of the co simulation interface and they are not the same as the parameters for the standard interface 25 Using the AMESim MATLAB Simulink Interface Common problems and their solutions 7 2 Compilation failure with a Line too long error message Versions All Matlab versions under Windows Situation When compiling an AMESim system containing interface blocks the compilation fails and the following error message is displayed in the AVESim compilation window Line too long Furthermore the DLL file representing the S Function is not generated And when trying to run the simulation in Simulink an error message indicates that the S Function does not exist Solution Close the current AMESim session and login with Administrator privileges First check that the AME environment variable points to the AMESim installation directory Go to the MATLAB bin win32 mexopts directory where MATLAB is the Matlab installation directory Depending on the MS Visual C version you use copy the following file and paste it into the AME lib directory where AME is the AMESim installation directory for Visual C 5 copy msvc50opts bat f
23. kyhook Ioj x File Edit View Simulation Format Tools Help DSHS jpe Selam Sd Body velocity S Function moz Values of Gain and Gain I come from the car suspension example in Chapter 4 of the AMESim manual Why has the transfer function been inserted This is a consequence of the fact that the AMESim S Function is defined as having direct feed through This means that the outputs from the block may be directly dependent on the input For most realistic AMESim systems this is not true there are normally state variable s between input and output The way the S Function is created makes it necessary to specify that all systems have a direct feed through anyway The transfer function a first order lag that is inserted is required to break the algebraic loop that Simulink sees due to this direct feed through For the current system it can be regarded as the dynamics of the actuator that applies the damping force 14 MATLAB Simulink interface 4 2 User Manual Important note If your AMESim model has more than one input coming from Simulink the input signals to AMESim have their order reversed when compared to what is sent from Simulink This is due to the fact that AMESim numbers the ports in counter clockwise order while the Mux block in Simulink numbers them starting at the top The output side of the interface block is not affected by this since in this case the variables are numbered from the top in both software
24. lated by the Simulink model is shown in Figure 20 Force as calculated by Simulink using a sample time of 0 01s compare this with the force in Figure 13 Force in Simulink The stability of the system has gone 21 Using the AMESim MATLAB Simulink Interface down due to the sampled controller Figure 20 Force as calculated by Simulink using a sample time of 0 01s ja P22 ABE S45 8000 6000 4000 2000 0 2000 4000 6000 8000 0 Time offset 0 Looking more closely on the input to the AMESim system Figure 21 Detailed view of force input to AMESim model using sample time of 0 01s one clearly sees the time discrete nature of the force The sampled controller results in body and wheel displacements that are more oscillatory Figure 22 Body and wheel displacement with a sample time of 0 01s than with the continuous controller Figure 15 Body and wheel displacements By selecting a smaller sample time we can get a result that is more similar to the one we had with the standard interface continuous controller In Figure 23 Body and wheel displacement with a sample time of 0 001s and Figure 24 Actual input to the AMESim model using a sample interval of 0 001s the sample time is set to 0 001s and the 22 MATLAB Simulink interface 4 2 User Manual AMESim communication interval is set to 0 0002s Figure 21 Detailed view of force input to AMESim model using sample time of 0 01s 3 1 expseu 1 Force nu
25. ll x10 8 1 0 0 1 02 _ 1 3 0 4 0 5 Time s Figure 22 Body and wheel displacement with a sample time of 0 01s 1 MA5002 1 Body displacement m 2 MAS002 2 Wheel displacement m 0 18 0 15 0 12 0 09 0 06 0 03 0 0 03 0 06 0 09 0 1 2 _ a 4 5 Time s Figure 23 Body and wheel displacement with a sample time of 0 001s 3 1 expseu 1 Force null x10 6 1 3 0 3 6 0 1 2 3A 4 5 Time s 23 Using the AMESim MATLAB Simulink Interface Figure 24 Actual input to the AMESim model using a sample interval of 0 001s 1 MAS002 1 Body displacement m 2 MAS002 2 Wheel displacement m 0 18 0 14 0 1 0 06 0 02 0 02 0 06 6 Using more than one interface block iS press First press2 block Second signal2 gt signal3 gt 7 vel block signal4 P gt vell Interface Graphs Icons Tools Make sure you give each port a unique name Greate intertace icon When the S Function is created AMESim will concatenate Display interface status all the inputs and concatenate all the outputs To see how this Import linear model is done select Interface gt Display interface status A dialog box Figure 25 shows how the ports are arranged Import Adams madel Generate files for Real hime Simulink 24 MATLAB Simulink interface 4 2 User Manual Figure 25 Concatenated inputs and outputs A Interface status display 24 x Number of inputs a Ty
26. mplete with three ports unconnected Figure 2 The AMESim model with the interface block Bspeed Command Force gt 7 SPROOOA 1 ee eee baea J Skyhook suspension LCON13 2 Tire stiffness Road profile The force representing the damping in the suspension will be provided by Simulink and the output from the velocity transducers will be sent to Simulink To complete the system it is necessary to add a special interface icon Figure 2 shows this block added to the system Figure 3 First step in creating the interface icon Interface Graphs Icons Tools W Create interface icon Display interface status Import linear model Import Adams model Generate files for Real Time No interface blocks tn system To create the interface blocks click on the Interface pulldown menu shown in Figure 3 This menu is designed to be used with the Simulink interface and other interfaces but in our case it will be Simulink Select the item labeled Create interface icon This is used to define the variables which are provided and received by the companion software From AMESim these variables are seen as inputs and outputs respectively The dialog box MATLAB Simulink interface 4 2 User Manual shown in Figure 4 is produced Figure 4 Interface Icon Creation dialog box Fl Interface Icon Creation 21x Number of inputs Type of interface Number of outputs fo Adams x 0 paa Clear all text
27. n The S Function can then be imported into Simulink and used within a Simulink system just like any other S Function The interface is designed so that you can continue to use many of the AMESim facilities while the model is running in Simulink In particular you can change the parameters of the AMESim model within AMESim in the normal way examine the results within AMESim by creating plots just as if they were produced in a regular AMESim run Normally you will have AMESim and Simulink running simultaneously so that you can use the full facilities of both packages The process is illustrated below Construct the AMESim model as a S Function Modify the AMESim submodel parameters Complete the Simulink system Run the simulation Examine the AMESim Examine the Simulink control submodel results in AMESim system results in Simulink When the process is done the AMESim model parameters may be changed within AMESim as well as the Simulink parameters within Simulink A series of runs can be performed Typically a controller can be designed for the system Organization of this manual This manual describes both the standard interface using the Simulink integrator and the co simulation interface where integrators from both Simulink and AMESim are used The main part of the manual deals with the standard interface and Co simulation interface page 17 looks a
28. ng the Simulink system in Figure 10 The system ready to run as an example we can type set_param skyhook S Function StopFen clear skyhook_ at the Matlab command prompt This makes Simulink unload the AMESim mex function after each simulation and thus forcing it to be reloaded when a new simulation is run If the Java interface Matlab 6 or higher is used a menu item File gt Model properties exists in the Simulink menu bar that does the same thing as the set_param command In the Simulation stop function zone add the expression clear xxxx_ where xxxx is the AMESim system name Click on the Apply button Save the Simulink model so that modifications are definitely taken into account MATLAB Simulink interface 4 2 User Manual Reporting Bugs and using the Hotline Service AME is a large piece of software containing many hundreds of thousands of lines of code With software of this size it is inevitable that it contains some bugs Naturally we hope you do not encounter any of these but if you use AME extensively at some stage sooner or later you may find a problem Bugs may occur in the pre and post processing facilities of AMESim AMERun AMESet AMECustom or in one of the interfaces with other software Usually it is quite clear when you have encountered a bug of this type Bugs can also occur when running a simulation of a model Unfortunately it is not pos sible to say that for any model it is always possible to run
29. ntended to advanced users only It can be skipped at a first reading The configuration files for the AMESim Simulink interface supplied with a standard AMESim installation assumes that all functions are written in C and that no extra libraries with user written functions are needed If you write your submodels in Fortran or you use non standard libraries in your model some changes to the standard distribution files are needed These changes can as all AMESim configurations be performed in two ways globally for all users or locally for the current directory for a particular project The files that can be customized are simulink conf and simulink make They normally exist in the SAME ib or 4AME ib directory For global customization they should be edited there Your system administrator should normally handle this For local configuration copy these files to your project directory and make the necessary changes to these files AMESim looks in the current directory before looking in the standard area AME lib or AME lib any changes made to the local files will therefore override the global configuration The file simulink conf contains instructions on which files are to be used to create the S Function for Simulink This means that if you decide to make any local configurations this file must be edited otherwise the global configuration will be used The standard simulink conf is shown in the following frame MATLAB Simulink interface 4 2
30. or Visual C 6 copy msvc60opts bat and for Visual NET copy msvc70opts bat Go to the AME lib directory Drag the msvc opts bat file and drop it onto the install_big_simulink_interface exe file one file is generated mexopts bat and one file is modified simulink make Logout and login with your user account Launch AMESim and re compile the system Compilation window is blocked during the first use of the interface 26 Versions All Matlab versions under Windows Situation The AMESim Simulink interface is used for the first time When compiling the AMESim system with Simulink blocks the compilation window in AMESim seems to be blocked and the following pieces of information are displayed MATLAB Simulink interface 4 2 User Manual Select a compiler 1 Digital Visual Fortran version 6 0 in C Program Files Microsoft Visual Studio 2 Lec C version 2 4 in C MATLAB6P35 sys Icc 3 Microsoft Visual C C version 6 0 in C Program Files Microsoft Visual Studio 0 None Solution AMESim is waiting for the user to select a compiler e Right click at the bottom of the compilation window e A menu labeled Interactive compilation appears e Select this menu a blank field appears at the bottom of the compilation window Type the index corresponding to the Microsoft Visual C compiler in this field 3 in this example and hit the Enter key e The compilation starts Not possible to run sequential simulations
31. pe of interface Number of outputs Simulink X j 4 press expseu press2 expseu vell expseu vel expseu e w N i d No Title Submodel Instance No Title Submodel instance A w N signall expseu signal4 expseu signal3 expseu signal expseu i i d j Cancel 7 Concluding remarks and FAQs 7 1 Concluding remarks This manual has presented a simple example to introduce the use of the Simulink interface Before you start developing your own models we now summarize the most important points Ifyou work ona PC with Windows NT Windows 2000 or Windows XP you must use Microsoft Visual C since it is the only compiler that can generate S Functions for Simulink The GNU gcc compiler supplied with AMESim cannot be used The input of the interface block in AMESim has its ports in reverse order compared with Simulink e Remember to change from Parameters to Run mode in AMESim before running the simulation in Simulink or to use File gt Write aux files e For systems using the standard Simulink interface the following points are important The AMESim model must be explicit i e there cannot be any implicit variables The reason for this is that the Simulink integrators can handle only ordinary differential equations e Users of previous versions of the AMESim Simulink interface should notice that the output dealing with discontinuities Hit Cross
32. roduction The main difference between the two interfaces is that co simulation interface uses two or more solvers while the standard interface uses only one This means that AMESim and Simulink use their own solver for the co simulation interface whereas they both use the Simulink solver for the standard interface Another difference is that with the standard interface the AMESim part is seen as a time continuous block in Simulink and in the co simulation it is a time discrete block Since the co simulation block is seen as a discrete block it makes this interface very suitable for discrete controllers implemented in Simulink controlling an AMESim model The figure below shows in more detail how the interfaces work In the standard interface the AMESim part of the system gets state variables and input variables from Simulink and calculates state derivatives and output variables The process of exchanging this information is controlled entirely by the Simulink solver In this case one could say that we import the equations into Simulink In the co simulation case the only exchanged variables are the input and output variables The rate of exchange is in this case decided by a parameter that the user decides As the name indicates the model is not entirely in the hands of one software Simulink but it is a co operation between two or more software It is important to realize that by exchanging only input and output variables at a certain sample r
33. s This can be seen by comparing the model in AMESim and Simulink as shown in the figures below Figure 11 Order of inputs and outputs Another Inputi D t Ditut Command Input2 gt Output2 Law Input3 Scope for output Output AMESiIm multi_inputs_ Output2 S Function Scopefor Output2 Input Next set the simulation parameters to the values shown in Figure 12 Remember that AMESim systems can be numerically stiff this is particularly true for hydraulic and HCD systems This means that some of the time constants are very small and there can be very fast dynamics For this reason the only integration methods likely to succeed are the ones that are specially designed for this 15 Using the AMESim MATLAB Simulink Interface Figure 12 Setting the simulation parameters Simulation Parameters skyhook e x Solver Workspace o Diagnostics Advanced Real Time Workshop Simulation time Start time 0 0 Stop time 5 0 Solver options Type Variable step ode1 5s stiff NDF 7 Max step size auto Relative tolerance 1e 3 Min step size auto Absolute tolerance 1e 6 Initial step size auto Maximum order 5 Y Output options Refine output 7 Refine factor 1 In Simulink it seems that both solvers for stiff systems are possible to use for AMESim models In this particular case use the ode 15s stiff NDF method in older versions Gear and Adams Gear were
34. t the differences between the standard and the co simulation Using the AMESim MATLAB Simulink Interface interface The structure of this manual is the following e Section 2 describes how you must set your working environment so that you can use the interface e Section 3 describes with a simple example how the AMESim submodel is created and converted to an S Function e Section 4 describes how the AMESim model is imported into and run within Simulink e Section 5 describes the differences between the co simulation interface and the standard interface e Section 6 shows how to use more than one interface block in an AMESim model e Section 7 gives a summary of the most important things to remember as well as as the answers to the most frequently asked questions FAQ e Sometimes a section of text is only applicable to a UNIX or Linux environment For such text the following presentation is used Using Unix Description for Unix Linux environments e Sometimes a section of text is only applicable to a Windows environment For such text the following presentation is used Using Windows Description for Windows environments Note that a collection of utilities also exists for MATLAB so as to import export data to and from AMESim These are documented in chapter 7 of the main AMESim manual It is assumed that the reader of this manual is already familiar with AMESim MATLAB and Simulink 2 Prelim
35. ze had been entered making the unit about as big as an ocean liner When this pa rameter was corrected the simulation ran fine It follows that you must spend some time investigating why a simulation runs slowly or fails completely However it is possible that you have discovered a bug in an AMESim submodel or utility If this is the case we would like to know about it By reporting problems you can help us make the product better On the next page is a form When you wish to report a bug please photocopy this form and fill the copy You telephone us having the filled form in front of you means you have the information we need Similarly include the information in an email To report the bug you have three options e reproduce the same information as an email e telephone the details e fax the form Use the email address telephone number or fax number of your local distributor HOTLINE REPORT Creation date Company Keywords at least one MATLAB Simulink interface 4 2 Created by Contact O Improvement User Manual O Other Problem type O Bug Summary Description Involved operating system s O All O Unix all O HP O IBM O SGI O SUN O Other Involved software version s O All O PC all O Windows 2000 O Windows NT O Windows XP O Linux O Other O AMESim all O AMESim 4 0 O AMESim 4 0 1 O AMESim 4 0 2 O AMESim 4 0 3 O AMESim 4 1 O AMERun all O AMERun 4 0 O AMERun 4 0 1

Download Pdf Manuals

image

Related Search

Related Contents

Conair NE163ACS User's Manual  先行手摺【セーフティーレール】  CARBOMAX II  ダウンロード  Hotpoint 9.8LTI User's Manual  MANUAL SISTOR 82 IT  Micro Innovations KB565BL User's Manual  Fitness Module - Bio Analogics  MoProSoft 1.3  DISEÑO DE LÍNEAS DE TRANSMISIÓN AÉREA  

Copyright © All rights reserved.
Failed to retrieve file