MATLAB: How to ensure that all signals that are input to a Bus Creator Block show up in the respective generated code for this block

Embedded Coder

When I name a signal in a subsystem, and then input it to a Bus Creator Block in the top-level mode, the generated code for the signal does not always show up where I want it to be. Regardless of where I name the signal, I want it to be defined in the generated code for the Bus Creator since that way the code looks similar to the Simulink model. How can I ensure that all signals that are input to a Bus Creator Block show up in the respective generated code for this block?

Best Answer

The signal must be configured as a "Model default" Simulink Signal. To do this, in the model:
1. Right-click on the signal
2. Open Properties
3. On the Code Generation tab
4. Set the type as "Model default".
This will ensure the signal gets renamed as it enters the Bus Creator to be a Bus signal.