Macro Function - Omron CPM1 - PROGRAMING MANUAL 02-2001 Programming Manual

Hide thumbs Also See for CPM1 - PROGRAMING MANUAL 02-2001:
Table of Contents

Advertisement

Macro Function

2-15 Macro Function

Using Macros
1, 2, 3...
Note *Input numbers 00005 and 00006 does not exist in CPM2C CPU Units with 10
I/O points.
The settings will go into effect when the mode is changed (from PROGRAM to
MONITOR/RUN) or when the power supply is turned ON to the PC.
The macro function allows a single subroutine (programming pattern) to be used
by simply changing the I/O word. A number of similar program sections can be
managed with just one subroutine, thereby greatly reducing the number of steps
in the program and making the program easier to understand.
To use a macro, call a subroutine by means of the MACRO instruction,
MCRO(99), as shown below, in stead of SBS(91) (SUBROUTINE ENTRY).
When MCRO(99) is executed, operation will proceed as follows:
1. The contents of the four consecutive words beginning with the first input
word will be transferred to SR 232 through SR 235.
2. The specified subroutine will be executed until RET(93) (Subroutine Return)
is executed.
3. The contents of SR 236 through SR 239 (results of the subroutine execu-
tion) will be transferred to the four consecutive words beginning with the first
output word.
4. MCRO(99) will then be finished.
When MCRO(99) is executed, the same instruction pattern can be used as
needed simply by changing the first input word or the first output word.
The following restrictions apply when the macro function is used.
The only words that can be used for each execution of the macro are the four
consecutive words beginning with the first input word number (for input) and
the four consecutive words beginning with the first output word (for output).
The specified inputs and outputs must correctly correspond to the words used
in the subroutine.
Even when the direct output method is used for outputs,subroutine results will
be actually reflected in the specified output words only when the subroutine
has been completed (step 3 above).
Note SR 232 through SR 239 can be used as work bits when MCRO(99) is not used.
The first input word and the first output word can be specified not with I/O bits, but
also with other bits (such as HR bits, work bits, etc.) or with DM words.
Subroutines called by MCRO(99) are defined by SBN(92) and RET(93), just as
are ordinary subroutines.
Section
MCRO(99)
Subroutine No
Fist input word
First output word
2-15
157

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents