Reading From Pc Cpu Word Device Memory (Word 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.5
Reading From PC CPU Word Device Memory (Word Units Batch
Read)
This section reads the contents of PC CPU registers DO to D4 (5 words) to the external device in
word units and displays them on the CRT screen.
4.5.1
External device Dronram
io00
!
I
1010
'
!
AJ71QC24 Command 0401 Sample Program
I
1020
'
!
ASCI I Mode
I
1 C 3 C
'
!
(Registers DO-D4 (current
value)
batch read)
I
1040
!
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - l
1050 *ST1
1060
CLS
:'Clear screen
1070
WTCNT
% =
1 0
:'Data receive wait retry counter
1080
DLCNT%=1000
:'Counter for data receive time adjustment
1090
STCNT%
=
3 2
:'Receive data length when STX received
1100
NACNT%
=
1 5
:'Receive data ;er,gth when NAK received
111 0
ERFLG%=O
:'Error flag storage at end of reception
1120
R'JCNT%=O
:'Receive request data count scorage
1130
CH%
=1
:'Channel No.
1140
STX$
=CHR$ (&H2
j
:
'
STX code
1150
ETX$
=CHR.$ (&E3
)
:
'ETX code
1160
ENQ$
=CHRS (GH5
)
:
'
ENQ code
1173
NAKS
=CHR$ (&H15)
:
'NAK code
1180
1190
I
- _ _ - _ _ - _ - _ _ - _ _ - _ - - _ - - - - - -
RS-232C open
&
initialize----------------------------
!
1200
O?EN "COM: E71NN" AS #CH%
:'Set communications mode, etc.
1210
1220
I
!
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Send c o m ~ a n d 0 4 0 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1230 *COMSEND
1240
?RINT fCH%,ENQ$;"F90S0OFFOC04010000D*0000OOO0G5"
1230
1260
3
. . . . . . . . . . . . . . . . . . . . . . .
R.eceive current value of D&D4
- - - - - - - - - - - - - - - - - - - - - - - - - !
1270 *RECEIVE
1280
RVCNT%=1
:
GOSUB
*JYUSIN
: ' 1 character receive request
1290
IF ERFLG%=99
THEN
*ERFIN
:
'Not received
1300
BUF$=RCV$
1310
IF (BUF$=STX$ OR. 3'JF$= NAK$)THEN *REC1 ELSE
*RCCE;VE
1320 *R.ECl
1330
IF BUFS=STX$ THEN RVCNT%=STCNT%-1 :'Set receive request character count to 31.
1340
IF BUF$=NAK$
THEN
RVCNT%=NACNT%-1 :'Set receive request character count to 14.
1350
GOSUB
*JYUSIN
:'Receive request
136C
IF ERFLG%=99 THEN *ERFIN
:
'Not received
1370
BUF$=BUFS+RCV$
:'Storage all receive data to BUF$.
1380
1390
IF LEFT$(BUF$,11)=STX$-"F9OOO0FOO" .WD RIGHT$(BUF$,l)=ETX$ THEN *DISP
140C
IF LEFT$(H~FS,11)=NAK$+"F90OGOFOG" THEN *ERCODE ELSE *ERDISP
1410
142,3
I
. . . . . . . . . . . . . . . . . . . . . . . . . . .
Display receive d a t a . - - - _ - - - - - - - - - - - - - - - - - - - - - - - - - - '
1430
* D I S P
1440
LOCATE 27,4
:
PRINT "Word units batch read normal end"
1450
D S = M I D $ ( B ~ F $ , ~ ~ , ~ O )
1450
LOCATE 27, 8
:
PRINT "D$=";D$
1473
LOCATE
7 , 1 2
:
PRINT
'I
DO-D4 current value list"
1480
FOR I%=l
TO
5
1490
DATS=VAL("&H"+MID$(D$, (I%-i) *4+1,4j
:
'Data (4 hexadecimal digits)
+
decimal conversion
1503
DNO%=I%-L
:'Data
register No.
1513
LOCATE 15,14+1%
1520
P R I N T
USING"D#=####";DNO%,DAT%
4 - 1 4

Advertisement

Table of Contents
loading

This manual is also suitable for:

Aj71qc24-r2Aj71qc24-r4

Table of Contents