Program in Advanced Ladder
See also: Project Toolbox for Advanced Ladder
Topic Menu
Home > View > Project Toolbox > Programs Operations
Label 
A label allows a position in the ladder program to be named. This name can be used with a JUMP or CALL instruction to cause program execution to change from one section to another.
Note: There can only be one label with a particular label name in a program. Labels can be inserted without matching jumps, but a jump must be matched with a label.
Jump to Label 
Use the JUMP element to cause a portion of the logic to be bypassed. The JUMP can be either a forward or a backward JUMP. Logic execution will continue at the LABEL specified. When the JUMP is active all coils within its scope are frozen. This includes coils associated with timers, counters, relays, etc. No elements can be placed after the jump element. When the jump is active program execution jumps directly from the jump element to the associated label.
Note: To avoid creating an endless loop with backward JUMP elements, a backwards JUMP must contain a way to make it conditional.
Right-click on a Jump or Call to find the associated Label.
Return to the Top: Program in Advanced Ladder
Call Subroutine 
Use the CALL element to call a subroutine. If power flow into the CALL is on, execution will move to the portion of ladder defined by a LABEL. When a RETURN element is executed in the subroutine, the execution will resume on the rung following the CALL element. Subroutines can be nested (calling a subroutine inside a subroutine) up to 8 levels deep. If more than 8 levels of nesting are attempted, the controller will stop and the logic error flag in the diagnostics will be set. No elements can be placed after a CALL element.
Note: Subroutines should not contain timer, counter, serial send or serial receive function blocks. These function block depend on being called the first scan or detecting changes each time a scan completes.
Example
-
Start on rung 1, CALL the subroutine.
-
Execute first line of subroutine, rung 5 (rung 4 is only a LABEL indicating the start of a section).
-
Execute rung 6, the RETURN causes execution to start on the rung after the last CALL, rung 2.
-
Execute rung 2, CALL the subroutine again.
-
Execute first line of subroutine, rung 5 (rung 4 is only a LABEL indicating the start of a section).
-
Execute rung 6, the RETURN causes execution to start on the rung after the last CALL, rung 3.
-
Execute rung 3, END PROGRAM ends this scan. After I/O and other processing start over at rung 1.
Return from Subroutine 
Use the RETURN element to return from a subroutine call. If power flow is enabled, this will return ladder execution to the rung following the last CALL. If a RETURN is executed without a CALL, the controller will stop and the Logic Error diagnostic flag will be set. No elements can be placed after a RETURN element.
End of Program 
Use this element to end the program scan. This element does not need a contact before it. When this element is executed the scan is immediately finished, I/O is read, other housekeeping is performed and another scan is started. This can be used to separate a main section of ladder from subroutines as seen in the example above, or can be used to temporally disable a portion of the ladder program for testing. No elements can be placed before or after a END PROGRAM element.
Return to the Top: Program in Advanced Ladder