Order of Execution

The
Logix Designer
programming application automatically determines the order of execution for the function blocks in a routine when you:
  • verify a function block routine
  • verify a project that contains a function block routine
  • download a project that contains a function block routine
You define execution order by wiring function blocks together and indicating the data flow of any feedback wires, if necessary.
If function blocks are not wired together, it does not matter which block executes first. There is no data flow between the blocks
fbd_ExOrder1
If you wire the blocks sequentially, the execution order moves from input to output. The inputs of a block require data to be available before the controller can execute that block. For example, block 2 has to execute before block 3 because the outputs of block 2 feed the inputs of block 3.
fbd_ExOrder2
Execution order is only relative to the blocks that are wired together. The following example is fine because the two groups of blocks are not wired together. The blocks within a specific group execute in the appropriate order in relation to the blocks in that group.
fbd_ExOrder3
Resolve a Loop
To create a feedback loop around a block, wire an output pin of the block to an input pin of the same block. The following example is OK. The loop contains only a single block, so execution order does not matter.
ResolveLoopEx1
If a group of blocks are in a loop, the controller cannot determine which block to execute first. In other words, it cannot resolve the loop.
ResolveLoopEx2
To identify which block to execute first, mark the input wire that creates the loop (the feedback wire) with the
Assume Data Available
indicator. In the following example, block 1 uses the output from block 3 that was produced in the previous execution of the routine.
Localized feedback wire
The
Assume Data Available
indicator defines the data flow within the loop. The arrow indicates that the data serves as input to the first block in the loop.
Do
not
mark all the wires of a loop with the
Assume Data Available
indicator.
ResolveLoopEx4
Resolve Data Flow Between Two Blocks
If you use two or more wires to connect two blocks, use the same data flow indicators for all of the wires between the two blocks.
Resolve Data Flow Between Two Blocks
Create a One Scan Delay
To produce a one scan delay between blocks, use the Assume Data Available indicator. In the following example, block 1 executes first. It uses the output from block 2 that was produced in the previous scan of the routine.
OneScanDelayEx1
Summary
In summary, a function block routine executes in this order:
  1. The controller latches all data values in IREFs.
  2. The controller executes the other function blocks in the order determined by how they are wired.
  3. The controller writes outputs in OREFs.
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.