The second s-function only run at first step in multiple S-Functions cases

I am running a simulink model with 2 S-functions (more in the future), while it cannot gives a correct result. When using some printf in my codes, I found that the second s-function runs only at the first step, although the first s-function runs continuously each step. What makes me confused is that when run the two S-function separately, by using workspace for data transmission indirectly, it works. Thus, I think there should be some tricks about running a model where the s-function cooperating with each other. Could someone give me some hints about it?
In the attachment is my model with the two C-codes.
My problem is that my simulink model can only support one s-function running continuously with fixed step (0.001s). When connecting s-function to another, the second s-function runs only at the first step.
Thank you for your reading

 Accepted Answer

Now I solved this problem Take care of the sample time setting when you connect the separate s-function blocks!
if true
ssSetNumSampleTimes(S, 1);
end
I changed the value to -1 then it works.

More Answers (0)

Categories

Find more on Simulink Coder in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!