2

I have a Simulink xPC target application that has blocks with discrete states at several different sample rates and some sections using continuous states. My intention on keeping the continuous states is for better numerical integration.

What creates the problem: One block is reading a device at a very fast rate (500 hz). The rest of the application can and should run at a slower rate (say, 25 or 50 Hz) because it would be overkill to run it at the highest rate, and because the processor simply cannot squeeze a full application cycle into the .002 secs of the faster rate. So I need both rates. However, the continuous states run by definition in Simulink at the faster discrete rate of the whole application! This means everywhere I have continuous states now they're forced to run at 500 Hz when 25 Hz would do!

Is there a way to force the continuous states in xPC target to a rate that is not the fastest in the application? Or alternatively, is there a way to allow certain block to run at a faster speed than the rest of the application?

4

3 回答 3

2

您以错误的方式考虑连续求解器 - 连续不仅意味着它运行得尽可能快 - 它使用与离散方程完全不同的算法来求解方程。因此,它们的运行速度必须至少与离散求解器一样快。

使用 Simulink开始:

连续求解器使用数值积分从先前时间步的状态和状态导数计算模型在当前时间步的连续状态。连续求解器依靠模型的模块来计算模型在每个时间步的离散状态的值。

数学家已经开发出多种数值积分技术来求解表示动态系统连续状态的常微分方程 (ODE)。Simulink 提供了一组广泛的固定步长和可变步长连续求解器,每个求解器都实现了特定的 ODE 求解方法(请参阅求解器)。

离散求解器主要用于求解纯离散模型。他们计算模型的下一个仿真时间步长,仅此而已。它们不计算连续状态,而是依靠模型的块来更新模型的离散状态。

所以结果是,,连续运行比最快的离散求解器慢是不够的——否则,根据定义,它们不是连续的。您应该重新考虑为什么将它们指定为连续的。

你想通过减慢连续求解器来完成什么?这是模拟时间/性能问题吗?

-亚当

于 2008-09-04T05:55:28.803 回答
0

我对此的看法是无法做到。解决此问题的一种方法是用离散状态(可能以中等速率,例如 100 Hz)替换连续状态,并祈祷精度损失是可以忍受的。

也许有可能以某种方式隔离一个块并以更快的速度单独运行它,但我不知道。

于 2008-09-04T05:46:17.467 回答
0

在像您的计算机这样的数字处理器中,真正的连续计算是不可能的。

MATLAB/Simulink 所说的“连续”是什么意思是“我将(动态地)尝试猜测离散步长足够小,以便您的应用程序中的离散化误差非常小”。

如果您通过了解您的应用程序已经知道 20 毫秒(50 赫兹)足够小,那么请使用离散 - 50 赫兹。

于 2009-10-15T17:39:17.063 回答