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" in the 2nd rung turns on. The JSR instruction is inserted in the 3rd rung.
Select the 2nd rung to enter the rung.
For how to enter a rung, refer to the following.29.4.1.1 Inserting Rungs
Insert a PT instruction in the 3rd rung (Positive Transition) and assign the symbol variable "lamp" to the PT instruction.
For how to enter an instruction, refer to the following.29.5.1 Inserting Instructions
For the operand settings, refer to the following.29.6 Allocating Addresses to Instructions
For details on an instruction, refer to the explanation of the relevant instruction.Chapter 31 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 in the 4th rung.