xLadder user manual-V2.0.0.6

6.18 Subroutine

6.18.1 Using subroutine

Subroutine is used for program partitioning.When the main program calls subroutine

and performs the subroutine,subroutine executes all instructions to the end.Then,

the system returns to the main program.

Subroutine is used for program partitioning.It helps to read and manage programs. It

also helps to debug and maintain programs.You can use PLC more effectively by using

subroutine.Because all of the subroutine blocks are not scanned when they are not

called.

If the subroutine only references parameters and local memory,then the subroutine

can be moved.In order to move the subroutine,you can not use any global variables /

symbols (I, Q, M, SM, AI, AQ, V, T, C, S, AC absolute address).If the subroutine does

not call parameters (IN, OUT, or IN_OUT) or only uses local variables,You can export

the subroutine and import it into another project.

Conditions of using subroutine:

1.Create a subroutine

2.Define parameters in the local variable table.

3.Call subroutine from the appropriate POU (from the main program or another

subroutine)

Using subroutine does not save or restore the accumulator.

207

Made with FlippingBook - Online magazine maker