0

我正在使用 Simulink 中内置的 s-function,我需要实现等待时间。例如我需要这样做:

send the first frame    
wait 20 ms
send the second frame
wait 20 ms
send  third frame

我怎么能在 2 帧之间建立这个等待时间。我正在使用 C 语言和 Level-1 Matlab S-Function。

4

1 回答 1

0

首先,要获得毫秒精度是非常困难的。这在很大程度上取决于您的硬件、操作系统、正在运行的进程。

您可以尝试通过简单地使用 pause 命令来实现它

send the first frame    
pause(0.020)
send the second frame
pause(0.020)
send  third frame

或使用计时器对象http://www.mathworks.com/help/matlab/ref/timerclass.html

两种解决方案都不准确。最好的解决方案是将您的时间安排在外部事件中。发送每一帧后是否触发了任何事件?

于 2014-04-08T12:29:32.787 回答