Example - Ladder Diagram
RET
The RET instruction declares the end of a subroutine block.
Ladder Diagram Example
- An existing subroutine program must be placed after the END instruction in the scan program.
- A subroutine is called using the CALL or CALLP instruction.
- The subroutine ID, n, must match the corresponding CALL or CALLP instruction.
Example 1
When the contact, M0.0, is powered OFF (0), the CALL instruction is NOT calling the SBRT instruction.
As a result, the data register, D0, is NOT increasing every 1 scan by the INCP instruction.
When the contact, M0.0, is powered ON (1), the CALL instruction is calling the SBRT instruction.
As a result, the data register, D0, is increasing every 1 scan by the INCP instruction.
Example 2
![]()
When the contact, M0.0, is powered OFF (0), the CALL instruction is NOT calling the SBRT instruction.
As a result, the data register, D0, is NOT increasing every 1 scan by the INCP instruction.
Additionally, the coil, Y2.0, is deenergized since the subroutine program with the ID 20 is not being called.
![]()
When the contact, M0.0 is powered OFF (0) and the contact, M0.1, is powered ON (1), the coil, Y2.0, remains deenergized.
This is because the subroutine program with the ID 20 is not being called.
![]()
When the contacts, M0.0 and M0.1, are powered ON (1), the data register, D0, is increasing every 1 scan by the INCP instruction and the data register, Y2.0, is energizing every 1 second.
Both subroutines are being called allowing both poritons of the ladder logic to execute.