Topic: DMD0504

Help File Version: 2.9.4.37

Stage Transition Instructions


Using a "Jump" Operation to Transition Between Stages

The 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:

 

  • The Jump to Stage (JMP) and Jump to Multiple Stages (SGDIVRG) instructions immediately disable the stage in which they occur. The effect of being disabled will take effect on the subsequent scan, meaning the stage that executed the Jump to Stage (JMP) instruction will be inactive - and thus bypassed - on the next PLC scan.
     

  • The target stage in the Jump to Stage (JMP) instruction will be enabled immediately. All of the target stages in the Jump to Multiple Stages (SGDIVRG) instruction will be enabled immediately. What this means in terms of program execution is that the target stage(s) will execute when the PLC scan gets to them.
     

  • All of the rungs in the stage are executed during the current scan, even any rungs that follow the Jump to Stage (JMP) and Jump to Multiple Stages (SGDIVRG) instructions.
     

  • All output coils used in a stage will be automatically turned off on the scan immediately following the scan in which the Jump to Stage and Jump to Multiple Stages (SGDIVRG) instructions are executed. We will discuss this more completely in a later section, but for now, it is sufficient to know that all output coils used in a stage will be automatically turned off once the stage has been disabled.
     

  • Generally speaking, if an instruction has a single input it will be reset when the stage is disabled. If the instruction has multiple inputs, with one of them being a reset input, it will not be reset when the stage is disabled. This too will be discussed in more detail later.

 

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 Stages

There 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 Stages

There 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 Parameters

Some 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

Introduction

 

Example 1 - A Simple 2-State Process

 

Stage Transition Instructions

 

Example 2 - A Lamp On / Off Controller

 

Example 3 - A Garage Door Opener

 

Review - Steps to Writing Successful Stage Programs

Stage Programming Instructions

JMP - Jump To Stage

JMPI - Indexed Jump
 

SG - Stage
 

SGRST - Disable Stage

SGRSTR - Disable Range of Stages

SGSET - Enable Stage
 

SGDIVRG - Jump to Multiple Stages

SGCONVRG - Converge Multiple Stages to SG