# Updating a Stimulus Profile to Use a Text File for Model Parameters

Configure an existing stimulus profile to use a text file to update model parameters without having to create and run multiple profiles.

Before you begin, deploy the engine demo's system definition.
1. In the VeriStand Editor, click Tool Launcher »Stimulus Profile Editor.
2. Click File»Open, navigate to <Common Data>\VeriStand Projects\Engine Demo\Stimulus Profiles\Engine Demo Return Value, and double-click the Engine Demo Return Value stimulus profile.
3. Save the stimulus profile as Update Model Parameters tutorial in the <Common Data>\VeriStand Projects\Engine Demo\Stimulus Profiles\Update Model Parameters directory.
4. Optional: If you want to run the stimulus profile in the VeriStand Editor, update the Setup step.
1. Right-click Open VeriStand Workspace and select Delete.
2. In the Steps palette, expand Other and drag Command Shell into the Setup.
3. In the Property Browser, specify the full path to VeriStand.exe as the Filename.
Note

You can add arguments in the Property Browser for this step to specify the VeriStand project, system definition file, and VeriStand gateway IP address to connect to.

5. In the Steps palette, expand VeriStand Control»Workspace and drag Update Model Parameters from File into Main, above the Real-Time Sequence Call.
6. In the Property Browser, set Source to <Common Data>\VeriStand Projects\Engine Demo\Stimulus Profiles\Update Model Parameters\OriginalParameterValues.txt If you open this file in a text editor, you can see that it resets the three key parameters for testing purposes back to their initial values.
a     [-7/9 0.5; -2/3 0]
{environment temperature (C)}     25
{idle speed (RPM)}     900
In this code, a is the A matrix for the engine state-space model, {environment temperature (C)} is the temperature of the environment in which the engine operates, and {idle speed (RPM)} is the RPM the engine maintains while idle.
Note

VeriStand expects parameter names to start with a letter and contain only alphanumeric characters or underscores. If a parameter name does not fit this convention, you can enclose it in curly braces ( { } ) to indicate that the string is a model parameter.

7. Select the Prompt Operator step that appears after the Real-Time Sequence Call and change the Message to Model parameters set to default values and the Dialog Title to New Parameter Values.
8. Add a second Update Model Parameters from File after the Prompt Operator, and set the Source to <Common Data>\VeriStand Projects\Engine Demo\Stimulus Profiles\Update Model Parameters\ParameterUpdate1.txt. This file changes the environment temperature and the idle speed of the engine to very high values:
{environment temperature (C)}     75
{idle speed (RPM)}     2000
9. Right-click the Prompt Operator you configured and select Copy.
10. Right-click Main, and select Paste to add another operator prompt to the end of section. Update its message to Environment temperature set to 75 and Idle RPM set to 2000.
11. Copy the Real-Time Sequence Call and paste it after the prompt. Because you are running the same test on each update of the model, you do not need to configure the sequence.
12. Add a third Update Model Parameters from File after the Prompt Operator, and set the Source to <Common Data>\VeriStand Projects\Engine Demo\Stimulus Profiles\Update Model Parameters\ParameterUpdate2.txt. This file demonstrates some more advanced operations:
tempConversionFactor     0.5
{environment temperature (C)}     50 * tempConversionFactor
subscript     subfile.txt

The first line declares a temporary variable, tempConversionFactor. The second line uses this variable in a calculation. Temporary variables are local to the file in which you create them.

The third line uses the subscript command to call another text file subfile.txt. This subscript sets a few more parameter values. When you call a file as a subscript, VeriStand inserts the contents of the subscript file into the calling file at the line that contains the subscript call.

13. Create another Prompt Operator with the Message Environment temperature reset to 25 C and the 'a' matrix (which controls RPM adjustments) changed to model a different engine.
14. Copy and paste another call to the real-time sequence.
15. Optional: If you want to ensure you leave your system in a known state, add another Update Model Parameters from File that calls OriginalParameterValues.txt.
16. Click Update Model Parameters tutorial.nivsstimprof and in the Property Browser disable Stop Execution on Fail.
17. Save the stimulus profile.

The stimulus profile code will look like the following image.

After updating the stimulus profile, run it. Each a time a test completes, click OK in the operator prompt to advance to the next model update.
Note

Some tests, such as the extreme conditions in ParameterUpdate1.txt, fail quickly.