The stepladder is described a rung at a time from left to right.
At the top of the scan, inputs are read from the MatPLC core. The
program is then scanned an instruction at a time from top to bottom (unless
a JMP
instruction changes this). Once scanning reaches the
bottom of the program or the special instruction END
, outputs
are written to the MatPLC core and the process starts over.
For all non-latching relays, make sure an OUT
or
OUTI
instruction is scanned on every scan. Otherwise relays
are latching: unless an OUT
, OUTI
,
SET
or RST
instruction changes them, they remain
as they were.
LD
contact/registerLDI
contactK
valueon
, off
or a number.
AND
contactANI
contactOR
contactORI
contactOUT
coil/registerThere should not normally be more than one OUT
or
OUTI
for each coil (unless one or the other is skipped using a
JMP
). Having more than one is valid, but will mean that some
rungs (between the first and second OUT
) will use the value
from the first OUT
, while a different value (from the second
OUT
) will actually appear on the output. This effect can be
quite useful, of course, as long as scan-order is taken into account.
OUTI
coilPlease see the remarks at the OUT
instruction.
SET
coilIt is somewhat more sensible to have a SET
or
RST
in combination with an OUT
than it is to have
two OUT
instructions. For instance, an exception logic
may wish to override a previous OUT
, setting the relay on or
off as appropriate. Nevertheless, care should be taken to avoid
confusion.
RST
coilPlease see the remarks at the SET
instruction.
LT
register
LE
register
GT
register
GE
register
MCS
LD
, LDI
and
OR
instructions will use this rail until another
MCS
or a MCE
.
Warning: this instruction is not a substitute for hard-wired safety and emergency stop circuits.
MCE
MCS
.
ANB
Unless you know what you are doing, you probably shouldn't have had an
OUT
on the previous rung.
ORB
Unless you know what you are doing, you probably shouldn't have had an
OUT
on the previous rung.
LTB
LEB
GTB
GEB
END
JMP
and LBL
.
JMP
labelIt is valid to jump into the middle of a rung: before the jump the current rung (which is on) is discarded and the previous rung reinstated as the current rung (and so on).
If the current rung is off, JMP
has no
effect and scanning continues as normal on the current rung.
LBL
labelJSR
subnameBefore the jump the current rung (which is on) is discarded and the previous rung reinstated as the current rung (and so on). This can be used to pass parameters to the subroutine.
If the current rung is off, JSR
has no
effect and scanning continues as normal on the current rung.
It is valid for a subroutine to JSR
another, or even itself
(directly or indirectly). In the latter case, care should be taken to avoid
infinite recursion and ensure that the subroutine eventually returns.
SUB
subnameSUB
instruction
or to the end of the program (though an END
can be used to
return from it prematurely).
The SUB
instruction always marks the end of the previous
subroutine or the main program. If it is encountered in normal scan, it
causes a subroutine return (in a subroutine) or a program scan end (in main
program), just like an END
.
The only way to get into a subroutine is with a JSR
. It is
not valid to JMP
in and out of subroutines or between
different subroutines.
RET
When this instruction results in a return from subroutine, the current rung (which is on) is discarded and the previous rung reinstated as the current rung (and so on). This can be used to return values from subroutines.
If the current rung is off, RET
has no
effect and scanning continues as normal on the current rung.
POP
NOP
Instructions appear one to a line. The instructions may appear in upper or lower case (ie "LD" is the same as "ld") but the contacts, coils and labels must agree exactly (ie "X1" is not the same as "x1").
Comments must appear on their own lines. They are indicated with a hash (#) or semicolon (;) at the beginning of a line.
Both instructions and comments may be indented from the left by any number of spaces and any number of spaces or tabs may be used to separate an instruction and its contact, coil or label.
At the start of each scan, both the current rung and previous rungs have
undefined values (which means they could be anything). This means that the
first instruction (other than LBL
or NOP
) must be
LD
or LDI
and similarly a sufficient number of
LD
or LDI
instructions must be scanned before an
ANB
or an ORB
.
$Date: 2004/12/28 05:32:11 $