Passing bus signals through a switch block

16 vues (au cours des 30 derniers jours)
you mess
you mess le 10 Juil 2020
Commenté : you mess le 14 Juil 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

Réponse acceptée

Mark McBroom
Mark McBroom le 11 Juil 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 commentaires
Mark McBroom
Mark McBroom le 14 Juil 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.
you mess
you mess le 14 Juil 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

Connectez-vous pour commenter.

Plus de réponses (0)

Produits


Version

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by