Table Of Contents

Create a Real-Time Sequence with Channel References and Local Variables

Last Modified: June 10, 2021

Create a real-time sequence that uses channel references to measure how long the engine takes to settle at a specified RPM.

Before you begin, create a real-time sequence with a channel reference.
  1. In the Stimulus Profile Editor, click the Start Page tab.
  2. Click New Real-Time Sequence.
  3. Save the sequence as Measure Set Preference tutorial in the <Common Data>\VeriStand Projects\Engine Demo\Stimulus Profiles\Engine Demo Channel References directory.
  4. Create variables.
    1. In the Primitives palette, expand Variables, drag a Double into the Return Variable section of the Variables pane, and enter its Identifier as SettleTime
    2. Create and configure the following Double parameters and local variable.
      Variable Type Name Evaluation Method Units
      Parameter Setpoint ByValue rpm
      Parameter Tolerance ByValue rpm
      Parameter Timeout ByValue s
      Local variable StartTime ByValue s
    3. In the Variables pane, right-click Channel References and click Insert Channels.
    4. In the Select channels dialog box, expand Aliases, enable ActualRPM and DesiredRPM, and click OK.
    The Variables pane will look like the following image.
  5. Add a setup expression for the set point of the engine.
    1. In the Primitives pane, expand Miscellaneous and drag Comment into Setup.
    2. In the Property Browser, enter the Comment as Set the desired set point for the engine.
    3. In the Variables pane, drag DesiredRPM into Setup.
    4. In the Property Browser, enter the Expression as DesiredRPM = Setpoint.
    The Setup block of the sequence code uses the DesiredRPM channel reference to change the value of the DesiredRPM channel to the specified Setpoint. You specify the value of the Setpoint parameter when you call this sequence from the stimulus profile. By configuring the real-time sequence this way, you can call this sequence from the stimulus profile to measure the settle time of various set points.
  6. Add main expressions to measure how long it takes for the engine to settle at its RPM set point.
    1. In the Primitives pane, drag Comment into Main.
    2. In the Property Browser, enter the Comment as Measure how long it takes for the engine to settle at its RPM set point.
    3. In the Variables pane, drag StartTime into Main.
    4. In the Property Browser, enter the Expression as StartTime = abstime().
    5. In the Sequences pane, expand Real-Tim Sequence Library»Standard»Timing and drag WaitUntilSettled into Main.
    6. In the Property Browser, enter the Expression as WaitUntilSettled(ActualRPM, DesiredRPM + Tolerance, DesiredRPM - Tolerance, 1.0, Timeout).
    7. In the Variables pane, drag SettleTime into Main.
    8. In the Property Browser, enter the Expression as SettleTime = abstime() - StartTime.
    The Main block of the sequence stores the absolute time at which the sequence starts to the StartTime local variable. The code waits for the RPM, as read from the ActualRPM channel, to settle into a range between the DesiredRPM plus or minus the specified Tolerance for at least one second or until it reaches the specified Timeout. When the RPM either settles or times out, the code returns how long it took the engine to settle at the specified RPM.
  7. 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