Passing bus signals through a switch block
17 views (last 30 days)
Show older comments
Hi
I've a model.slx which has 2 inports with 2 datatypes of equivalent child busses. These child buses are fed into a subsystem, for further processing.
I want the feed bus be switching from source inport 1 to inport 2, based on a certain condition. I'm using switch block for this.
To exlempify this:
- Bus1 and Bus2 at in1 and in2, whose child busses are selected using a busSelector.
- Bus1_child1 and Bus2_child1 are to be fed to a certain subsystem, and are inputs of a switch block (at inport 1 and 3).
- Swicth block has a condition making it switch between both busses.
- But it gives an error:
Data type mismatch. Input port 3 of 'switch_demo/Switch1' expects a signal of data type 'Bus2_child1'. However, it is driven by a signal of data type 'Bus1_child1'.
Data type mismatch. Output port 1 of 'switch_demo/From1' is a signal of data type 'Bus1_child1'. However, it is driving a signal of data type 'Bus2_child1'.
Component:Simulink | Category:Modelerror
NOTE1: This error is seen to be noticed when a non Virtual bus is being fed to swicth, if it helps identify the issue.
NOTE2: Both child busses (Bus1_child1 and Bus2_child1) have equivalent structure, except for names of child busses. Although, there is change in datatypes but i changed to while trying to resolve the error, but no luck.
So, my question will be that if the documentation says switch block can handle signals with bus DTs, then it should right ?
If the approach I've chosen to go is somewhat wrong or doesn't align with the modelling guidelines, do let me know.
Any better suggestions for switching between two equivalent busses will be more than appreciated.
Thanks!!
Umesh
0 Comments
Accepted Answer
Mark McBroom
on 11 Jul 2020
Are you using Simulink Bus Objects to define the child buses? If not, try creating a Simulink.Bus object and setting the datatype of the two input ports to this bus object.
6 Comments
Mark McBroom
on 14 Jul 2020
Your latest model doesn't work for the same reason. The data types for the two inputs to your subsystem are different. For Bus1.a1 and Bus2.a2, you need to make the data types the same. For example, if you change the data type of Bus2.a2 to be Bus1_child1_def, then the model works properly.
The bottom line is, for a switch block, inputs 1 and 3 must be the same data type as the switch output port.
Thanks.
mark.
More Answers (0)
See Also
Categories
Find more on Model Verification 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!