Reading From Pc Cpu Bit Device Memory (Bit Units Batch Read) - Mitsubishi Electric AJ71QC24 Manual

Melsec qna serial communications module
Table of Contents

Advertisement

4. COMMUNICATIONS USING A DEDICATED
PROTOCOL
MELSEC
QnA
4.6
Reading From PC CPU Bit Device Memory (Bit Units Batch Read)
This sections reads the ON/OFF state of PC CPU bit devices X0 to X7 (8 points) to the external
device in bits units and displays the read state on the CRT screen.
4.6.1
External device Dronram
1000
1010
1020
1030
1040
1050
1060
1070
1080
1090
1100
1110
1120
1130
1140
1150
1160
1110
1180
1190
1200
1210
1220
1230
1240
1250
1260
1270
1280
1290
1300
1310
1320
1330
1340
1350
1360
1370
1380
1390
1400
1410
1420
1430
1440
1450
1460
1470
1480
1490
1500
1510
1520
1530
I
I
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
I
1
1
AJ71QC24 Command 0401 Sample Program
I
1
1
ASCII Mode
1
I
1
(Batch read of ON/OFF
state
of
bit devices X0
to
X7)
!
I
I
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
I
*ST1
CLS
:'Clear screen
WTCNT%
=
1 0
:'Data receive wait retry counter
DLCNT%=1000
:'Counter
for data receive wait time adjustment
STCNT%=20
:'Receive
data length when
STX
received
NACNT%=15
:'Receive
data length when
NAK
received
ERFLG%=G
:'Error flag storage at end of reception
RVCNT%
=
0
:'Receive request data count storage
CH%
=1
:'Channel No.
STX$
=CHR$(&H2)
:
STX code
ETX$
=CHR$ (&H3
)
:
'ETX code
ENQ$
=CHR$ (&H5
)
:
'ENQ code
NAK$
=CHR$(&H15)
:
'NAK code
I
I
_ _ - - _ _ _ - - - _ _ _ - - - _ _ _ - - - _ - -
~ ~ - 2 3 2 C
open
&
initialize----------------------------
1
OPEN "COM:E71NN" AS #CH%
:'Set communications mode, etc.
*COMSEND
t
I
- - _ _ _ - - - _ _ _ - - - _ _ _ - - - - _ - - - - - - -
send command 0401-------------------------_------
PRINT #CH%,ENQ$;"F90000FF0004010001X*~000000008"
I
I
_ _ _ _ _ - - _ _ - _ - - - _ _ _ - - - _ _ _ _
Receive DO-D4 current value---------------------------
!
*RECEIVE
RVCNT%=1
:
GOSUB *JYUSIN
: ' 1 character receive request
IF ERFLG%=99 THEN
*ERFIN
:
'Not received
BUF$=RCV$
IF (BUF$=STX$ OR BUF$=NAK$) THEN *RECl ELSE *RECEIVE
* R E 1
IF BUF$=STX$ THEN RVCNT%=STCNT%-1
:'Set receive request character count to 19.
IF BUF$=NAK$ THEN RVCNT%=NACNT%-l
:"Set receive request character count to 14.
GOSUB *JYUSIN
:'Receive request
IF E R F L G % = ~ ~
THEN *ERFIN
:
'Not received
BUF$=BUF$+RCV$
:'Storage all receive data to BUF$.
IF LEFT$ (BUF$,
ll)=STX$+"F90@00FF00"
AND RIGHTS (BUF$,
1)
=ETX$
THEN
*DISP
IF
L E F T $ ( B U F $ , I I ) = N A K $ + ~ ~ F ~ O O O O F F O O ~ ~
THEN *ERCODE ELSE *ERDISP
*DISP
I
I
isplay
play receive data
- - _ _ _ - - - - _ _ - - - - _ - - - - - - - - - - - - - - !
LOCATE 27,4
:
PRINT "Bit units batch read normal end"
X$=MID$
(BUFs,
12,8)
LOCATE 27, 8
:
PRINT :X$=";XS
LOCATE
7,12
:
PRINT "X0-X7 ON/OFF state"
FOR I%=l TO 8
IF MID$ (X$, I%,l)="l"
THEN DAT$= "ON"
:
'When 1 , ON
IF MID$ (X$,I%,
1)="0"
THEN DATS="OFF"
:
'When 0, OFF
LOCATE 15,14+1%
XNO%=I%-1
:
' X No.
PRINT USING"X#=&
& "
;XNO%, DAT$
4
-
20

Advertisement

Table of Contents
loading

This manual is also suitable for:

Aj71qc24-r2Aj71qc24-r4

Table of Contents