主要内容GydF4y2Ba

Model and Validate a System

you model each component within the system structure to represent the physical or functional behavior of that component. You verify the basic component behavior by simulating them using test data.

打开系统布局GydF4y2Ba

A big-picture view of the whole system layout is useful when modeling individual components. Start by loading the layout model. At the MATLAB command line, enter:

open_system(GydF4y2Ba'system_layout.slx'GydF4y2Ba)GydF4y2Ba

Model the Components

A Simulink®model of a component is based on several starting points:

  • 物理组件的输出和输入之间的显式数学关系 - 您可以直接或间接地通过代数计算和集成微分方程从输入中计算组件的输出。例如,鉴于流入率的水平计算水位是明确的关系。每个Sim万博1manbetxulink块根据其输入到其输出的计算的定义执行。GydF4y2Ba

  • 物理组件的模型变量之间的隐式数学关系 - 因为变量是相互依赖的,因此将输入和输出分配给组件并不简单。例如,电压在GydF4y2Ba+GydF4y2Baendof a motor connected in a circuit and the voltage at the-GydF4y2Ba结束有隐性关系。要在Simulink中建模这种关系,您可以使用诸如SIMSCAP万博1manbetxE™之类的物理建模工具,也可以将这些变量建模为允许输入/输出定义的较大组件的一部分。有时,仔细检查建模目标和组件定义有助于定义输入/输出关系。GydF4y2Ba

  • 从实际系统获得的数据 - 您已经从实际组件中测量了输入/输出数据,但是不存在完全定义的数学关系。许多设备都有适合此描述的未模拟组件。例如,电视消散的热量。您可以使用系统标识工具箱™来定义此类系统的输入/输出关系。GydF4y2Ba

  • 明确的功能定义 - 您通过代数和逻辑计算从输入中定义功能组件的输出。例如,恒温器的开关逻辑。您可以将大多数功能关系建模为Simulink块和子系统。万博1manbetxGydF4y2Ba

This tutorial models physical and functional components with explicit input/output relationships. In this tutorial, you will:

  1. 使用系统方程创建模型。万博1manbetxGydF4y2Ba

  2. 添加一个dconnect Simulink blocks in the Simulink Editor. Blocks represent coefficients and variables from the equations.

  3. 分别为每个组件构建模型。建立系统模型的最有效方法是首先独立考虑组件。GydF4y2Ba

  4. 首先使用系统的近似值构建简单的模型。确定可能影响模型准确性的假设。迭代添加细节,直到复杂性水平满足建模和准确性要求。GydF4y2Ba

建模物理组件GydF4y2Ba

Describe the relationships between components, for example, data, energy, and force transfer. Use the system equations to build a graphical model of the system in Simulink.

在开始建模组件之前,有一些问题要问:GydF4y2Ba

  • 每个组件的常数是什么?除非您更改它们,否则什么值不会改变?GydF4y2Ba

  • What are the variables for each component? What values change over time?

  • 组件有多少个状态变量?GydF4y2Ba

Derive the equations for each component using scientific principles. Many system equations fall into three categories:

  • 对于连续系统,微分方程描述了变量的变化速率,其方程为所有时间值定义。例如,一阶微分方程给出了汽车的速度:GydF4y2Ba

    dGydF4y2Ba vGydF4y2Ba ((GydF4y2Ba tGydF4y2Ba )GydF4y2Ba dGydF4y2Ba tGydF4y2Ba =GydF4y2Ba -GydF4y2Ba bGydF4y2Ba mGydF4y2Ba vGydF4y2Ba ((GydF4y2Ba tGydF4y2Ba )GydF4y2Ba +GydF4y2Ba 你GydF4y2Ba ((GydF4y2Ba tGydF4y2Ba )GydF4y2Ba

  • 对于离散系统,差异方程式描述了变量的变化率,但是方程仅在特定时间定义。例如,来自离散比例衍生控制器的控制信号:GydF4y2Ba

    pGydF4y2Ba dGydF4y2Ba [[GydF4y2Ba nGydF4y2Ba 这是给予的GydF4y2Ba =GydF4y2Ba ((GydF4y2Ba eGydF4y2Ba [[GydF4y2Ba nGydF4y2Ba 这是给予的GydF4y2Ba -GydF4y2Ba eGydF4y2Ba [[GydF4y2Ba nGydF4y2Ba -GydF4y2Ba 1GydF4y2Ba 这是给予的GydF4y2Ba )GydF4y2Ba kGydF4y2Ba dGydF4y2Ba +GydF4y2Ba eGydF4y2Ba [[GydF4y2Ba nGydF4y2Ba 这是给予的GydF4y2Ba kGydF4y2Ba pGydF4y2Ba

  • 没有衍生物的方程是代数方程。例如,代数方程在平行电路中具有两个组件:GydF4y2Ba

    我GydF4y2Ba tGydF4y2Ba =GydF4y2Ba 我GydF4y2Ba 一个GydF4y2Ba +GydF4y2Ba 我GydF4y2Ba bGydF4y2Ba

车轮和线性运动。GydF4y2Ba有两种作用在车轮上行动:GydF4y2Ba

  • 电动机施加的力 - 力GydF4y2BaFGydF4y2Ba一个cts in the direction of velocity change and is an input to the wheel subsystems.

  • 阻力 - 力量GydF4y2BaFGydF4y2Badr一个GGydF4y2Ba反对速度变化的方向,是速度的函数。GydF4y2Ba

    FGydF4y2Ba dGydF4y2Ba rGydF4y2Ba 一个GydF4y2Ba GGydF4y2Ba =GydF4y2Ba kGydF4y2Ba dGydF4y2Ba rGydF4y2Ba 一个GydF4y2Ba GGydF4y2Ba vGydF4y2Ba |GydF4y2Ba vGydF4y2Ba |GydF4y2Ba

Acceleration is proportional to the sum of these forces:

((GydF4y2Ba mGydF4y2Ba /GydF4y2Ba 2GydF4y2Ba )GydF4y2Ba vGydF4y2Ba ˙ =GydF4y2Ba FGydF4y2Ba -GydF4y2Ba FGydF4y2Ba dGydF4y2Ba rGydF4y2Ba 一个GydF4y2Ba GGydF4y2Ba ((GydF4y2Ba mGydF4y2Ba /GydF4y2Ba 2GydF4y2Ba )GydF4y2Ba vGydF4y2Ba ˙ =GydF4y2Ba FGydF4y2Ba -GydF4y2Ba kGydF4y2Ba dGydF4y2Ba rGydF4y2Ba 一个GydF4y2Ba GGydF4y2Ba vGydF4y2Ba |GydF4y2Ba vGydF4y2Ba |GydF4y2Ba vGydF4y2Ba ˙ =GydF4y2Ba FGydF4y2Ba -GydF4y2Ba kGydF4y2Ba dGydF4y2Ba rGydF4y2Ba 一个GydF4y2Ba GGydF4y2Ba vGydF4y2Ba |GydF4y2Ba vGydF4y2Ba |GydF4y2Ba ((GydF4y2Ba mGydF4y2Ba /GydF4y2Ba 2GydF4y2Ba )GydF4y2Ba

在哪里GydF4y2BakGydF4y2Badr一个GGydF4y2Ba是阻力系数和GydF4y2BamGydF4y2Ba是机器人的质量。每个车轮都有一半的质量。GydF4y2Ba

构建车轮模型:GydF4y2Ba

  1. 在里面GydF4y2BaSystem_layoutGydF4y2Bamodel, double-click the右轮GydF4y2Ba子系统显示空子系统。GydF4y2Ba

  2. 模型速度和加速度。添加一个GydF4y2Ba集成商GydF4y2Ba堵塞。将初始条件设置为GydF4y2Ba0GydF4y2Ba。该块的输入是加速度GydF4y2Bavdot输出是速度GydF4y2BavGydF4y2Ba。GydF4y2Ba

  3. 建模阻力力。添加一个GydF4y2BaMATLAB Function从用户定义的功能库中块。这GydF4y2BaMATLAB FunctionBlock提供了一种在模型中实现数学表达式的快速方法。要编辑函数,请双击块以打开MATLAB功能编辑器。GydF4y2Ba

  4. Define arguments for the MATLAB Function block. In theMATLAB Functionblock editor, click theEdit Data按钮。点击GydF4y2Bak_dragGydF4y2Ba, 放GydF4y2BaScope至GydF4y2Ba范围GydF4y2Ba,然后单击GydF4y2Ba申请GydF4y2Ba。GydF4y2Ba

  5. 从摩托力中减去阻力GydF4y2Ba减去GydF4y2Ba堵塞。用A完成力加速方程式GydF4y2Ba获得GydF4y2Ba带有参数的块GydF4y2Ba1/((m/2)GydF4y2Ba。GydF4y2Ba

  6. To reverse the direction of theMATLAB Functionblock, select the block. In the toolstrip, on the格式GydF4y2Ba选项卡,单击GydF4y2BaFlip left-right翻转左右按钮GydF4y2Ba。连接块。GydF4y2Ba

  7. 两个轮子的动力学是相同的。制作您刚建模并将其粘贴到左轮子系统中的右车轮子系统的副本。GydF4y2Ba

  8. 查看模型的最高级别。点击GydF4y2Ba导航到父母GydF4y2Bab你t至nGydF4y2Ba。GydF4y2Ba

旋转运动。GydF4y2BaWhen the two wheels turn in opposite directions, they move in a circle of radiusrGydF4y2Ba, causing rotational motion of the robot. When the wheels turn in the same direction, there is no rotation. Assuming that the wheel velocities are always equal in magnitude, it is practical to model rotational motion as dependent on the difference of the two wheel velocitiesvGydF4y2BarGydF4y2Ba和GydF4y2BavGydF4y2BalGydF4y2Ba:GydF4y2Ba

θGydF4y2Ba ˙ =GydF4y2Ba vGydF4y2Ba rGydF4y2Ba -GydF4y2Ba vGydF4y2Ba lGydF4y2Ba 2GydF4y2Ba rGydF4y2Ba

构建旋转动力学模型:GydF4y2Ba

  1. 在最高的GydF4y2BaSystem_layoutGydF4y2Bamodel, double-click the Rotation subsystem to display the empty subsystem. Delete the connection between the企业GydF4y2Ba和GydF4y2Ba外港GydF4y2Ba块。GydF4y2Ba

  2. Model angular speed and angle. Add an集成商GydF4y2Ba堵塞。将初始条件设置为GydF4y2Ba0GydF4y2Ba。该块的输出是角度GydF4y2BaThetaGydF4y2Ba和input is the angular speedTheta_dot。GydF4y2Ba

  3. 从切向速度计算角速度。添加一个GydF4y2Ba获得GydF4y2Ba使用参数GydF4y2Ba1/(2*r)GydF4y2Ba。GydF4y2Ba

  4. 连接块。GydF4y2Ba

  5. 查看模型的最高级别。点击GydF4y2Ba导航到父母GydF4y2Bab你t至nGydF4y2Ba。GydF4y2Ba

Model the Functional Components

描述功能从函数输入到其输出的功能。此描述可以包括代数方程式和逻辑构造,您可以在Simulink中使用它们来构建系统的图形模型。万博1manbetxGydF4y2Ba

坐标转换。GydF4y2BaX和Y坐标中机器人的速度,GydF4y2BavGydF4y2BaXGydF4y2Ba和GydF4y2BavGydF4y2BayGydF4y2Ba,与线性速度有关GydF4y2BavGydF4y2BanGydF4y2Ba和一个nGleThetaGydF4y2Ba:GydF4y2Ba

vGydF4y2Ba XGydF4y2Ba =GydF4y2Ba vGydF4y2Ba nGydF4y2Ba cosGydF4y2Ba ((GydF4y2Ba θGydF4y2Ba )GydF4y2Ba vGydF4y2Ba yGydF4y2Ba =GydF4y2Ba vGydF4y2Ba nGydF4y2Ba sin ((GydF4y2Ba θGydF4y2Ba )GydF4y2Ba

Build the coordinate transformation model:

  1. 在最高的GydF4y2BaSystem_layoutGydF4y2Ba模型,双击坐标转换子系统以显示空子系统。GydF4y2Ba

  2. 模型三角函数。添加一个GydF4y2BaSincosGydF4y2Bablock from the Math Operations library.

  3. 模型乘法。添加两个GydF4y2Ba产品GydF4y2Bablocks from the Math Operations library.

  4. 连接块。GydF4y2Ba

  5. 查看模型的最高级别。点击GydF4y2Ba导航到父母GydF4y2Bab你t至nGydF4y2Ba。GydF4y2Ba

设置模型参数GydF4y2Ba

A source for model parameter values can be:

  • 书面规格,例如标准财产表或制造商数据表GydF4y2Ba

  • 现有系统的直接测量GydF4y2Ba

  • 使用系统输入/输出的估计GydF4y2Ba

This model uses these parameters:

范围GydF4y2Ba 象征GydF4y2Ba 价值GydF4y2Ba
Mass mGydF4y2Ba 2.5公斤GydF4y2Ba
滚动阻力GydF4y2Ba k_dragGydF4y2Ba 30 nsGydF4y2Ba2GydF4y2Ba/mGydF4y2Ba
机器人半径GydF4y2Ba rGydF4y2Ba 0。15 m

万博1manbetxSimulink使用MATLABGydF4y2Ba®工作空间评估参数。在MATLAB命令窗口中设置这些参数:GydF4y2Ba

m=2。5; k_drag = 30; r = 0.15;

v一个lidate Components Using Simulation

通过提供输入和观察输出来验证组件。即使如此简单的验证也可以指出改进模型的立即方法。此示例验证了这些行为:GydF4y2Ba

  • 当将力连续施加到车轮上时,速度会增加,直到达到稳态速度为止。GydF4y2Ba

  • When the wheels turn in opposite directions, the rotation angle increases at a constant rate.

验证车轮组件GydF4y2Ba

Create and run a test model for the wheel component:

  1. Create a new model. In the模拟GydF4y2Ba选项卡,单击GydF4y2Ba新的GydF4y2Ba。Copy the Right Wheel block into the new model.

  2. 创建一个测试输入。添加一个GydF4y2BaStepblock from the Sources library and connect it to the input of the Right Wheel block. Leave the step time parameter set to1GydF4y2Ba。GydF4y2Ba

  3. 将查看器添加到输出中。right-click the output port of the Right Wheel block and select创建并连接查看器> simulink>范围万博1manbetxGydF4y2Ba。GydF4y2Ba

  4. 运行模拟。在里面GydF4y2Ba模拟GydF4y2Ba选项卡,单击GydF4y2Ba跑GydF4y2Ba。GydF4y2Ba

这simulation result exhibits the general expected behavior. There is no motion until force is applied at step time. When force is applied, the speed starts increasing and then settles at a constant when the applied force and the drag force reach an equilibrium. In addition to validation, this simulation also gives information on the maximum speed of the wheel for the given force.

验证旋转组件GydF4y2Ba

Create and run a test model for the rotation model:

  1. Create a new model. Click并将旋转块复制到新型号中。GydF4y2Ba

  2. Create a test input in the new model. Add aStep距离来源库。将步骤时间参数设置为GydF4y2Ba1GydF4y2Ba。将其连接到旋转块的输入。该输入表示车轮沿相反方向旋转时车轮速度的差。GydF4y2Ba

  3. 将查看器添加到输出中。右键单击旋转块的输出端口,然后选择GydF4y2Ba创建并连接查看器> simulink>范围万博1manbetxGydF4y2Ba。GydF4y2Ba

  4. 运行模拟。在里面GydF4y2Ba模拟GydF4y2Ba选项卡,单击GydF4y2Ba跑GydF4y2Ba。GydF4y2Ba

该模拟表明,当车轮以相反方向相同的速度转动时,角度会稳定增加。您可以进行一些模型改进,以使解释角度输出更容易:GydF4y2Ba

  • 您可以将弧度的输出转换为学位。添加一个GydF4y2Ba获得GydF4y2Bablock with a gain of180/piGydF4y2Ba。GydF4y2Ba

  • 您可以显示度的输出in cycles of 360 degrees. Add a数学功能GydF4y2Bablock with functionmod。GydF4y2Ba

MATLAB trigonometric functions take inputs in radians.

验证模型GydF4y2Ba

After you validate individual components, you can perform a similar validation on the complete model. This example validates the following behavior:

  • 当将相同的力施加到同一方向上的两个车轮时,机器人将移动一条线。GydF4y2Ba

  • When the same force is applied to both wheels in opposite directions, the robot rotates in place.

  1. 在里面GydF4y2BaSystem_layoutGydF4y2Ba模型,双击输入子系统以显示空子系统。GydF4y2Ba

  2. Create a test input by adding aStep堵塞。将步骤时间参数设置为GydF4y2Ba1GydF4y2Ba。将其连接到两者GydF4y2Ba外港GydF4y2Ba块。GydF4y2Ba

  3. 在模型的顶层,将两个输出信号连接到同一范围查看器:GydF4y2Ba

  4. 运行模型。GydF4y2Ba

    在这个图中,黄线是X方向,蓝线是y方向。由于角度为零并且没有变化,因此车辆仅在X方向上移动,如预期。GydF4y2Ba

  5. Double-click the Inputs subsystem and add a获得GydF4y2Ba使用参数GydF4y2Ba-1GydF4y2Ba在源和第二输出之间。这逆转了左轮的方向。GydF4y2Ba

  6. 在角度输出中添加范围。GydF4y2Ba

  7. 运行模型。GydF4y2Ba

    第一个视图表明X-Y平面没有运动。第二视图表明旋转稳定。GydF4y2Ba

您可以使用此最终模型通过更改输入来回答有关模型的许多问题。一些例子是:GydF4y2Ba

  • 当初始角度不是零时会发生什么?GydF4y2Ba

  • 当力降至零时,运动要停止需要多长时间?GydF4y2Ba

  • 机器人较重时会发生什么?GydF4y2Ba

  • 当机器人在更平滑的表面上移动时,会发生什么,也就是说,当阻力系数较低时?GydF4y2Ba

相关话题GydF4y2Ba