1

似乎延迟块只接受真正的输入/输出。我在布尔延迟上找不到任何东西。还是我需要进行布尔到实际的转换?

我对 Modelica 很陌生,但这对我来说似乎是一个明显的内置块......

谢谢!

4

1 回答 1

0

如果您使用 对其建模delay(),请注意信号可能会被插值。所以你必须决定0.5truefalse

但是,您可以实现自己的(效率稍低)延迟缓冲区(在 OpenModelica 和 Dymola 中测试):

model M
  parameter Integer bufferSize = 10;
  parameter Real delayTime = 0.1;
  discrete Real nextTime[bufferSize](each start = 0);
  Boolean delayBuffer[bufferSize](each start = false);
  Boolean signal,delayed;
  Integer n(start = 0), m(start = 1), prem;
equation
  when change(signal) then
    n = if pre(n)==10 then 1 else pre(n)+1;
    nextTime = {if i<>n then pre(nextTime[i]) else time + delayTime for i in 1:bufferSize};
    delayBuffer = {if i<>n then pre(delayBuffer[i]) else signal for i in 1:bufferSize};
  end when;
equation
  prem = pre(m);
  when time > nextTime[pre(m)] then
    delayed = delayBuffer[pre(m)];
    m = if pre(m)==10 then 1 else pre(m)+1;
  end when;
  if time < 0.1 then
    signal = true;
  elseif time < 0.2 then
    signal = false;
  elseif time < 0.7 then
    signal = true;
  elseif time < 0.71 then
    signal = false;
  elseif time < 0.72 then
    signal = true;
  elseif time < 0.73 then
    signal = false;
  elseif time < 0.74 then
    signal = true;
  elseif time < 0.75 then
    signal = false;
  else
    signal = true;
  end if;
end M;

在第一个信号被延迟之前,结果是错误的,但它可能可以改进。for 的 if 语句signal只是用于测试的样本信号。

于 2013-06-25T17:57:51.563 回答