Make signal names coming from library links unique?

Well, I struggled with this for a while. What is the best way to accomplish the following:

enter image description here

where Reaction Wheel 1-4 - links to the same block in the library. When the Speed Counter , Speed Direction and Current signals are added to the final bus output, as shown, MATLAB (rightfully) complains:

Warning: Signals 9, 10, 11, 12 enter Autostart "myAwesomeModel" have duplicated names "Current". They become unique by adding "(signal #)" to the signals on the resulting bus. please update the signal labels so that they are unique.

So far I have used the “solution” as follows:

enter image description here

that is, place a block of size 1-multiplex / gain-1 / other-dummy in the middle, so that the signals can be renamed to something unique. However, I really like to believe that MathWorks was thinking about how to do this ...

What is the “right” way to build such bus signals? It is like being pushed to accept a specific design / architecture, but what exactly is eluding me at the moment ...

+6
source share
2 answers

It was a difficult task for me, but it seems that I took it apart. Matlab R2007a is here. I will give an example with a subsystem already completed with its inputs, outputs, ...

1- In the properties of the block, add the tag to the block. This will be done to identify the block and its “siblings” among the system. MY_SUBSYSTEM for this example.

2- Block properties again. Add the following snippet to the CopyFcn callback:

 %Find total amount of copies of the block in system len = length(find_system(gcs,'Tag','MY_SUBSYSTEM')); %Get handle of the block copied/added and name the desired signal accordingly v = get_param(gcb,'PortHandles'); set(v.Outport(_INDEX_OF_PORT_TO_BE_RENAMED_),'SignalNameFromLabel',['BASENAME_HERE' num2str(len)]); 

3- In _INDEX_OF_PORT_TO_BE_RENAMED_ you should put the index of the port signal (starting from 1) that you want to rename for each copy of the block. For one output block, this should be 1. BASENAME_HERE should be the base name of the port, in this case "Current" for you.

4- Add the block to the desired library and delete the instance that you used to create this example. From there, when you add from a library or copy an existing block, Outport should indicate Current1, Current2, Current3, etc. Please note that you can apply any convention or formatting.

Hope this helps. This worked for me, feel free to ask / criticize!

Note Obviously, as the model grows, this method may be demanding on the computer, since find_system will have to scroll through the entire model, but it seems to be a good way to get around me in small-sized systems.

+1
source

Connect a bus selector to each data output. Select the desired signals and set "Output as bus". Then connect all bus selectors to the bus maker.

simulink model

+1
source

Source: https://habr.com/ru/post/975651/


All Articles