Creating a Multitasking Real-Time Sequence
- Updated2025-10-27
- 4 minute(s) read
Creating a Multitasking Real-Time Sequence
Create a real-time sequence that will warm-up and monitor the demo engine in separate tasks.
- In the VeriStand Editor, click .
- In the Stimulus Profile Editor, click New Real-Time Sequence.
- Save the sequence as Engine Demo Advanced tutorial in the <Common Data>\VeriStand Projects\Engine Demo\Stimulus Profiles\Engine Demo Advanced directory.
-
Add blocks to organize your code.
- In the Primitives palette, expand Miscellaneous and drag a Block into the Setup section of the real-time sequence.
- In the Property Browser Name field, enter Turn on engine.
- Add a block to the Main section and name it Set engine speed to 2500 and wait.
- Add a block to the Clean Up section and name it Turn off engine.
-
Create variables.
- In the Primitives palette, expand Variables and drag a Boolean into the Parameters section of the Variables pane.
- In the Property Browser next to Default Assignment, click Browse to display the system definition channel tree.
-
Click View aliases
to
display the aliases defined in the system definition.
- Double-click EnginePower to assign this alias to the parameter.
- In Identifier, enter EnginePower.
- In Units, enter On/Off.
- Select Double from the Primitives palette and drag it to Parameters to add a double-precision numeric parameter after EnginePower.
- In the Property Browser, name the new parameter DesiredRPM, map the parameter to the corresponding alias, and enter the units as RPM.
- Add another Double primitive after DesiredRPM, name it ActualRPM, and map it to the corresponding alias.
- Add another Double primitive after ActualRPM, name it EngineTemp, and map it to the corresponding alias.
-
Drag a Boolean primitive into the Local Variables
section of the Variables pane and name it
WarmUpComplete.
Note Local variables are variables you use within the real-time sequence as a way to hold values you get or set in statements.
-
In the Primitives palette under Variables, drag
Void Return Value into the Return
Variable section of the Variables
pane.
Note By default, the return value node is named Pass.
The Variables pane will look like the following image.
-
Add variables to the sequence code and set their values.
- In the Variables pane, drag EnginePower into the Turn on engine block.
-
In the Property Browser, edit the
Expression to EnginePower =
true.
This value will turn the engine on when the block executes.
-
Drag WarmUpComplete into
Setup so that this variable is at the same
level in the tree as Turn on engine.
Adding WarmUpComplete to Setup initializes the variable to a known value so that the real-time sequence can then write values to the variable during execution.
-
Drag EnginePower into Turn off
engine.
Leave the value as false to turn off the engine when the block executes.
-
Drag DesiredRPM into Turn off
engine.
Leave the value as 0 to decrease the RPM to 0 when the block executes.
-
Enable Multitasking
- In the Primitives palette, expand and drag MultiTask into Main.
- In the Property Browser, rename Task1 as EngineWarmUp and Task2 as MonitorEngineTemperature.
-
Modify the EngineWarmUp task by adding the
following code.

Note In the Sequences palette, expand to find WaitUntilSettled.The EngineWarmUp task sets the engine speed (DesiredRPM) to 2500 RPM, and then waits until the RPM (ActualRPM) settles into a range between 2450 and 9999999 RPM for 25 seconds. Then the task will raise the engine speed to 8000 RPM and wait until the RPM settles into a range between 7800 and 9999999 RPM for another 25 seconds. When the task successfully completes, the task sets the WarmUpComplete variable to true for the MonitorEngineTemperature task.
-
Modify the MonitorEngineTemperature task with the
following code.

Note In the Primitives palette, expand to find the DoWhile Loop and to find If Else.As long as the WarmUpComplete variable is false, the MonitorEngineTemperature task monitors the engine temperature (EngineTemperature) to ensure it does not exceed 110 degrees. If the engine temperature exceeds 110 degrees, the engine shuts down and the sequence aborts. If the engine temperature remains below 110 degrees, the sequence completes its execution and turns off the engine. - Save the real-time sequence.

Related Information
- Deploying the Engine Demo
Deploy the engine demo's system definition before running a stimulus profile.
- VeriStand Directories and Aliases
VeriStand uses directories and aliases for project files, models, and custom devices.
- Creating a Multitasking Stimulus Profile
Configure a stimulus profile to execute a multitasking real-time sequence.
