Basic Program Examples - Mitsubishi Melsec A User Manual

Table of Contents

Advertisement

7. CoMMuNlcATloN WITH PROGRAMMABLE CONTROLLER cpu
/MELSEC-A
7.3.2 BASIC program examples
This section gives some BASIC program examples which use system
subroutines SADR (batch read), SADW (batch write), SADMO
(monitor data entry), SADMI (monitor), and SADT (test). The pro-
gram examples use channel 1. For details of the system subroutines,
refer to the GPC-BASIC Handbooks.
(1) Batch read from device memory (SADR)
[Program example 1
I
Program to read data from 16 points, X I 0 0 t o XIOF, to AD51
addresses EOOOH to EOOFH as individual bits.
100 A=$F000
. . . . . . . . . . . .
.Head
address for
system subroutine
INPUT data.
110 A:Ol=$FF.
. . . . . . . . . . .
.Defines PC station number as host.
120 A : l I = " B " .
. . . . . . . . . . .
.Specifies bit read.
130 B=$F002
. . . . . . . . . . . .
Sets indirect variable head address.
140 B$="X0100".
. . . . . . . . .
Sets headdevice to beread usingcharacter
string variable.
150 C=$F007
. . . . . . . . . . . .
Sets indirect variable head address.
160 C(O)=16
. . . . . . . . . . . . .
.Sets the number o f points t o be read as
16.
170 C(lI=$E000
. . . . . . . . . .
S e t s destination head address for data.
180 C(2)=60
. . . . . . . . . . . . .
S e t s time check period to 60 (600msecl.
190 Z=CALL(O, $8078, 1, A ) .
.
.Calls system subroutine SADR.
200 IF
Z#O
PRINT "ERROR",
Z: GOT0 190
. . . . . . . . .
.Checks for errors in SADR execution.
210 END
(1) When specifying the head device using a character string
variable, define the number of points t o be read after
setting the head device. (Reason: The character string
variable overwrites the bits at the end of the data with
"0".
This would delete the "number of points" data if
this was written first.)
(2) The time check period in line 180 should be set in accor-
dance with the "number of scans required for processing"
given in Section 3.8 (page 3-19) after taking into account
any delays which may occur due to other devices access-
ing the PC CPU.

Advertisement

Table of Contents
loading

Table of Contents