Simulink Test: update constant block in iteration

I created a Simulink Model and I would like to use the Test Manager in Simulink Test to run numerous test cases on a Speedgoat (realtime test).

For some test cases I would like to use Scripted Iterations in Test Manager in order to change the speed.

The speed is defined in a constant block.

The problem:

I try to set the contents of that constant block in scripted iterations using setVariable(‘Name’, ‘Value’, ‘Source’, ‘MainTestModel/SpeedBlock’,’Value’, k)

While executing the testcase “Real time normal shift chain” , I get an error : Invalid parameter ‘MainTestModel/SpeedBlock/Value’.

What am I doing wrong?

How can I change the value of the constant block in iterations?

Is it also possible to use a struct in the constant block and still update using “setVariable” ?

ANSWER

The idea is to make use of the “Parameter Overrides” section of the “Real time normal shift chain” in the Simulink Test Manager.

Please follow the steps below:

  • Select the test “Real time normal shift chain”
  • Open “Parameter Overrides” section
  • Click “Refresh” at the bottom of the table. This will actually build the real-time application and retrieve all the available parameters in the model
  • Note down the name of the parameter set / workspace variable that corresponds to the model element ‘MainTestModel/SpeedBlock’. It is likely named ‘Speed’ based on what I see of your model.
  • Now you may override this value as follows:

>> setVariable(testItr, ‘Name’, ‘Speed’, ‘Value’, num2str(k));

in your test iterations.

SEE COMPLETE ANSWER CLICK THE LINK

Simple! That is me, a simple person. I am passionate about knowledge and reading. That’s why I have decided to write and share a bit of my life and thoughts to.