Subroutine Instructions; Subroutines - Omron CJ - INSTRUCTIONS REFERENCE MANUAL 07-2009 Reference Manual

Programmable controllers
Hide thumbs Also See for CJ - INSTRUCTIONS REFERENCE MANUAL 07-2009:
Table of Contents

Advertisement

3. Instructions

Subroutines

Subroutine instruction
In the CS/CJ Series, function blocks and subroutines can be used as a means of structuring programs.
The advantages and disadvantages of each are as follows:
Differences between function blocks and subroutines
Unit versions of CPU
CS1-H, CJ1-H, CJ1M CPU Units: Unit version 3.0 or later
units that can be used
CJ2 CPU Units: All unit versions
Process names
Instance names can be assigned.
Clarification of input and
Clarification as FB input variable or output variable is possible
output
Variable names
Names can be assigned to variables
Internal variables
Yes
When instance names are the same, the same variable is
accessed. When instance names are different, different
variables are accessed. As such, data can be stored
separately for each call (instance) in a function block.
Using timers in function blocks does not result in
duplicated use.
Program writing method
Variable programming by ladder or ST language
Indication by diagram
Processing content and input/output parameters are easier to
understand (visibility can be heightened)
Input/output parameters can be clarified
Protection
Read protect can be set for each function block
(Supported from CX-Programmer 6.1)
Storing
Can be stored by function block
The subroutine function has two types of subroutines: regular subroutines and global subroutines.
The differences between the two types are as follows.
Differences between regular subroutines and global subroutines
Functions
A subroutine within the same task can be called.
For example, a subroutine in task 0 cannot be called from task
1.
Combined-use
SBS (subroutine call) instruction
instructions
SBN (subroutine entry) instruction
RET (subroutine return) instruction
Entry in subroutine
Entered at the end of the task that uses the subroutine (before
program
the END instruction).
678
Function blocks
Processing content can be clarified
Control of
heater A
Present
value read
(BOOL)
(BOOL)
ENO
EN
&10
Temperature control
Current
D100
number
temperature
D1
Set value
Internal variables are different
Using timers does not result in
Control of heater A
duplicated use (different timers
Present value read
are used)
(BOOL)
(BOOL)
ENO
EN
&11
Temperature control
Current
D102
number
temperature
D2
Set value
Regular subroutines
Subroutines
All unit versions
Names cannot be assigned
Clarification is not possible
Variable names can be assigned
No
All subroutines are accessed using the same variables.
For this reason, data cannot be stored separately for
each call in a subroutine.
If timers are used in a subroutine, duplicated timer use
will result.
Address programming by ladder
Address programming by ladder
MOV &10
Temperature control number
MOV D1 Set value
SBS 10
MOV Current temperature D100
MOV &11
Temperature control number
MOV D2 Set value
SBS 10
MOV Current temperature D102
No protect function
Storing is not possible by subroutine.
Global subroutines
Global subroutines can be called from all tasks.
A subroutine in interrupt task 0 can be called from any task.
GSBS (global subroutine call) instruction
GSBN (global subroutine entry) instruction
GRET (global subroutine return) instruction
Entered at the end of interrupt task 0 (before the END
instruction).
CS/CJ/NSJ Series Instructions Reference Manual (W474)
Input/output parameters
cannot be clarified
Variables used internally are
the same When timers are used,
duplicate timer use results

Advertisement

Table of Contents
loading

Table of Contents