Programming Example - Omron K3GN - V1.04 User Manual

1/32 din digital panel meter
Table of Contents

Advertisement

7.12 Programming Example

N88 BASIC
The section shows a programming example where a response from the product is
displayed on the screen on the host PC when a command is entered from the
keyboard.
This program is created with N88 BASIC.
1000
'-------------------------------------------------------
1010
'PROGRAM: K3GN Communication Sample Program(CompoWay/F)
1020
'VERSION:1.00
1030
'(C)Copyright OMRON Corporation 1999
1040
'All Rights Reserved
1050
'------------------------------------------------------
1060
'
1070
'====== Baud rate setting (PARITY=EVEN,DATA=7,STOP=2) ==========="
1080
'COM port settings
1090
OPEN "COM:E73" AS #1
1100
'
1110
*REPEAT
1120
'
1130
'========= Transmission processing =====================
1140
'
1150
'--------SD input----------
1160
INPUT "SEND DATA:",SEND$
1170
'
1180
'--------If not input, go to end processing---------
1190
"IF SEND$ = "" THEN *EXIT
1200
'
1210
'-------BCC calculation--------
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
'------Transmission----------
1300
SDATA$ = CHR$(2)+SEND$+BCC$
1310
PRINT #1,SDATA$;
1320
'
1330
'=========Reception processing===========
1340
'
1350
RDATA$ = ""
1360
TIMEOUT = 0
1370
*LOOP
1380
'-------No-response detection-------
1390
TIMEOUT = TIMEOUT+1
1400
IF TIMEOUT > 2000 THEN RESP$ = "No Response":GOTO *REND
1410
IF LOC(1) = 0 THEN *LOOP
1420
'
1430
'-----Ending character identification (if not ending character,
continue reading)
1440
RDATA$ = RDATA$+INPUT$(LOC(1),#1)
1450
IF LEN(RDATA$) < 2 THEN *LOOP
1460
IF MID$(RDATA$,LEN(RDATA$)-1,1) <> CHR$(3) THEN *LOOP
1470
RESP$ = MID$(RDATA$,2,LEN(RDATA$)-2)
1480
*REND

7.12 Programming Example

123

Advertisement

Table of Contents
loading

This manual is also suitable for:

K3gn

Table of Contents