Create a new subroutine screen to which the instruction will jump, and create a subroutine program on the screen.
You can insert JSR instructions anywhere in the logic program.
When a display unit executes a JSR instruction, the instruction jumps to the given subroutine with the defined name and the subroutine is executed.
For example, a subroutine could reset counters every time the display unit is turned on.
Creating a Subroutine
On the toolbar or the [Screen List] window, click . The [New Screen] dialog box appears.
You can display the [New Screen] dialog box in either of the following ways.
Right-click the logic screen in the [Screen List] window and select [New Screen (N)].
On the [Screen (S)] menu, click [New Screen (N)].
If the [Screen List] tab is not displayed on the work space, on the [View (V)] menu point to [Work Space (W)] and then click [Screen List (G)].
In [Screens of Type], select [Logic] and in [Logic Name], select the subroutine name (for example, SUB-01).
Input the title when necessary. You can input up to 30 characters.
Click [New]. The subroutine screen will be displayed.
Create the subroutine.
To add more than one subroutine to a logic program, repeat the steps to create the desired number of subroutine programs.
Inserting a JSR Instruction
To execute the subroutine you created in a specific location in the main logic program [MAIN], you must insert a JSR instruction.
Here, for example, a subroutine [SUB-01] is executed when the OUT instruction (Lamp) on the second rung turns on. The JSR instruction is inserted in the 3rd rung.
Select the second rung to insert a rung.
For information on inserting rungs, refer to the following.30.4.1.1 Inserting Rungs
Insert a PT instruction on the third rung (Positive Transition) and assign the symbol variable (Lamp) to the PT instruction.
For information on inserting instructions, refer to the following.30.5.1 Inserting Instructions
For the operand settings, refer to the following.30.6 Assigning Addresses to Instructions
For details on instructions, refer to the corresponding logic instruction.32. Logic Instruction List
Insert the JSR instruction to the right of the PT instruction.
For the JSR instruction operand, specify the [SUB-01] subroutine.
When the "Lamp" ON is detected, the operation jumps to the subroutine program [SUB-01]. After the subroutine program [SUB-01] is executed, the main logic program [MAIN] resumes on the fourth rung.