How to avoid Code Inspector warnings about If blocks connected to Constant blocks?

5 views (last 30 days)
I have a model that I'm trying to update to pass all Code Inspector checks within Model Advisor, because I will be generating code from it. One check that I've not been able to resolve is under the "Check If blocks" section and reads as follows:
Warning: The following blocks are constant or have ports connected to Constant blocks or other blocks that are constant
An example is that we have an internal timer where the confirmation time is coming from a Constant block; the Constant block has a non-inf update rate and the parameter within it is tuneable. So when code is generated, it may actually change during execution but it fails the Code Inspector checks.
How can use tuneable parameters, in Constant blocks or otherwise, and avoid the error I described above?
Edit: this is with R2016, and we have standards that we should avoid placing parameters within masks as this can hide functionality.

Answers (1)

Birdman
Birdman on 18 Oct 2017
If you are using an internal timer, Simulink has a block named Clock, which provides the simulation time of the model. You may use it instead of a Constant block. Hope this helps.
  4 Comments
Nathan B
Nathan B on 23 Oct 2017
I will test this out - but I suspect I will lose the ability to tune the parameter as the model is running (using generated code). I will try and report back.
Birdman
Birdman on 24 Oct 2017
You can set the parameter you want to tune as an input and take it as an output in the function.

Sign in to comment.

Categories

Find more on Simulink Code Inspector in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!