问题
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