Mitsubishi Melsec A User Manual page 61

Table of Contents

Advertisement

7. COMMUNICATION WITH PROGRAMMABLE CONTROLLER CPU
/MELSEC
[Program example]
Inputs X I 3 and X I B are turned on and off respectively and the resul-
tant onloff condition is stored in head addresses 6000H and 6001 H.
(1) Program t o switch on X I 3
100 A=PEEK($6000)
. .
.Reads address 6000H from the common area
(This byte is all '0's).
110 B=A ! $08.
. . . . . .
.Executes a logical OR operation w i t h address
6000H and a "dummy"
byte containing the
binary representation of 8 as follow:
Bit pattern
Address 6000H
0 0 0 0 0 0 0 0
82
0 0 0 0 1 0 0 0
OR result
0 0 0 0 1 0 0 0
The result is written t o variable B.
120 POKE $6920,
B . . .
.Variable B is written t o address 6920H (i.e. the
user work area reserved for accessing the general-
purpose
110).
130 POKE $6000. B
. . .
.The result is also written t o address 6000H.
140 END
(2) Program t o switch off X I B
100 A=PEEK($6001)
. .
.Reads address 6001H from the common area
(This byte is all '0's).
110 B = A ~ $ F ~ .
. . . . .
.
.Executes a logical A N D operation w i t h address
6000H and a dummy byte containing the binary
representation of F7 as follows:
Bit pattern
Address 6000H
0 0 0 0 0 0 0 0
F72
1 1 1 1 0 1 1 1
A N D result
0 0 0 0 0 0 0 0
The result is written into variable B.
120 POKE $6940, B
. . .
.Variable B is written t o address 6940H (i.e. the
user work area reserved for accessing the general-
purpose
110).
130 POKE $6001, B
. . .
.The result is also written t o address 6001 H.
140 END
POINT
*:
X I D to I F cannot be turned onloff in the BASIC pro-
gram. The value marked
*
in line 110 of (2) may also be
17H (bits 5 to 7
=
0 ) . I f AND operation is performed,
the same result is obtained.

Advertisement

Table of Contents
loading

Table of Contents