Table Of Contents

Creating a Multitasking Real-Time Sequence

Last Modified: November 16, 2020

Create a real-time sequence that will warm-up and monitor the demo engine in separate tasks.

Before you begin, you need to deploy the Engine Demo's system definition.
  1. In the VeriStand Editor, click Tool Launcher »Stimulus Profile Editor.
  2. In the Stimulus Profile Editor, click New Real-Time Sequence.
  3. Save the sequence as Engine Demo Advanced tutorial in the <Common Data>\VeriStand Projects\Engine Demo\Stimulus Profiles\Engine Demo Advanced directory.
  4. Add blocks to organize your code.
    1. In the Primitives palette, expand Miscellaneous and drag a Block into the Setup section of the real-time sequence.
    2. In the Property Browser Name field, enter Turn on engine.
    3. Add a block to the Main section and name it Set engine speed to 2500 and wait.
    4. Add a block to the Clean Up section and name it Turn off engine.
  5. Create variables.
    1. In the Primitives palette, expand Variables and drag a Boolean into the Parameters section of the Variables pane.
    2. In the Property Browser next to Default Assignment, click Browse to display the system definition channel tree.
    3. Click View aliases to display the aliases defined in the system definition.
    4. Double-click EnginePower to assign this alias to the parameter.
    5. In Identifier, enter EnginePower.
    6. In Units, enter On/Off.
    7. Select Double from the Primitives palette and drag it to Parameters to add a double-precision numeric parameter after EnginePower.
    8. In the Property Browser, name the new parameter DesiredRPM, map the parameter to the corresponding alias, and enter the units as RPM.
    9. Add another Double primitive after DesiredRPM, name it ActualRPM, and map it to the corresponding alias.
    10. Add another Double primitive after ActualRPM, name it EngineTemp, and map it to the corresponding alias.
    11. Drag a Boolean primitive into the Local Variables section of the Variables pane and name it WarmUpComplete.
      spd-note-note
      Note  

      Local variables are variables you use within the real-time sequence as a way to hold values you get or set in statements.

    12. In the Primitives palette under Variables, drag Void Return Value into the Return Variable section of the Variables pane.
      spd-note-note
      Note  

      By default, the return value node is named Pass.

    The Variables pane will look like the following image.
  6. Add variables to the sequence code and set their values.
    1. In the Variables pane, drag EnginePower into the Turn on engine block.
    2. In the Property Browser, edit the Expression to EnginePower = true. This value will turn the engine on when the block executes.
    3. 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.
    4. Drag EnginePower into Turn off engine. Leave the value as false to turn off the engine when the block executes.
    5. Drag DesiredRPM into Turn off engine. Leave the value as 0 to decrease the RPM to 0 when the block executes.
  7. Enable Multitasking
    1. In the Primitives palette, expand Structures»Multitasking and drag MultiTask into Main.
    2. In the Property Browser, rename Task1 as EngineWarmUp and Task2 as MonitorEngineTemperature.
    3. Modify the EngineWarmUp task by adding the following code.
      spd-note-note
      Note  

      In the Sequences palette, expand Real-Time Sequence Library»Standard»Timing 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.
  8. Modify the MonitorEngineTemperature task with the following code.
    spd-note-note
    Note  

    In the Primitives palette, expand Structures»Loops to find the DoWhile Loop and Structures»Conditional 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.
  9. Save the real-time sequence.
The real-time sequence code will look like the following image.
After creating this real-time sequence, add it to a stimulus profile.

Recently Viewed Topics