EasyManua.ls Logo

PI MS249E - Page 111

PI MS249E
279 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
7 Operation
C-863.12 Mercury Controller MS249E Version: 1.2.1 105
Example: Implementing multiple calls of a macro via a loop
INFORMATION
When macros are recorded on the Controller macros tab in PIMikroMove, the MAC BEG and
MAC END commands must be left out.
The TESTDION macro checks the status of the digital input lines on the I/O socket. It uses a local
variable to identify the digital input line (1 to 4). So that the TESTDION macro does not have to
be called separately for each input line, another macro with a loop is recorded.
Record the LOOPDION macro by sending:
MAC BEG loopdion
VAR COUNTER 1
MAC START TESTDION ${COUNTER}
ADD COUNTER ${COUNTER} 1
JRC -2 VAR? COUNTER < 5
MAC END
The COUNTER variable is created with the value 1. After this, the TESTDION macro is
started for the input line whose identifier is specified via the COUNTER variable. Then
the value of the COUNTER is increased by 1. As long as the value of the COUNTER is less
than 5, the macro execution pointer subsequently jumps two lines back, so that the
TESTDION is now started for the next digital input line.
Stopping a macro
INFORMATION
You can link the stopping of the macro execution to a condition with the MEX command. The
command must be included in the macro.
In the following, PITerminal or the Command entry window of PIMikroMove is used to enter
commands. Details on working with the Controller macros tab in PIMikroMove are in the
PIMikroMove manual.
Stop the macro execution with the #24 or STP commands.
If you want to check whether an error has occurred during macro execution, send the
MAC ERR? command. The response shows the last error that occurred.

Table of Contents

Related product manuals