Topic: DMD0156
YIELD - Yield Program or Task |
|
The Yield Program or Task (YIELD) instruction is used to stop execution of a Program or Task and pass control to the next Program or Task, or to the main ladder logic program. Unlike other Yielding instructions - For/Next, While/Wend, Repeat/Until, etc. - the Yield instruction yields regardless of the code-block's .TimeSlice value.
When executed, the YIELD instruction will store the location of the next instruction in the Program or Task, as this is where processing will resume the next time the Program or Task is run.
One instance where the this instruction is particularly useful is when there is a Program or Task that contains enough ladder logic to increase the scan time by an unacceptable amount, for example, a Program that runs an end-of-day report. Divide the code-block into segments with one or more Yield instructions so that executing the ladder logic in any one of the segments will keep the scan time at an acceptable level.
Then, once the code-block begins executing, only the ladder logic between the first rung and the first Yield instruction will execute on the first scan of the Program. On the next scan the ladder logic between the first and second Yield instructions will be executed, and so forth until all of the segments of ladder logic. Refer to the following pseudo-code:
Program Start
Ladder Code
Ladder Code Ladder Code
Yield
Ladder Code
Ladder Code
Yield
Ladder Code
Ladder Code
Ladder Code
This process of segmenting the ladder logic into subsections that will be run on subsequent executions allows the Do-more Controller to process fewer instructions per scan, which keeps the scan time as low as possible. Of course it is the responsibility of the developer to decide where to place the YIELD instructions so that the application still functions and the scan time is minimized.
Note: this instruction is a 'power-rail' instructions. Even though the instruction is displayed in the left-most column of the ladder diagram (the power rail), it is created in the right-most column of the ladder logic diagram (the output column). Creating this instruction in Do-more Designer is a bit counter-intuitive because the first step is to position the edit cursor in the output column of the ladder logic diagram (the far right) instead of positioning it against the power rail (the far left).
|
|
Parameters:There are no parameters for this instruction.
|
|
See Also:
|
|
Related Topics:
|
|
Rung Example:
|
|