MATLAB Answers

Passing bus signals through a switch block

2 views (last 30 days)
you mess
you mess on 10 Jul 2020
Commented: you mess on 14 Jul 2020
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

Accepted Answer

Mark McBroom
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
you mess
you mess on 14 Jul 2020
Fair enough. Thanks for your time, if only I knew about keeping the same data type.
I'm gonna accept your answer, considering your last comment conclusive.
Thanks for the help !
Umesh

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!