Guy on Simulink

Simulink & Model-Based Design

ModeCharts:在Simscape中建模离散模式

Last week I described how tomodel a box on a moving table using Simulink subsystems as Stateflow state

As it is the case for most systems, there are many ways to model this box-table system in Simulink. I thought it would be interesting to model the same system this week using a new Simscape feature:ModeCharts.

背景

以类似于Simulink子系统的方式作为状态流状金宝app态,Simscape ModeCharts旨在使用离散操作模式进行模拟系统。

在表的框中的示例中,这两种模式是:

  • 锁定:盒子和表格以相等的速度在一起,表能够生成需要的任何力来保持它们的速度等于。
  • 解锁:盒子在空气中苍蝇,零力在桌子和盒子之间产生

To implement my table-box relationship, I thought it would be a good idea to get inspired by thefundamental friction clutch。如果您查看文档,您将找到下图为单向案例,这非常接近我所需要的。我唯一需要改变的是锁定的条件,这将是位置而不是速度的函数。

离合器逻辑

请注意,我们不能在zonefluce中只有两个模式。为了避免锁定和解锁之间的求解器,我们介绍了在达到解锁状态之前在离开锁定状态后等待锁定状态后等待的“等待”状态。

Mode Charts

Now, how do we implement that in Simscape?

首先,我们使用Simscape语言创建一个标准组件,具有来自机械翻译域的两个端口。为了帮助,我建议从基础库中的一个组件开始,例如弹簧。这看起来像:

Simscape code

然后我们可以开始定义我们的模式。在我们的ModeCharts中,我们需要定义3个部分:模式,
转换和初始模式。

关于模式,在我们被锁定的情况下,我们想要的等式是两个端口之间的速度为零。在所有其他模式中,我们想要的等式是两个端口之间的力为零。

模式

For the transitions, for each transition in the above diagram, we specify the source state, the destination state, and the condition when the transition should happen.

transitions

最后,我们可以指定模式的仿真on will start. If you do not specify one, the first mode defined will be used.

模式

现在我们的组件完成,我们可以抓住一个Simscape组件block and specify the SSC-file we just created.

Simscape组件Block

要创建类似于上周的模拟,我们将理想的速度源连接到基础(这将是我们的移动基础),以及另一个端口的质量(这将是我们的盒子)。使用运动传感器块,我们可以确认运动如预期。

The Model

结果

Now it's your turn

通过在州流和Simscape中练习这个系统的运动后,你知道我的结论是什么吗?我想要一个混合,其中我可以使用stateflow用户界面的便利性创建Simscape ModeChart。这不是惊人吗?

您认为此类功能对您有用吗?让我们在下面的评论中知道,沿着您将与Simscape ModeChart有关。

|
  • 打印
  • 发送电子邮件

댓글

댓글을 남기려면링크를클릭하여mathworks계정계정에로그인하거나하거나을새로새로새로