Company Events Academic Community Support Solutions Products & Services Contact NI MyNI

Timed Loop

LabVIEW 2011 Help

Edition Date: June 2011

Part Number: 371361H-01

»View Product Info
Download Help (Windows Only)

Owning Palette: Timed Structures and VIs

Requires: Base Package (ETS, VxWorks, Windows)

Executes one or more subdiagrams, or frames, sequentially each iteration of the loop at the period you specify. Use the Timed Loop when you want to develop VIs with multirate timing capabilities, precise timing, feedback on loop execution, timing characteristics that change dynamically, or several levels of execution priority. Right-click the structure border to add, delete, insert, and merge frames.

Note  If you use the Timed Loop in an FPGA VI, you must use a single-cycle Timed Loop. A single-cycle Timed Loop executes one subdiagram per FPGA clock cycle. Single-cycle Timed Loops do not support frames.

The iteration (i) terminal provides the current loop iteration count, which is zero for the first iteration. If iteration count exceeds 2,147,483,647, or 231-1, the iteration terminal remains at 2,147,483,647 for all further iterations. If you need to keep count of more than 2,147,483,647 iterations, you can use shift registers with a greater integer range.

The Timed Loop includes the (1) Input and (4) Output nodes, and (2) Left and (3) Right Data nodes for each frame, as shown in the previous illustration. By default, nodes of the Timed Loop do not display all of the available input and output terminals. You can resize nodes or right-click a node and use the shortcut menu to display node terminals. Right-click the border of a Timed Loop and select Show Left Data Node or Show Right Data Node from the shortcut menu to display each node.

Double-click the Input Node or right-click the structure and select Configure Timed Loop to display the Configure Timed Loop dialog box, where you can configure the Timed Loop. The values you enter in the Configure Timed Loop dialog box appear next to the input terminals on the Input Node.

The following table lists node terminals of the Timed Loop.

(1) Input Node

DeadlineSpecifies the time when the Timed Loop must complete the iteration. Deadline equals Period if you do not specify a value. The deadline value is relative to the start of the Timed Loop and is specified in units of the timing source.
ErrorPropagates errors through the structure. The Timed Loop does not execute if Error receives an error condition.
ModeSpecifies how the Timed Loop handles late executions. There are five available modes—No change, Process missed periods maintaining original phase, Process missed periods ignoring original phase, Discard missed periods maintaining original phase, and Discard missed periods ignoring original phase.
Structure NameSpecifies a name for the Timed Loop.
OffsetSpecifies the length of time a Timed Loop waits to begin execution. The offset value is relative to the start of the Timed Loop and is specified in units of the timing source.
PeriodSpecifies a period for the Timed Loop in the same units as the timing source specified by Source Name.
PrioritySpecifies the priority of the execution of the Timed Loop. The priority of a timed structure specifies when the structure executes on the block diagram relative to other objects on the block diagram. The value for the Priority input must be a positive integer between 1 and 65,535.
ProcessorSpecifies the processor you want to handle execution. The default is -2, which means LabVIEW automatically assigns a processor. To manually assign a processor, enter a number between 0 and 255, where 0 represents the first processor. If you enter a number that exceeds the number of available processors, you generate a run-time error and the timed structure does not execute.
Source NameSpecifies the name of the timing source to use for controlling the structure. The timing source must be created on the block diagram using the Create Timing Source VI or selected from the Configure Timed Loop dialog box.
TimeoutSpecifies the maximum amount of time a Timed Loop can wait to begin execution. The default is -1,which means that no timeout is specified for the next frame. The timeout value is relative to the start of the Timed Loop or the end of the previous iteration and is specified in units of the frame timing source.

(2) Left Data Node

Actual End [f-1] (Unavailable in singe-frame Timed Loop)Returns the actual end time for the previous frame (f-1). The actual end value is relative to the start time of the Timed Loop and is specified in units of the timing source.
Actual End [i-1] (First frame only)Returns the actual end time for the previous iteration (i-1). The actual end value is relative to the start time of the Timed Loop and is specified in units of the timing source.
Actual Start [f] (Unavailable in single-frame Timed Loop)Returns the actual start time of the current frame (f). The actual start value is relative to the start time of the Timed Loop and is specified in units of the frame timing source.
Actual Start [i] (First frame only)Returns the actual start time of the current iteration (i). The actual start value is relative to the start time of the Timed Loop and is specified in units of the timing source.
DeadlineReturns the deadline value for the current frame.
ErrorPropagates errors through the structure.
Expected End [f-1] (Unavailable in single-frame Timed Loops)Returns the expected end time for the previous frame (f-1). The expected end value is relative to the start time of the Timed Loop and is specified in units of the timing source. The expected end (f-1) is equal to the start of the next period.
Expected End [i-1] (First frame only)Returns the expected end time for the previous iteration (i-1). The expected end value is relative to the start time of the Timed Loop and is specified in units of the timing source.
Expected Start [f]Returns the expected start time of the current frame (f). The expected start value is relative to the start time of the Timed Loop and is specified in units of the frame timing source.
Expected Start [i] (First frame only)Returns the expected start time of the current iteration (i). The expected start value is relative to the start time of the Timed Loop and is specified in units of the timing source.
Finished Late? [f-1]Returns TRUE if the Timed Loop does not complete the previous frame before the specified deadline.
Finished Late? [i-1] (First frame only)Returns TRUE if the Timed Loop does not complete the previous iteration before the specified deadline.
Frame Duration (Unavailable in single-frame Timed LoopsReturns the duration time of the previous frame. The frame duration is relative to the start of the frame and is specified in units of the frame timing source.
Global End TimeReturns a time stamp for the end of the previous iteration in nanoseconds.
Global Start TimeReturns a time stamp for the start of the current frame in nanoseconds.
Iteration Duration (First frame only)Returns a time stamp of the duration of the previous iteration. The iteration duration value is relative to the start of the iteration and is specified in units of the timing source.
Mode (First frame only)Returns the mode value for the current iteration.
Offset (First frame only)Returns the offset value for the start of the current iteration.
Period (First frame only)Returns the period value for the current frame.
PriorityReturns the priority value for the current frame.
ProcessorReturns the processor you assigned to handle execution, if you assigned one. Otherwise, returns -2, which means LabVIEW automatically assigned a processor.
Start (Unavailable in first frame)Returns the start value for the current frame.
TimeoutReturns the timeout value for the current frame.
Wakeup ReasonReturns an enumerated type with the reason for the execution start of the current iteration. The possible values are 0 for Normal, 1 for Aborted, 2 for Asynchronous wakeup, 3 for a Timing source error, 4 for a Timed loop error, and 5 for Timeout.

(3) Right Data Node

DeadlineSpecifies the time when the Timed Loop must complete the next frame. The deadline value is relative to the start of the next frame and is specified in units of the timing source. The default is -1, which means unchanged.
ErrorPropagates errors or warnings out of the Timed Loop subdiagram. If Error receives an error condition, the Timed Loop executes the next frame untimed. If Error receives an error condition in the last frame, the structure finishes executing the current iteration untimed, exits the loop, and returns the error condition on the Output node.
Mode (Last frame only)Specifies the Mode for the next iteration of the Timed Loop. There are five available modes—No change, Process missed periods maintaining original phase, Process missed periods ignoring original phase, Discard missed periods maintaining original phase, and Discard missed periods ignoring original phase.
Offset (Last frame only)Specifies the length of time the next iteration waits to begin execution. The offset value is relative to the start of the next iteration and is specified in units of the timing source. The default is -1, which means unchanged. If you set an offset for the next iteration, you must set a new Mode value.
Period (Last frame only)Specifies a period for the next iteration of a Timed Loop in units as the timing source. The default is -1, which means unchanged.
PrioritySpecifies the Priority for the next iteration of the Timed Loop. The priority specifies when the next iteration executes on the block diagram relative to other objects on the block diagram. The value for the Priority input must be a positive integer between 1 and 65,535.
ProcessorSpecifies the processor you want to handle execution. The default is -1, which means LabVIEW assigns the same processor specified in the Input node. Enter -2 to allow LabVIEW to assign the processor. To manually assign a processor, enter a number between 0 and 255, where 0 represents the first available processor. If you enter a number that exceeds the number of available processors, you generate a run-time error and the timed structure does not execute.
Start (Unavailable in last frame)Specifies the length of time the next frame waits to start execution. The start value is relative to the end of the current frame and is specified in units of the timing source.
TimeoutSpecifies the maximum amount of time the next iteration can wait to begin execution. The default is -1, which means that no timeout is specified for the next iteration. The timeout value is relative to the end of the previous iteration and is specified in units of the frame timing source.

(4) Output Node

Actual End [f-1] (Unavailable in single-frame Timed Loops)Returns the actual end time for the previous frame (f-1). The actual end value is relative to the start time of the Timed Loop and is specified in units of the timing source.
Actual End [i-1]Returns the actual end time for the previous iteration (i-1). The actual end value is relative to the start time of the Timed Loop and is specified in units of the timing source.
ErrorPropagates errors received by the Timed Loop and returns errors from the subdiagram.
Expected End [f-1] (Unavailable in single-frame Timed Loops)Returns the expected end time for the previous frame (f-1). The expected end value is relative to the timed structure if the frame timing source is not reset at the beginning of the iterations. The expected end value is specified in units of the timing source. The expected end (f-1) is equal to the start of the next period.
Expected End [i-1]Returns the expected end time for the previous iteration (i-1). The expected end value is relative to the timed structure if the frame timing source is not reset at the beginning of the iterations. The expected end value is specified in units of the timing source.
Finished Late? [f-1] (Unavailable in single-frame Timed Loops)Returns TRUE if the Timed Loop does not complete the previous frame before the specified deadline.
Finished Late? [i-1]Returns TRUE if the Timed Loop does not complete the previous iteration before the specified deadline.
Frame Duration (Unavailable in single-frame Timed Loops)Returns the duration time of the previous frame. The frame duration is relative to the start of the frame and is specified in units of the frame timing source.
Global End TimeReturns a time stamp for the end of the previous iteration in nanoseconds.
Iteration DurationReturns a time stamp of the execution length of the previous iteration. The iteration duration is relative to the start of the iteration and is specified in units of the timing source.
ProcessorReturns the processor you assigned to handle execution, if you assigned one. Otherwise, returns -2, which means LabVIEW automatically assigned a processor.

Refer to the Configuring Timed Loops topic for more information about using and configuring the Timed Loop.

To convert a Timed Loop to a While Loop, right-click the Timed Loop and select Replace with While Loop from the shortcut menu. To convert a Timed Loop to a Timed Sequence structure, right-click the Timed Loop and select Replace with Timed Sequence from the shortcut menu.

Note  (ARM) The Configure Timed Loop dialog box is different for ARM targets, which support only a subset of Timed Loop configuration options.

Unlike the While Loop, the Timed Loop does not require wiring to the stop terminal. If you do not wire anything to the stop terminal, the loop will run interminably.

Refer to the Timed Loop (FPGA Module) topic for more information about using and configuring the Timed Loop in FPGA Vis.

(ARM) The Processor terminal for the Timed Loop is unsupported in ARM Vis.

Examples

Refer to the following VIs for examples of using the Timed Loop:

  • Offset for the Timed Loop VI: labview\examples\general\timedloop.llb
  • Optimizing timed loop rate VI: labview\examples\general\timedloop.llb
  • PAC Simulation With Frames VI: labview\examples\general\plat-timedloopframes.llb
  • PAC Simulation VI: labview\examples\general\timedloop.llb
  • Resettable Timing VI: labview\examples\general\timedloop.llb

 

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
Add Comments 1 2 3 4 5 submit