石珍 发表于 2012-10-29 14:45

与MATLAB的联合仿真

与MATLAB的联合仿真这一节的主要目的是介绍Virtual.Lab与MATLAB/Simulink的联合仿真,例子中的模型仿真飞机起落架的着陆过程,模型中的减震器是利用MATLAB/Simulink建立的。仿真模型如下。在进行联合仿真前,需要启动MATLAB。如果你有Virtual.Lab与MATLAB/Simulink的License,那么你选择Start All Programs LMS Virtual.Lab Tools-Rev7B Motion Matlab(在安装Virtual.Lab时必选选择安装与MATLAB的接口才有Motion Matlab选项),就能在启动Virtual.Lab的同时已经将MATLAB启动了,前提是你计算机上已经装了MATLAB。 一、创建Plant Input/Output单元1、选择File Open,找到文件MLG_L.CATAnalysis并打开它。2、进入机构设计平台,点击Two Body Plant Output 按钮,添加一个监测距离的控制单元,弹出如下所示的对话框。3、在Body1中选择Product1_ROOT l_mlg (l_mlg.1) l_oleo_cyl (l_oleo_cyl.1) l_oleo_cyl Axis Systems tsda.l_oleo_stop.t1,在Body2中选择Product1_ROOT l_mlg (l_mlg.1) l_oleo_pist (l_oleo_pist.1) l_oleo_pist Axis Systems tsda.l_oleo_stop.t2。   4、Type项选择DISTANCE,在Node项右击选择New Node,设置Node name为dist,点击ok关闭对话框。5、再次点击Two Body Plant Output 按钮,添加一个监测速度的控制单元,对话框设置如下。在Body1中选择tsda.l_oleo_stop.t1,在Body2中选择tsda.l_oleo_stop.t2。Type项选择DISTANCED, 设置Node name为distd,点击ok关闭对话框。6、点击 Two Body Plant Input e按钮,这个单元将会在两个Two Body Plant Output单元定义l_oleo_cyl和l_oleo_pist的轴之间施加一个刚性/阻尼力。对话框设置如下。 二、求解模型并导入MATLAB/Simulink的仿真结果1、         在Analysis Model MLG_L_Drop_Test下双击Solution Set,弹出Solution Set对话框。这里需注意将working directory设为与模型文件保存的同一目录下。   Analysis Type项设为DYNAMIC,在Solution Set对话框中点击Dynamic,设置Method Integration为MATLAB_SIM,点击Ok关闭Solution Parameters对话框中。2、         选择Compute Solution 按钮进行求解,在工作目录下会生成一个名为plantout.m的文件,这个文件包含在MATLAB/Simulink中创建S-function block的命令。3、         启动MATLAB。4、         在MATLAB命令窗口中敲入land,打开文件land.mdI,按下回车键,删除模型中现有的plantout S-function。5、         在MATLAB命令窗口中敲入plantout,按回车键,创建一个新的plantout S-function。6、         从MATLAB的主菜单中选择Simulation Start,仿真结果将自动连接到Virtual.Lab Motion中。 三、仿真模型 在Analysis Model MLG_L_Drop_Test下面选择Solution Set,点击Animate 按钮,弹出仿真对话框,点击Parameters 按钮,在采样步长Sampling Step填0.002s,关闭player parameters设置对话框,点击Play Forward 按钮仿真模型。 四、结果后处理1、从机构设计平台中点击运动曲线绘制 按钮,会弹出如下所示的曲线绘制窗口。2、选中Analysis Case并选择MLG_L_Drop_Test,在曲线图绘制中,X轴系统自动设为仿真时间,Y轴自己选择所需结果,这里在element name敲入l_oleo_pist,element Type项下拉选择Body,在过滤出的选项中选择L_oleo_pist:z。3、完成曲线绘制的设置后,点击曲线创建按钮 ,在右边的plots manager中我们就可以看到在MLG_L_Drop_Test下面出现了一个新的分支。4、点击新曲线展示按钮 ,在弹出的New Function Display对话框中选择2D Plots,点击Finish。在弹出的窗口中右击选择Select Data,弹出Select Data窗口,选择SYSTEM:TIME__l_oleo_pist:z。曲线显示如下。
页: [1]
查看完整版本: 与MATLAB的联合仿真