External Device Program; Writing To Pc Cpu Word Device Memory (Word Units Batch Write) - Mitsubishi Electric AJ71QC24 Manual

Melsec qna serial communications module
Table of Contents

Advertisement

4. COMMUNICATIONS USING A DEDICATED
PROTOCOL
MELSEC
QnA
4.7
Writing to PC CPU Word Device Memory (Word Units Batch Write)
This section inputs numeric data from an external device and writes it to PC CPU data registers
DO to D4.
4.7.1
External device program
1060
1070
1080
1090
1100
1110
1120
1130
1140
1150
1160
1170
1180
'
!
1190
1200
1210
1220
1230
1240
1250
1260
1270
'
!
1280
1290
1300
1310
1320
1330
'
!
1340
1350
1360
'
!
CLS
ear
screen
WTCNT%
=
10
:'Data receive wait retry counter
DLCNT%=1000
:'Counter for data
receive
wait time am3justment
ACCNT%
=
11
:'Receive data length
when
ACK receive83
NACNT%
=
15
:'Receive data length
when
NAK receive83
ERFLG%
=
0
:'Error flag storage at the end
of
reccption
RVCNT%
=
0
:'Receive request data count storage
CH%
= :
:'Channel No.
ENQ$
=CHR$
( & H 5
)
:
'
ENQ code
ACK$
=CHR$ (&H6)
:
'
ACK code
NAK$
=CHR$(&H15)
:
'NAK code
------------------------------write
data input
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - I
CLS
LOCATE 10,13
:
PRINT "Input in decimal."
LOCATE 10,12
:
INPUT "DO=
"
;
D ( 0 )
LOCATE 10,13
:
INPUT
" D l =
"
;
D(1)
LOCATE 10,14
:
INPUT "D2=
"
;
D(2)
LOCATE
1 0 , 1 5
:
INPUT "D3=
"
;
D(3)
LOCATE 10,16
:
INPUT "D4=
"
;
D(4)
. . . . . . . . . . . . . . . . . . . .
Write data
>
hexadecimal conversion-----------------------!
DS
=
I' 'I
FOR I%=O TO 4
D$=D$+RIGHT$("OOO"+HEX$(D(I%) ) , 4 )
NEXT I%
. . . . . . . . . . . . . . . . . . . . . . . . .
~~-2321 ope=,
&
initialize----------------------------
I
OPEN "COM:E71NN" AS #CH%
:'Set communications mode, etc.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Send command 1401
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
I
1370 *COMSEND
1380
PRINT #CH%,ENQ$;"F90000FF0014010000D*0000000005''+D$
1390
1400
!
1
--------------------------Receive
response message
~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
1410 *RECEIVE
1420
RTICNT%=l
:
GOSUB *JUYSIN
:I1 character receive request
1430
IF ERRFLG%=99 THEN *ERFIN
:
'Not received
1440
BUF$=RCV$
1450
IF (BUF$=ACK$ OR BUF$=NAK$) THEN *REC1 ELSE *RECEIVE
1460
1470 *REC1
1480
IF BUF$=ACK$ THEN RVCNT%=ACCNT%-1
:'Set receive request characLer count to 10.
1490
IF BUF$=NAK$ THEN RVCNT%=NACNT%-1
:'Set receive request character count to 14.
1500
GOSUB *JYUSIN
:'Receive request
1510
IF ERFLG%=99
THEN
*ERFIN
:
'Not received
1520
BUF$=BUF$+RCV$
:'Storage
all receive
data
to BUF$.
1530
1540
CHK$=ACKS+"F90000F00"
:'Normal
end response
message
structure
4
-
25

Advertisement

Table of Contents
loading

This manual is also suitable for:

Aj71qc24-r2Aj71qc24-r4

Table of Contents