Dealing with array of buses in Simulink®
by Vijay Swaminathan
15 Jul 2009
(Updated 10 Aug 2009)
This demo shows a self modifying masked subsystem to split out the correct subbus from the superbus.
|
Watch this File
|
| File Information |
| Description |
Here is the situation. Suppose you have a model that can analyze the properties of a meteor to track its trajectory. You want to use it in a larger model which tracks many such meteors at the same time. You now need a block that can accept a superbus called Mainbus (that contains a lot of subbuses called meteorbus) and split out the relevant subbus (metoerbus).
This block should be able to handles any changes in MainBus and meteorbus automatically on model update (no manual intervention).
Solution: Look at the example “ArrayofBus_example.mdl”. I created a masked subsystem “Meteor Selector” which automatically looks at the Bus Objects (MainBus and meteorbus), figures out how many meteors are in the “MainBus” and the structure of the “misbus” and pulls out the correct meteor.
I simply used a Bus Selector which splits out ALL the meteors and then use a Multiport Switch to pass through the correct meteor(based on input frm the mask) to the outport. The tricky part is to get this to work if the number of meteors in MainBus changes. I got this to happen by writing a script that figures out what needs to be done (at the time of model update) and put that in Mask Initialization callback. Essentially you have to set the correct number of ports for the Bus Selector and the Multiport Switch, delete the existing signal lines and add the required lines.
Instructions:
Open the model “ArrayofBus_example.mdl” and follow the instructions in the annotation. |
| Required Products |
Simulink
|
| MATLAB release |
MATLAB 7.8 (R2009a)
|
|
Tags for This File
|
| Everyone's Tags |
|
| Tags I've Applied |
|
| Add New Tags |
Please login to tag files.
|
| Updates |
| 10 Aug 2009 |
Minor changes in description and comments |
| 10 Aug 2009 |
Title update |
|
Contact us at files@mathworks.com