MATLAB Answers


Using a bus-signal as an Input into a 'Model'-Block in Simulink

Asked by Sönke Matthiesen on 30 Jul 2019
Latest activity Commented on by Fangjun Jiang
on 2 Aug 2019
Hello everybody,
I am currently working on quite a complex simulink-model. To make the model more modular I wanted to use the 'Model'-Block to allow an easy swap between pre-defined models. However since the model is very complex I am currently using bus-signals(virtual) to make the model more "readable" and it seems, that those signals do not get recognized by the 'model'-block and its contents. The error-message I receive is, that the signal in the 'Model'-Block is not a bus-signal, althought the signal I input is.
How do I get around this issue? I want to the modularity of the 'model'-block with the usability of the bus-signals. Are there alternitives? If not, then what does the bus-signal turn into, once it 'crosses' over to the 'model'-block?
Thank you in advance for your answers!


Sign in to comment.




1 Answer

Answer by Fangjun Jiang
on 30 Jul 2019

see the demo model: sldemo_mdlref_conversion


Thank you for your answer. The use of Bus-Object has solved a part of the problem, so thank you for that! Unfortunatly it revealed another obstacle: When I now try to run the model, I get an error message like this:
Selected signal 'mysignal' in the Bus Selector block 'myBlock' is invalid since it refers to a bus element within an array of sub-buses. The path to the array of sub-buses is 'Bus1.Bus2'. Please select the appropriate array element using a Selector block before using the Bus Selector block to access an element within the bus.
Apparently the issue is, that the bus has multiple 'layers'. I discovered, that one way to get around this is to use multiple bus selectors, each one of them going one layer 'deeper' (like the error message suggested). In the given example with Bus1.Bus2 this would mean that a first bus selector selects Bus1 and the output is passed to another bus selector, this one selecting Bus2. Now this seems to work in the cases I have tried, but it is quite a lot of work, and makes the model very untidy. Do you have a better solution for this as well?
If not thats a shame, but thank you anyway for your first answer, it helped a lot!
The error must be caused by something else. It sounds like a mismatch issue. It is expecting "Bus1.Bus2" but 'mysignal' is feeded, or vise versa.
You can certainly select any signal or bus element (no matter how "deep") within a bus using a BusSelector block. In the demo model (after the conversion), try to add LIMITBUS.lower_limit at the first BusSelector block inside the reference model.

Sign in to comment.