Topic: DMD0504 Stage Transition Instructions |
|
Using a "Jump" Operation to Transition Between StagesThe previous examples have used the Jump to Stage (JMP) instruction to transition between stages. Recall that the Jump to Stage (JMP) instruction does two things: it deactivates the stage in which the instruction occurs, and activates the stage referred to in the Jump to Stage (JMP) instruction.
Please Read This Carefully The functionality of the Jump to Stage (JMP) instruction can be easily misunderstood. The term ”jump” sounds like the instruction would function like a GOTO instruction when executed, that is, processing would immediately begin at the target of the "jump"this is wrong! Here are some general rules to keep in mind when dealing with the Jump to Stage (JMP) and Jump to Multiple Stages (SGDIVRG) instructions:
Refer to the two-stage program examples below. Here’s how the Jump to Stage (JMP) instruction functions:
In this example, stage S0 is enabled. When X0 comes ON the Jump to Stage (JMP) S1 executes. Stage S1 is executed during the same scan turning Y0 ON. This is because stage S1 follows stage S0.
In this example, stage S1 is enabled. When X0 comes ON the Jump to Stage (JMP) S0 executes. However, Stage S0 is executed the next scan. Thus Y0 will come ON during the next scan not the same scan the JMP was executed. This is because stage S0 precedes stage S1.
|
|
Using "Enable / Disable" Operations to Transition Between StagesThere are three additional stage programming instructions that allow for stage-to-stage transitions: they are Enable Stage (SGSET), Disable Stage (SGRST), and Disable Range of Stages (SGRSTR).
Whereas the Jump to Stage (JMP) and Jump to Multiple Stages (SGDIVRG) instructions enable the target stage and disable the current stage, the Enable Stage (SGSET) and Disable Stage (SGRST) instructions only enable and disable the target stage; they do not necessarily disable the current stage. The Disable Range of Stages (SGRSTR) disables a range of consecutive stages.
A Jump to Stage (JMP) instruction is functionally equivalent to an Enable Stage (SGSET) of the target stage paired with a Disable Stage (SGRST) of the current stage.
|
|
Using a "Converge" Operation to Transition Between Multiple StagesThere is a special stage programming instruction that allows for multiple stages that are enabled to be converged to one stage when all stages in its list are enabled, and a condition is non-zero (TRUE / ON). It is called Converge Multiple Stages to SG (SGCONVRG).
The instruction is a Stage itself (e.g. S7 in the picture above). In the instruction above, when Stages S1, S2 and S3 are all enabled, and then C0 is ON, Stages S1, S2 and S3 will be disabled when the Transition to Stage S7 is executed. This one instruction is equivalent to using a rung in each of the Stages (S1, S2 and S3) that has a normally-open contact C0 turning ON an SGRST disabling themselves, and then using an SGSET enable Stage S7.
|
|
Instructions that Use Stage Transitions as ParametersSome instructions have parameters that can be configured to optionally perform stage transition operations. For example the class of instructions called Fully Asynchronous have two parameters (On Success and On Error) that can be configured to either Set a Bit ON or Jump to a Stage. Refer to the Clear Device (DEVCLEAR) example below:
If the Jump to Stage selection is used the instruction itself must be placed within a Stage and the target Stage must be in the same Program code-block as the instruction, you cannot specify a target Stage that exists in a different Program code-block. When the instruction complete the transition operation will enable the target Stage in the same way as a standalone Jump to Stage (JMP) instruction.
|
|
Stage Programming Concepts
Example 1 - A Simple 2-State Process
Example 2 - A Lamp On / Off Controller
Example 3 - A Garage Door Opener
Review - Steps to Writing Successful Stage Programs Stage Programming InstructionsSGRSTR - Disable Range of Stages SGDIVRG - Jump to Multiple Stages SGCONVRG - Converge Multiple Stages to SG
|
|