以比连续速率更快的速率运行Simulink xPC块

时间:2020-03-05 18:47:28  来源:igfitidea点击:

我有一个Simulink xPC目标应用程序,该应用程序的块具有处于离散状态的块,这些块具有处于几种不同采样率的离散状态,并且某些部分使用连续状态。我保持连续状态的目的是为了更好地进行数值积分。

造成此问题的原因是:一个障碍正在以非常快的速度(500 hz)读取设备。应用程序的其余部分可以并且应该以较低的速度(例如25或者50 Hz)运行,因为以最高的速度运行它会过大,并且处理器根本无法将整个应用程序周期压缩到0.002秒。更快的速度。所以我需要两个价格。但是,连续状态按照定义在Simulink中以整个应用程序更快的离散速率运行!这意味着我到处都有连续状态,现在当25 Hz可以运行时,它们被迫以500 Hz运行!

有没有办法强制xPC目标中的连续状态达到应用程序中最快的速率?或者,是否有一种方法可以允许某些块以比应用程序其余部分更快的速度运行?

解决方案

回答

我认为这是不可能完成的。解决此问题的一种方法是将连续状态替换为离散状态(也许以中等速率,例如100 Hz),然后用手指指住精度损失是可以承受的。

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

回答

我们在以错误的方式考虑连续求解器时,连续不仅仅意味着它运行得最快,而且它使用的是与离散算法相比根本上可以求解方程的算法。因此,它们的运行速度必须至少与离散求解器一样快。

通过使用Simulink:

Continuous solvers use numerical
  integration to compute a model's
  continuous states at the current time
  step from the states at previous time
  steps and the state derivatives.
  Continuous solvers rely on the model's
  blocks to compute the values of the
  model's discrete states at each time
  step.
  
  Mathematicians have developed a wide
  variety of numerical integration
  techniques for solving the ordinary
  differential equations (ODEs) that
  represent the continuous states of
  dynamic systems. Simulink provides an
  extensive set of fixed-step and
  variable-step continuous solvers, each
  implementing a specific ODE solution
  method (see Solvers).
  
  Discrete solvers exist primarily to
  solve purely discrete models. They
  compute the next simulation time step
  for a model and nothing else. They do
  not compute continuous states and they
  rely on the model's blocks to update
  the model's discrete states.

因此,结果是,不可以使连续运行比最快的离散求解器慢得多,否则按照定义,它们不是连续的。我们应该重新考虑为什么将它们指定为连续的。

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

-亚当

回答

在诸如计算机这样的数字处理器中,不可能进行真正的连续计算。

MATLAB / Simulink"连续"的意思是"我将(动态地)尝试猜测离散步长足够小,从而在应用中离散化误差非常小"。

如果我们已经知道了应用程序,那么20ms(50Hz)足够小,然后使用离散的50Hz。