Mitsubishi Melsec A User Manual page 85

Table of Contents

Advertisement

7. COMMUNICATION WITH PROGRAMMABLE CONTROLLER CPU
/MELSEC
(2) Sequence program write
[Program example]
Program to write the main sequence program and parameters
from the AD51 t o the PC CPU.
Channel
2
EOOOH t o E FFFH +Sequence program (2K steps)
I
Channel
2
D000H t o DBFFH
f
Parameters
(3K
bytes)
I
100 Z=CALL(O, $8030, $FF, 701.
. .
.Checks PC CPU RUNISTOP status.
110 I F Z=1 LOCATE 5. 10; PRINT "CPU RUN"; GOT0 100.
. .
. . . .
.Indicates whether the CPU i s running.
120 I F Z#0 G O T 0 To error processing
. . .
.Detects any error i n SKC execution and
. . . .
moves to a suitable part o f the program.
130 Z=ZWR1(2. $F000. $FF).
. . . .
.Defines the PC station number as host.
140 Z=ZWR2(2, $F004. 1281
. . . . .
.Sets byte length t o be written t o 128.
150 Z=ZWR212, $FO08,70)
. . . . . .
S e t s time check period t o 7 0 (70Omsec).
160 FOR Is0 TO $BFF STEP $80
170 Z=ZWR2(2' $FOO1' I)
}
. . . . .
Sets parameter write head address.
180 Z=ZWR1(2. $F003,0)
190 Z=ZWR2(2. SF006, $DOOO+l).
.
S e t s
source data head address.
200 Z=CALL(O, $8093. 2, $F0001.
.
.Writes parameters.
210 I F ZffO PRINT "ERROR".
Z; GOT0 200.
. . . . . . . . . . . .
.Checks for errors in SAPWexecution.
220 NEXT I
230 Z=CALL(O, $8096, $FF, 70).
. .
.Parameter analysis request.
240 I F Z M PRINT "ERROR",
Z; GOT0 225.
. . . . . . . . . . . .
.Checks for errors i n SAPS execution.
250 Z=ZWR1(2, $F010, $ F F ) .
. . . .
.Defines PC station number as host.
260 Z=ZWR1(2, $F011.
$40).
. . . .
Sets main, "M", sequence program.
270 Z=ZWR2(2. $F014. 64)
. . . . . .
S e t s the number of.steps t o be written
t o 64.
280 Z=ZWR2(2, $F018, 70)
. . . . . .
.Sets time check period t o 7 0 (700msec).
290 A=$E000.
. . . . . . . . . . . . . . .
S e t s data source head address to variable
A.
300 FOR I = 0 TO 2047 STEP 64
310 Z=ZWR2(2, $F012, I )
. . . . . . .
Sets head step number of sequence pro-
gram t o be written.
320 Z=ZWR212. SE014. A).
. . . . . .
.Sets data source head address.
330 Z=CALL(O. $F016. 2, $F0101.
.
.Writes sequence program.
340 I F Z#0 PRlNT"ERR0R".
Z; GOT0 300.
. . . . . . . . . . . .
.Checks for errors in SAAW execution.
350 A=A+128
. . . . . . . . . . . . . . .
.Adds 128 to sequence program write
head address.
360 N E X T I
370 E N 0

Advertisement

Table of Contents
loading

Table of Contents