Real-Time Workshop User's Guide    

Part 4: Tuning Parameters

You can change the gain factor of either Gain block by assigning new values to the variables A or B in the MATLAB workspace. When you change block parameter values in the workspace during a simulation, you must explicitly update the block diagram with these changes. When the block diagram is updated, the new values are downloaded to the target program. To tune the variables A and B:

  1. In the MATLAB command window, assign new values to both variables, for example
  2. Activate the ext_example model window. Select Update Diagram from the Edit menu, or type Ctrl+D. As soon as Simulink has updated the block parameters, the new gain values are downloaded to the target program, and the effect of the gain change becomes visible on the scopes.

You can also enter gain values directly into the Gain blocks. To do this:

  1. Open the dialog box for Gain block A or B in the model.
  2. Enter a new numerical value for the gain and click Apply. As soon as you click Apply, the new value is downloaded to the target program and the effect of the gain change becomes visible on the scope.

    Similarly, you can change the frequency, amplitude, or phase of the sine wave signal by opening the dialog box for the Sine Wave block and entering a new numerical value in the appropriate field.

    Note, however, that you cannot change the sample time of the Sine Wave block. Block sample times are part of the structural definition of the model and are part of the generated code. Therefore, if you want to change a block sample time, you must stop the external mode simulation and rebuild the executable.

  1. To simultaneously disconnect host/target communication and end execution of the target program, pull down the Simulation menu and select Stop real-time code.

 Part 3: Running the External Mode Target Program Using the External Mode User Interface