I am developing a controller model which I have put inside a Model Reference. I store all my Simulink.Parameter and Simulink.Signal objects inside a Data Dictionary. The storage class of these objects is set to ExportedGlobal.
The code that I am generating with Embedded Coder, interfaces with external code to run on hardware. This external code is able to change Simulink.Parameter values based on their name, and it can read the Simulink.Signal values also by using their name.
How it works is that the external code can change the value of a Simulink.Parameter (since it is an ExportedGlobal) and in the next execution time step the generated Simulink code uses the new value of that parameter.
My question now is, can I also change the parameter value from inside my Simulink model, with blocks?
The practical use-case is that an external event (such as a CAN message, or Ethernet message) can change a Simulink.Parameter value. But I want to place some value check algorithm inside the model to check if the new parameter value is allowed, e.g. is not above an allowed threshold. If it is above a threshold, I want to overwrite that value change by the threshold value but from inside Simulink.
I have investigated the Parameter Writer block and moving the Simulink.Parameters from the Data Dictionary to the Model Workspace. Such that the Parameter Writer block could change the arguments of the model reference. But this is only possible within an Initialize, Reset or Terminate block and it cannot be done on-command.
With kind regards,