How can I input and output Bus signals to and from an S-function created using the S-function builder in Simulink 7.3 (R2009a)?

16 views (last 30 days)
In the S-function Limitations section of the Simulink documentation, I see that handwritten C MEX S-functions do not support bus input and output signal.
For the S-Function Builder block, bus signals are not mentioned, so I am assuming that the S-function Builder block supports bus input and output signals.
However, I can not find any documentation or demo explaining how to do this.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 18 Oct 2013
The documentation explaining how to connect bus signals to the S-Function Builder block has been omitted in Simulink 7.3 (R2009a). A link to download an updated version of the documentation section titled "Writing S-Function in C" is provided below.
To connect a bus signal to the Input or Output port of the S-Function Builder follow these steps:
1. Create a bus object in the MATLAB workspace. This can be done from interactively using the Simulink Bus Editor, or from the command line by typing:
a = Simulink.Bus
More information about bus objects can be found at this link:
<http://www.mathworks.com/help/simulink/ug/using-bus-objects.html>
2. In the S-Function block, go to the "Data Properties" tab and add an Input port.
3. You will notice that the input port has two properties related to bus signals, "Bus" and "Bus Name". Set the "Bus" property to "on" and the "Bus Name" to the bus object created in the MATLAB workspace.
4. You can repeat the same operations for other input and output ports.
It is now possible to access the bus elements in the Outputs, Continuous Derivatives and Discrete Update section of the S-Function Builder.
An example model using bus signals with the S-Function Builder can be reached in MATLAB 7.7 (R2009a) by executing this command:
sfbuilder_bususage

More Answers (0)

Categories

Find more on Simulink Functions in Help Center and File Exchange

Products


Release

R2009a

Community Treasure Hunt

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

Start Hunting!