S功能的等待时间 [英] Waiting time in S-function

查看:131
本文介绍了S功能的等待时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用S函数(C语言)在Simulink中创建一个闪烁过程,我需要发送一些帧,并且连续两个帧之间的时间应该为200毫秒.如何执行此等待时间?有实施的可能性吗?

I am trying to create a flashing procedure in Simulink using a S-function (C language) and I need to send some frames and the time between 2 consecutive frames should be lets say 200 milisconds. How can I implement this waiting time? Is there any possibility of implementing it?

推荐答案

在下面,您可以找到我在函数中遵循的步骤:

Below you can find the steps that I followed in the function:

1.create first frame
2.send first frame
3.save the time when I send first frame
4.if(current_time - time_send_FF == x ms)
    5. calculate nr of consecutive frame
    6. for each consecutive frame
        7. create consecutive frame
        8. send consecutive frame
        9. save the time when I send consecutive frame 
        10. if(current_time - time_send_CF == x ms)
            11. jump to step 6
        else 
            12. check again if(current_time - time_send_CF == x ms)
   else
        13.check again  if(current_time - time_send_FF == x ms)

问题是我无法存储发送第一帧/连续帧的时间,因为即使我使用全局DWOrk/RWork数组,它也会不断递增,并且当我尝试在current_time和time_send_FF之间进行求和时,结果会有所不同始终为0. 我可以使用时钟块作为输入来访问系统时间.我应该尝试其他什么方法... 谢谢!

The problem is that I can't store the time when I send first/consecutive frame because even if I use a global DWOrk/RWork array it is continuously incrementing and when I try to do the difference between current_time and time_send_FF the result is always 0. I have access to the system time using a clock block as input. What other approach should I try... Thanks!

这篇关于S功能的等待时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆