SIMULINK testing a model that has bus input and output ports

30 views (last 30 days)
I have a SIMULINK model that uses bus inputs and outputs as top level ports. When I am testing it, I don't know how to create a test signal as a bus and feed it into the model. I know that the straightforward way to do it is to create lots of individual signal and use bus creator block to group those as a bus that will feed into the model. However, this may not be a very efficient way to do things. Does anyone know any alternative?
I tried to look into Mathworks website but nothing really came up. Any help would be appreciated
  2 Comments
Mohammed Manna
Mohammed Manna on 13 Jan 2014
Thanks. i have already found the solution, it was basically an array of buses and all the leaf bus and element names needed to be EXACTLY the same in my input signal structure (a bit weird)

Sign in to comment.

Answers (2)

Jens
Jens on 13 Jan 2014
TPT is a very efficient testing and verification tool for Simulink models. It handles busses as well as vector signals automatically. The test harness for the Simulink model can be build automatically. So it is very efficent. TPT

Mark McBroom
Mark McBroom on 31 May 2024
If you already have a Simulink.Bus defined, another approach is to place a constant block in the Simulink model, set its value to zero, and set the data type to be the Simulink Bus. You can connect the output of the constant block to a Bus Assignment block to override any signals that you want to have non-zero values.
The createMATLABStruct function can also be useful if you have a Simulink.Bus. This function creates a MATLAB structure with the same layout as the Bus. You can then populate individual fields with the desired value, and then use this MATLAB struct in a Simulink Constant block to generate a bus signal. Create MATLAB structures that use the same hierarchy and attributes as buses - MATLAB Simulink.Bus.createMATLABStruct (mathworks.com)
Thanks.
Mark.

Tags

Products

Community Treasure Hunt

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

Start Hunting!