The program control functions are used when a series of conditional or unconditional jump and return instruction are required. These instructions allow the program to execute only certain sections of the control logic if a fixed set of logic conditions are met. The most common instructions for the program control available in most controllers are described in this section.
The MCR output instruction is used to activate and deactivate the execution of a group or zone of ladder rungs. The MCR is used in conjunction with an END MCR (END MCR) coil to place a fence around the group of rungs.
The jump instruction allows the CPU to jump to a new position in the ladder diagram from the normal sequential execution. If the jump logic rung is true, the jump coil (JMP) instructs the CPU to jump to and execute the rung labelled with the same reference address as the jump coil. This allows the program to execute rungs out of the normal sequential flow of a standard ladder program.
The label (LBL) is to identify that ladder rung which is the destination of a jump instruction. The label reference must match that of the jump instruction with which it is used. The label instruction does not contribute to logic continuity, and it is always logically true. It is placed as the first logic condition in the rung. A label instruction referenced by a unique address can be defined only once in a program.
The RET instruction is used to terminate a ladder jump subroutine. The output coil is
programmed normally without any rung logic inputs. When a RET coil is encountered, the program returns to the spot where is left the main program and begins at the ladder rung immediately following the jump instruction that initiated the subroutine. Normal program execution continues from that point. A return must used at the end of each subroutine.