We have a Simulink model that is compiled and run on a dSPACE box. We need to be able to
- change the value of a parameter with dSPACE ControlDesk and
- change the value of a parameter with a Matlab function inside the model (or something equivalent like a Simulink block)
(1) is possible with a Constant block, just by entering a number. You can change the value of the Constant block in dSPACE. It is also possible to enter a variable name like FOO in the Constant block and change that value FOO as a tunable parameter.
(2) has not been possible so far. Things like 'set_param' do not seem to work, because everything is compiled with Simulink Coder.
Any method that is able to change the parameter FOO from inside the model would work for us.
Application / Why?: We have values like "target x position of robot". Sometimes, this value is set manually, but sometimes, it is set automatically by different actors ('Drive straight', 'Drive curves', whatever). It would be nice to see the current target x position in one definite place and not have to worry about manually switching control from manual mode to actor 1, actor 2 etc. (of course we then need to make sure only one actor is active at each time step). If need be and our idea is impossible, we would at least like an elegant way to switch control.
Current workaround (has problems):
Our current method detects changes in the set values (that may come from different actors). Actor 1 sets value u1=10, then y=u1=10. Actor 2 then sets value u2=30, then y=u2=30. But if actor 1 then sets u1=10 again, no change is detected and y is still u2=30.