Waiting time in S-function

≡放荡痞女 提交于 2019-12-25 02:35:31

问题


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?


回答1:


If you want to update something every 200ms, put your S-Function into a subsystem which is triggered every 200s.




回答2:


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)

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!



来源:https://stackoverflow.com/questions/22785027/waiting-time-in-s-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!