amesim simulink联合仿真

合集下载

AMESim与Simulink联合仿真设置步骤与实例

AMESim与Simulink联合仿真设置步骤与实例

1. 联合仿真环境设置:软件环境:AMESimR10VC++6.0MA TLAB/Simulink2010a1.将VC++中的"vcvar32.bat"文件从Microsoft Visual C++目录(通常是. \Microsoft Visual Studio\VC98\Bin中)拷贝至AMESim目录下。

2.环境变量确认:1) 选择“控制面板-系统”或者在“我的电脑”图标上点右键,选择“属性”;在弹出的“系统属性”窗口中选择“高级”页,选择“环境变量”;2) 在弹出的“环境变量”窗口中找到系统变量“AME”,它的值就是你所安装AMESim的路径,选中改环境变量;比如AMESim10安装目录(即AMESim10安装文件的存储目录)是:C:\AMESim\v1000(D:\AMESim就是错误的),那么“AME”的值就是C:\AMESim\v1000, 点击“确认”按键,该变量就会加到系统中;3) 按上述步骤设置系统变量“MATLAB”,该值为MA TLAB文件所安装的路径,例如Matlab 2010a按照文件的存储路径为:D:\Program Files\MATLAB\R2011a,那么“MA TLAB”的值就是D:\Program Files\MATLAB\R2010a,点击“确认”按键,该变量就会加到系统中;4) 同样的方式定义系统变量LM_LICENSE_FILE,值为C:\AMESim\v1000\licensing\license.dat,值就是AMESim软件许可文件的存储路径。

即LM_LICENSE_FILE=C:\AMESim\v1000\licensing\license.dat。

3. 在AMESim中选择VC作为编译器。

具体操作在AMESim->Opions-> AMESimPreferences->Compilation中;进去后选择Microsoft Visual C++项,然后点击OK确认。

基于AMESim和Simulink联合仿真的定量泵-变量马达系统转速控制研究

基于AMESim和Simulink联合仿真的定量泵-变量马达系统转速控制研究

基于AMESim和Simulink联合仿真的定量泵-变量马达系
统转速控制研究
邬凯;陈朋威
【期刊名称】《价值工程》
【年(卷),期】2024(43)9
【摘要】本文使用了AMESim和Simulink软件构建了定量泵-变量马达系统仿真模型,用于定量泵-变量马达系统的分析,并采用Simulink为主的联合仿真方法。

进行了PID和模糊PID两种控制策略的比较研究。

结果表明,与传统PID控制相比,模糊PID控制策略在系统响应时间和稳定性方面表现更出色,尤其在恒转速控制方面表现更佳。

【总页数】4页(P136-139)
【作者】邬凯;陈朋威
【作者单位】陕西工业职业技术学院机械工程学院;复合型移动机器人陕西省高校工程研究中心
【正文语种】中文
【中图分类】TH137
【相关文献】
1.基于AMESim/Simulink的轮式两栖车静压行驶驱动系统马达同步控制联合仿真研究
2.基于AMESim和Simulink联合仿真的阀控马达转速控制
3.变转速输入定
量泵-恒转速输出变量马达系统恒转速控制方法研究4.基于AMESim和Simulink 联合仿真的马达转速自适应控制
因版权原因,仅展示原文概要,查看原文内容请购买。

Simulink_modelsim联合仿真

Simulink_modelsim联合仿真

simulink/modelsim联合仿真XX学生的师傅2016年5月13日Simulink/Modelsim 联合仿真操作步骤本人使用的matlab版本为:matlab R2014a ; modelsim版本为:Modelsim SE-64 10.1c。

以下内容是参考自matlab帮助文档,结合自己第一次联合仿真的经验得出,如有不到之处,不能帮助解决问题还请原谅。

第一次使用markdown,如阅读体验不好,你咬我啊以下正文1.新建目录2.在matlab中配置cosimulation block1.在matlab中运行cosimWizard。

2.按要求配置。

3.在simulink或matlab中搭建仿真模型4.从matlab或simulink中启动modelsim两种方法:•在matlab中运行vism或vism('socketsimulink'),4449 ,其中4449为端口号,根据实际情况确定。

之后需在modelsim中加载verilog文件,并输入vsimulink work.uq_pmsm ,其中uq_pmsm为实体名,根据实际情况替换。

•双击simulink中的Launch HDL Simulator块启动modelsim。

以下两种情况: - 方法一启动实体仿真、方法二modelsim加载实体完成后,若一直显示loading。

- 直接在simulink中运行仿真时出现错误,提示change port。

可进入任务管理器结束lmutil.exe进程。

黑科技,不确保有效。

5.在simulink中启动仿真,此时modelsim会同步进行仿真。

AMEsim与Matlab_simulink联合仿真技术

AMEsim与Matlab_simulink联合仿真技术

目录摘要 (1)0 引言 (1)1 联合仿真技术 (2)1.1 联合仿真技术的特点与应用 (2)1.2 联合仿真技术的实现途径 (2)2 联合仿真接口技术 (3)2.1 系统环境配置 (3)2.2 系统编译器配置 (3)3 联合仿真应用举例 (5)4 结论 (8)致谢 (8)参考文献 (9)AMESim与Matlab_Simulink联合仿真技术机械电子系0802班李敏M200870228摘要:根据AMESim与Matlab/Simulink软件各自的特点,对两者联合仿真技术进行了研究,解决了联合仿真的接口与实现问题,并把该技术应用于电液位置伺服系统的仿真,取得了良好的效果。

关键词:AMESim;Matlab/Simulink;联合仿真;接口Abstract:United Matlab/Simulink technique with AMESim and Matlab/Simulink was discussed based on their own characteristics. The problem of their interface and realization were solved. As an applied example, Matlab/Simulink of electro hydraulic servo-system was shown. Good results were achieved.Keywords:AMESim;Matlab/Simulink;United simulation;Interface0 引言传统的设计方法往往是通过反复的样品试制和试验来分析该系统是否达到设计要求,结果造成大量的人力和物力投入在样品的试制和试验上。

随着计算机仿真技术的发展,在工程系统的软件设计开发中,大量地采用了数值成型的方法,即通过建立系统的数值模型,利用计算机仿真使得大量的产品设计缺陷在物理成型之前就得到了处理,从而可以使企业在最短的时间、以最低的成本将新产品投放到市场。

基于AMESim和Simulink的起升机构速度控制仿真

基于AMESim和Simulink的起升机构速度控制仿真

起 重 机 械 中 具 有 重 要 地 位 。 性 能 的 优 劣 , 接 影 响 起 重 其 直
机 械 的工 作性 能 。 起 升 机 构 的 作 用 是 实 现 重 物 的 升 降 运 动 .控 制 重 物 的升 降 速 度 , 以 使 重 物 停 留 在 空 中 某 一 位 置 . 便 进 行 可 以 装 卸和 安 装作 业 。 升 机构 的传动 方式 包括 机械 传 动 、 起 电
【 sr c Ab ta t】T ep i il o y rui s se o osigme h ns wa n l e h y a i d l n C h r cpe f da l y t m fh i n c a im sa a z d T ed n m c mo e a dE U n h c t y s
中 图 分 类 号 : 1 . U4 55
文献 标 志码 : B
文 章 编 号 : 0 0 0 3 2 1 )3 0 1 0 1 0 — 3 X( 0 1 0 -0 7 - 4
0 引 言
为 了完成 垂 直 运输 任 务 ,工程 起 重机 械 必须 设 置 起 升 机 构 。 升 机 构 作 为 工 程 起 重 机 械 的 主 要 机 构 , 工 程 起 在
Spe d C o r l S m u a i n f H o s i e ha s Ba e e nt o i l to o i tng M c ni m s d on AM ESi nd m a Si ulnk m i
郭 启 华
G U o lhua Q —
f unc i as bui o ton w l t connectt t hei n eraces it f r The r esuls ofsi ul i t m aton show hathoi i t stng speed s i pr i m oved,and

论文基于AMESim与MatlabSimulink联合仿真技术的接口...

论文基于AMESim与MatlabSimulink联合仿真技术的接口...

论文:基于A M E S i m与M a t l a b\S i m u l i n k联合仿真技术的接口与应用研究基于AMESim与Matlab\Simulink联合仿真技术的接口与应用研究摘要:根据AMESim与Matlab\Simulink软件各自的特点,对两者联合仿真技术进行了研究,解决了联合仿真的接口与实现问题,并把该技术应用于电液位置伺服系统,取得了良好效果关键词:AMESim,Matlab\Simulink,联合仿真,电液伺服系统1 引言法国lmagine公司开发的AMESim是当今领先的流体,传动系统和液压/机械系统建模,仿真及动力学分析软件.它为用户提供了一个系统工程设计的完整平台,可以建立复杂的多学科领域系统的数学模型,并在此基础上进行仿真计算和深入的分析.然而,不存在一种仿真软件平台能够提供工程设计所需要的所有功能。

AMESim作为多学科领域系统仿真设计的平台提供了丰富的与其他软件的接口。

基于Matlalb平台的Simulink是动态系统仿真领域中著名的仿真集成环境,它在众多领域得到广泛应用。

Simulink 借助Matlalb的计算功能,可方便地建立各种模型、改变仿真参数,很有效地解决仿真技术中的问题。

AMESim作为一个完整的系统工程仿真平台,Simulink作为事实上的控制系统设计的标准平台。

点对点的AMESim-Simulink接口提供了一个使用便捷和行之有效的工具用于AMESim的被控对象模型和控制系统模型之间的耦合分析。

同时利用了AMESim和Simulink的最佳功能,避免了不同平台之间复杂模型的重建。

2 联合仿真设置与实现2.1 联合仿真设置1 将VC++中的"vcvar32.bat"文件从Microsoft Visual C++目录(通常是.\Microsoft Visual Studio\VC98\2 设置环境变量:我的电脑-〉属性-〉高级-〉环境变量。

基于AMESim和Simulink的汽车电动助力转向系统的联合仿真

基于AMESim和Simulink的汽车电动助力转向系统的联合仿真

2008年6月第36卷第6期机床与液压MACH I N E T OOL &HY DRAUL I CSJun 12008Vol 136No 16收稿日期:2007-09-03基金项目:四川省重点学科重点实验室建设项目(Z01336)作者简介:王康康(1981—),男,浙江浦江人,在读研究生,主要研究方向:汽车电子控制技术。

电话:013550397278,E -mail:p jcucu mber@1631com 。

基于A MESim 和Simulink 的汽车电动助力转向系统的联合仿真王康康,唐岚,黎长青(西华大学交通与汽车工程学院,成都610039)摘要:以研究电动助力转向系统的助力控制模式的跟踪性能和轻便性为目的,在AMESi m 和Si m ulink 平台上创建了电动助力转向系统联合仿真模型。

仿真结果表明,所设计的P I D 控制算法使电动助力转向系统具有良好的跟踪性能和轻便性。

仿真结果为电动助力转向控制系统的设计提供了依据。

关键词:汽车电动助力转向;AMESi m ;联合仿真中图分类号:U46116 文献标识码:A 文章编号:1001-3881(2008)6-127-2Co 2si m ul a ti on Study of Autom ob ile Electron i c PowerSteer i n g System Ba sed on AM ES i m and S i m uli n kWANG Kangkang,T ANG Lan,L I Changqing(School of Trans portati on and Aut omobile Engineering,Xihua University,Chengdu 610039,China )Abstract:The trace capability and portability of the power 2assisted mode of the electric power steering syste m was studied,a co 2si m ulati on model of the electric power steering syste m was created on the p latfor m of AMESi m and Si m ulink .The results of the si m ula 2ti on confir m that the P I D contr ol algorith m f or the electric power steering syste m has a good trace capability and portability .The con 2clusi on of si m ulati on is useful f or the design of electric power steering syste m.Keywords:EPS;AMESi m ;Co 2si m ulati on1 电动助力转向系统的结构电动助力转向系统(EPS )是机械转向装置配合电子控制单元共同完成转向的动力转向系统。

基于Simulink AMESim联合仿真

基于Simulink AMESim联合仿真

基于SimulinkAMESim联合仿真作者:王鹏宇王庆年胡安平于远彬摘要:本文对混合动力客车制动力分配系数β的确定进行分析。

在并行再生制动系统基础上,提出通过调节气压ABS调节单元来控制汽车机械制动力,以期改善混合动力客车制动力分配,提高制动稳定性,增加制动能量回收。

本文建立了Simulink-AMESim联合仿真模型并进行仿真分析,仿真结果表明:这种再生制动系统可有效的提高汽车制动稳定性,增加制动能量回收。

关键词:混合动力客车再生制动AMESim引言混合动力城市公交车是目前公认的混合动力车主要应用车型,城市公交车主要工作在频繁起停的工况下,混合动力城市公交车将能够显著的提高燃油经济性,减少尾气排放,降低污染。

再生制动[1]技术应用到混合动力汽车上将能够部分回收制动消耗在制动器上的能量,提高整车燃油经济性。

就目前大多数混合动力汽车而言,机械制动与再生制动是并行的,这种再生制动系统存在着机械制动子系统常开,机械制动力不可控,制动能量回收有限,驱动轴容易提前抱死等问题。

因此本文尝试在并行再生制动系统基础上,通过调节ABS调节单元来控制机械制动力从而提高再生制动系统性能。

1并行再生制动系统如图1所示为混合动力客车的并行再生制动系统制动控制策略[2][3],这种制动力分配控制策略在传统汽车定比例制动力分配控制策略思想的基础上发展起来的,具有控制系统简单,可靠性高,容易实现等优点是一种应用价值很高的制动力分配控制策略。

但是这种控制策略下制动力分配曲线高于I曲线,在附着系数低的路面上容易发生后轮先抱死的不稳定工况,同时为了尽可能提高制动稳定性,后轮再生制动力被控制在较小的范围,限制了再生制动能量的回收。

如果可以通过简单的调解机构控制驱动轴机械制动力,使再生制动力起作用后的制动力分配曲线沿原有的制动力分配曲线β线分配。

将提高整车的制动稳定性,同时提高再生制动能量回收率。

2 混合动力客车制动力分配对于混合动力客车而言,后轴为驱动轴,其制动力由机械制动力与再生制动力共同提供。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

MATLAB/Simulink interface®Version 4.0 - March 2002 EMail:cadserv21@The document is for study only,if tort to your rights,please inform us,we will deleteCopyright © IMAGINE S.A. 1995-2002AMESim® 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, Incorporated.ADAMS/Solver™ and ADAMS/View™ are trademarks of Mechanical Dynamics, Incorpo-rated.MATLAB and SIMULINK are registered trademarks of the Math Works, Inc.Netscape and Netscape Navigator are registered trademarks of Netscape CommunicationsCorporation in the United States and other countries. Netscape’s logos and Netscape productand service names are also trademarks of Netscape Communications Corporation, which maybe 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 licensedby X / Open Company Ltd.Windows, Windows NT, Windows 2000 and Windows XP are registered trademarks of theMicrosoft Corporation.X windows is a trademark of the Massachusetts Institute of Technology.All other product names are trademarks or registered trademarks of their respective compa-nies. EMail:cadserv21@The document is for study only,if tort to your rights,please inform us,we will deleteAMESim 4.0User ManualiTable of contentsUsing the AMESim MATLAB/Simulink Interface. . . . . . . . . . . . . . . . . . . . . . .11.Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12.Preliminaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .22.1.C compiler requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .22.2.Supported versions of Simulink . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .22.3.Setting up the environment. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .33.Constructing the model in AMESim . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .64.Importing the model into Simulink . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .115.Co-simulation interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .165.1.Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .175.2.Usage of the co-simulation interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .186.Concluding remarks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . EMail:cadserv21@The document is for study only,if tort to your rights,please inform us,we will deleteTable of contentsii EMail:cadserv21@The document is for study only,if tort to your rights,please inform us,we will deleteMATLAB/Simulink interface 4.0User Manual1Using the AMESim MATLAB/Simulink Interface1.IntroductionThe AMESim M ATLAB /Simulink interface enables you to construct a model of a sub-system in AMESim and to convert it to a Simulink S-Function. The S-Function can then be imported into Simulink and used within a Simulink system just like any other S-Func-tion.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 withinAMESim 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:When the process is done, the AMESim model parameters may be changed withinAMESim , 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 manualThis manual describes both the standard interface and the co-simulation interface. The main part of the manual deals with the standard interface and section 5 looks at the differ-ences between the standard and the co-simulation interface.Modify the AMESim submodel parametersConstruct the AMESim model as a S-FunctionComplete the Simulink systemRun the simulationExamine the AMESimsubmodel results in AMESim Examine the Simulink control system results in Simulink EMail:cadserv21@The document is for study only,if tort to your rights,please inform us,we will deleteChapter 1Using the AMESim MATLAB/Simulink Interface2The structure of this manual is the following:•Section 2 describes how you must set your working environment so that you can use the interface.•Section 3 describes with a simple example how the AMESim submodel is cre-ated and converted to an S-Function.•Section 4 describes how the AMESim model is imported into and run within Simulink .•Section 5 describes the differences between the co-simulation interface and the standard interface.•Section 6 gives a summary of the most important things to remember.•Sometimes a section of text is only applicable to a UNIX or Linux environment.For such text the following presentation is used:•Sometimes a section of text is only applicable to a Windows environment. Forsuch text the following presentation is used:Note that a collection of utilities also exists for M ATLAB 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 , M ATLAB and Simulink .2.Preliminaries 2.1. C compiler requirementsIf you work on a UNIX or Linux platform, you will need an ANSI C Compiler that is sup-ported by MATLAB/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++ whether you use the Simulink interface or not.2.2.Supported versions of SimulinkThis manual is written for Simulink 4.1.1 (distributed with M ATLAB 6.1), but the AMESim/Simulink interface was originally developed using Simulink 1.3c (M ATLAB4.2c) and has thus been tested using this version. It has also been tested with M ATLAB5.3. Note that the performance of the interface is higher with the newer version of Simulink . If you are using a different version of Simulink , some of the pictures of this manual will be different from the ones on your ing Unix:Description for Unix/Linux ing Windows:Description for Windows environments. EMail:cadserv21@The document is for study only,if tort to your rights,please inform us,we will deleteMATLAB/Simulink interface 4.0User Manual32.3.Setting up the environmentIn order to use the AMESim M ATLAB /Simulink interface it is necessary to set an envi-ronment variable that points out the M ATLAB 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 win-dow:Using Unix:echo $MATLAB_ROOTThis should result in something like:/opt/matlabr12.1being 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 M ATLAB is installed. If your working environment is set up properly to run M ATLAB , type eitherwhich matlab(if you are using Cshell) or whence matlab(if you are using Korn shell (ksh) or Bourne shell (sh)) or type matlab (for some versions of Bourne shells).This will tell you the location of your version of M ATLAB e.g./opt/matlabr12.1/bin/matlabRemove the last two parts from this pathname to get the value to set forMATLAB_ROOT, in this case /opt/matlabr12.1. If you are using the Unix C shell, you can then set the environment variable as follows:setenv MATLAB_ROOT /opt/matlabr12.1This 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/matlabr12.1 ; export MATLAB_ROOTAdd these statements to your .profile file so that the environment variable is set ev-ery time you login. EMail:cadserv21@The document is for study only,if tort to your rights,please inform us,we will deleteChapter 1Using the AMESim MATLAB/Simulink Interface42. 4. Configuration filesThe 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: glo-bally 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 $AME/lib or (%AME%/lib) directory. For global customization, they should be ed-ited 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 con-figuration. The file simulink.conf contains instructions on which files are to be used to cre-ate 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 Using Windows:echo %MATLAB%This should result in something like:C:\MATLAB6p1being 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 you path must contain the directory:%windir%\System32where %windir% is the Windows installation directory (a typical value for %wind-ir% 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% EMail:cadserv21@The document is for study only,if tort to your rights,please inform us,we will deleteMATLAB/Simulink interface 4.0User Manual5standard simulink.conf is shown below.The lines beginning with # are comments. The line that all local configurations needs to change is the 3rd non-comment line (currently reading "$AME/lib/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 ($AME/lib/simulink.make ) contains two lines, as in: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 command used for creating the Simulink mex S-function. This is a small shell script (amemex ) that runs the M ATLAB utility mex . All arguments are passed on to mex . By modifying amemex more advanced customizations can be made than are possible using lines 1 and 3 in simulink.make .########################################################## ## This file specifies the AMESim export facility to ## Simulink. The entries are as follows: ## ## 1. the template to use for an explicit system. ## 2. the template to use for an implicit system. ## 3. the makefile to use. ## 4. the button title. ## 5. the script file to launch the companion software. ## ##########################################################$AME/lib/imulink.etempNULL$AME/lib/simulink.makeSimulink\nInterface$AME/lib/unchUsing Unix:${AME}/lib/amemex -c -g -I${AME}/lib${AME}/lib/amemexUsing Windows:$(CC) -c -g -DWIN32 -I${MATLAB}/extern/include -I${MATLAB}/simulink/include${AME}/lib/amemex EMail:cadserv21@The document is for study only,if tort to your rights,please inform us,we will deleteChapter 1Using the AMESim MATLAB/Simulink Interface6This is for advanced users only.Each AMESim model ‘remembers’ which simulink.config was specified when it was cre-ated. 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.Using Unix:If your model includes Fortran code simulink.make probably needs to be altered by adding a 3rd line specifying the additional libraries needed. An example on such aline is:-L/opt/SUNWspro/SC3.0.1/lib -lF77 -lsunmathThis is highly system dependent and you probably need to ask your system admin-istrator 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 inthe standard area ($AME/lib/simulink.make).Another reason to add a 3rd line is if your submodels use user written utilities or oth-er non-standard files or libraries; this would typically be a change that you woulddo locally. For instance, if you would like to include a library called libmyfuncs.a which is stored in /home/my_name/library add the following line:-L/home/my_name/library –lmyfuncsIf there already is a 3rd line in simulink.make, for instance for using Fortran, addyour files at the beginning of the line as in:-L/home/my_name/library -lmyfuncs -L/opt/SUNWspro/SC3.0.1/lib -lF77 -lsunmathUsing Windows:A reason to add a 3rd 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 local-ly. 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.liborC:\home\my_name\library\myfuncs.lib EMail:cadserv21@The document is for study only,if tort to your rights,please inform us,we will delete3.Constructing the model in AMESimFigure 1The process of constructing the AMESim model is described with the help of a simple ex-ample. 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 calling it skyhook. It consists of two masses connectedwith a spring which represent a quarter car suspension.Note. :•two transducers determine the positions of the wheel and the car body;•connected to the wheel is a spring to which the road profile is applied;•the system is incomplete with three ports unconnected.8Figure 2The 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 sys-tem.Figure 3To 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 export 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 boxshown in Figure 4 is produced. EMail:cadserv21@Figure 4Notice that in this figure there is a field with the label SimulCosim 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 bet-ter to use more than one interface block. In our example, we require two input variables and three 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 appropriate text string.10Figure 5Note the three buttons labeled Clear all text , OK and Cancel .•Click on Cancel to abandon the process.•Click on Clear all text to remove any text you have entered.•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 >.Figure 6The 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 Fig-ure 2.It is worth mentioning 2 important points:•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);•the AMESim model must be explicit i.e. there cannot be any implicit variables,unless the co-simulation interface is used.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 submodelso as to get the simplest submodels. EMail:cadserv21@Figure 7Next, change to Parameter mode. Normally AMESim would create an executable pro-gram 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 de-scribed in section 2.Enter new parameters for the components to values shown in the table below, leave all oth-er parameters at their default values:Submodel Name onsketch ifanyTitle Value MAS002Body mass mass [kg]400SPR00current spring length [m]0.2 spring rate [N/m]15000 free length of spring [m]0.2MAS002Wheel mass mass [kg]40SPR00Tire stiffness current spring length [m]0.05 spring rate [N/m]200000 free length of spring [m]0.05UD00duration of step 1 [s]0.1 output at start of stage 2 [null]0.1 output at end of stage 2 [null]0.1 duration of step 2 [s]312When 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 . Start Simulink in the normal way from a suitable shell window (Unix) or by double-clicking on its asso-ciated icon (Windows).4.Importing the model into SimulinkThe AMESim model at this stage exists as an S-Function. It must be imported into Sim-ulink . Remember that when you quit AMESim , the files defining your system are com-pressed 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 simulta-neously when using the interface. This way, 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 skyhookto 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 8From 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 AMESimresult files. EMail:cadserv21@Figure 9With a normal AMESim 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.•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 re-sults.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 form two kind of signals:•The outputs from the AMESim model, labeled Bspeed and Wspeed.•The signal which is passed to the Hit Crossing block.If there are N outputs from the AMESim model, there will be N+1 outputs from the S-Function. The last output will always be connected to the Hit Crossing block.Figure 10Why is the extra output required? To understand why it is needed it is necessary to remem-ber that the AMESim model probably contains discontinuities. AMESim has its methodto deal with discontinuities and Simulink has, a different method that uses the Hit Cross-ing block. Since the model is run within Simulink, it must employ the Simulink method.The last output from the S-Function is a variable, which is normally positive but becomesnegative near a discontinuity. When this happens the Hit Crossing block slows down thesimulation greatly reducing the integration step. When the value goes positive again, thesimulation can speed up.It is possible to omit the Hit Crossing block but simulation runs are likely to be less reliableand may take longer.14 EMail:cadserv21@Important note:If your AMESim model has more than one input coming from Simulink, the input sig-nals to AMESim have their order reversed when compared to what is sent from Sim-ulink. 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 that case the variables are numbered from the top in both softwares. This can be seen by comparing the model in AMESim and Simulink as shown in the figures below:Next, set the simulation parameters to the values shown in Figure 11. 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.Figure 11In Simulink it seems that both solvers for stiff systems are possible to use for AMESimmodels. In this particular case, use the ode15s (stiff/NDF) method (in older versions, Gearand Adams/Gear were the ones most suitable). Set the stop time to 5 seconds, this will bequite enough to produce some interesting results.Initiate the Simulink run and watch the output from the Scope block. This will give theinput force supplied to the car suspension as shown in Figure 12.Figure 1216 EMail:cadserv21@Figure 13Figure 13 shows the same quantity plotted within AMESim. If you chose to generate anAMESim result file, it is possible from within AMESim to access the full range of vari-ables of the AMESim model. These can be plotted as from a normal AMESim simulation,Figure 14 shows the body and wheel displacements.Figure 145.Co-simulation interfaceTwo possibilities are offered to create an interface with Simulink: the standard interfaceand the co-simulation interface. Here we will explain what the differences are between the18two, and describe how to use the co-simulation interface.5.1.IntroductionThe 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 in-terface 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 Sim-ulink 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 infor-mation is controlled entirely by the Simulink solver. In this case one could say that we im-port 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 exchang-ing only input and output variables at a certain sample rate there is a loss of information.Figure 15The two AMESim-Simulink interfaces, exchange of informationThis can be compared with the difference between a continuous and a sampled controller. EMail:cadserv21@。

相关文档
最新文档