Program Example; N88Basic - Omron E5AR - MANUAL 2 User Manual

Digital controller
Hide thumbs Also See for E5AR - MANUAL 2:
Table of Contents

Advertisement

Section 6 Communication (CompoWay/F)

6.10 Program example

■ N88Basic

6-32
This program displays the response from the E5AR/ER on the screen
when command data is entered from the keyboard.
Command data from the unit number to the number of elements must
be entered.
The program was created in N88BASIC.
1000
'----------------------------------------------------
1010
'PROGRAM: E5AR/ER Communication Sample Program(CompoWay/F)
1020
'VERSION:1.00
1030
(c)Copyright OMRON Corporation 2003
1040
All Rights Reserved
1050
'----------------------------------------------------
1060
'
1070
'======Communication port (PARITY=EVEN, DATA=7, STOP=2) ======"
1080
'
1090
OPEN "COM:E73" AS 1
1100
'
1110
SENDDATA
1120
'
1130
========= Communication routine==================
1140
'
1150
--------Communication data input----------
1160
INPUT "SEND DATA:",SEND$
1170
'
1180
--------If no input, jump to end routine----------
1190
IF SEND$ = " " THEN EXITSEND
1200
'
1210
-------BCC calulation--------
1220
BCC = 0
1230
SEND$ = SEND$+CHR$(3)
1240
FOR I=1 TO LEN(SEND$)
1250
BCC = BCC XOR ASC(MID$(SEND$, I, 1))
1260
NEXT I
1270
BCC$ = CHR$(BCC)
1280
'
1290
------Send----------
1300
SDATA$ = CHR$(2)+SEND$+BCC$
1310
PRINT 1, SDATA$;
1320
'
1330
========= Receive routine ===========
1340
'
1350
RDATA$ = " "
1360
TIMEOUT = 0
1370
RCVLOOP
1380
-------No response detection-------
1390
TIMEOUT = TIMEOUT+1
1400
IF TIMEOUT > 2000 THEN RESP$ = "No Response":GOTO RCVEND
1410
IF LOC(1) = 0 THEN RCVLOOP
1420
'
1430
-----Check for end character (if no end character, continue reading)
1440
RDATA$ = RDATA$+INPUT$(LOC(1), 1)
1450
IF LEN(RDATA$) <2 THEN RCVLOOP
1460
IF MID$(RDATA$,LEN(RDATA$)-1,1)
1470
RESP$ = MID$(RDATA$,2,LEN(RDATA$)-2)
1480
RCVEND
1490
'
1500
-------Display received data-----------
1510
PRINT "RESPONSE:";RESP$
1520
GOTO SENDDATA
1530
'
1540
EXITSEND
1550
=========End routine==========
1560
CLOSE 1
1570
END
CHR$(3) THEN RCVLOOP

Advertisement

Table of Contents
loading

This manual is also suitable for:

E5er

Table of Contents