I need to write a simulink s-function that is triggered by an input signal

472 Views Asked by At

I wish to write data to a file when an integrator saturates. I would like to route the integrator's saturation output port to one of the s-function's inputs. I realize that I can continuously poll the signal, but I'd like to explore triggering on the signal. In other words, for the s-function to behave similarly to a software interrupt.

2

There are 2 best solutions below

1
On

Madison,

If you like to call s-function based on trigger, you might explore using a relational operator to check the condition. When the condition is True, function would be triggered.

Trying to embed a screenshot below:

Screenshot

1
On

F. Madison,

If you like to trigger it on signal change from 0 to 1, you can make use of a condition made up of relational operator and Unit delay:

Another Screenshot