Ignore certain blocks for production code generation

5 views (last 30 days)
Hi all
I have a controller model that I develop and reference in three different harnesses:
  1. simulation
  2. rapid prototyping
  3. production code generation.
I have certain blocks and signals that are used in the first two harnesses, but may not appear in the final production code generation. For example: I have made a library block of a PI controller which has an additional 'log' output port containing a bus with all kinds of signals from inside the PI controller block. In simulation I use this bus for Scope blocks, in the rapid prototyping environment I use this bus for other displaying methods. For production code generation however, this signal bus is not needed and I want to avoid code generation for this. This bus is passed through an outport.
I have found the block 'Environment Controller' which could be used to reduce blocks only used in simulation, but I still need them in rapid prototyping. I have also found this MATLAB Question but it is only a solution for MATLAB code, not Simulink.
Are there ways to reduce blocks for production code generation, which are not reduced by the automatic block reduction?
Can I differentiate based on the TLC I chose?

Accepted Answer

Jonas
Jonas on 27 Feb 2020
Edited: Jonas on 28 Feb 2020
Found the solution.
I have made a variant subsystem, wherein the production code variant I have used 'Ground' blocks as sources such that the code generator reduces those blocks for logging. I did have to use the Bus Creator and named signals for the code generator to not complain about a missing bus.
The Variant subsystem is controlled by a Simulink.Variant parameter inside my data dictionary with the expression:
strcmp('ert.tlc',get_param('controller','SystemTargetFile'))
This way, the PI controller with logging function is used for simulation and prototyping, and is not used for production code generation.

More Answers (0)

Categories

Find more on Schedule Model Components in Help Center and File Exchange

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!