3.3 Sample Program
H8GN
3-9
3.3 Sample Program
The following sample program displays responses returned from the
H8GN on screen when command data is entered from the keyboard.
Enter starting with the unit up to the number of elements as the command
data.
This sample program was created using N88BASIC
1000 'ĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆ
1010 'PROGRAM: H8GN Communication Sample Program (Compo Way/F)
1020 'VERSION: 1.00
1030 '(c) Copyright OMRON Corporation 2000
1040 'All Right Reserved
1050 'ĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆĆ
1060 '
1070 '= Communications port setting (PARITY=EVEN, DATA=7, STOP=2)="
1080 '
1090 OPEN "COM: E73" AS #1
1100 '
1110 *REPEAT
1120 '
1130 '=====Transmission processing==========
1140 '
1150 'ĆĆĆĆĆĆĆĆĆĆ Entry of send data ĆĆĆĆĆĆĆĆĆĆ
1160 INPUT "SEND DATA:", SEND$
1170 '
1180 'ĆĆĆĆĆĆĆĆĆĆ To exit processing if there is no entry ĆĆĆĆĆĆĆĆĆĆ
1190 IFSEND$="" THEN * EXIT
1200 '
1210 'ĆĆĆĆĆĆĆĆĆĆ Calculation of BCC ĆĆĆĆĆĆĆĆĆĆ
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 *LOOP0
1360 RDATA$=""
1370 TIMEOUT=0
1380 *LOOP
1390 'ĆĆĆĆĆĆĆĆĆĆ Detection of time-out ĆĆĆĆĆĆĆĆĆĆ
1400 TIMEOUT=1
1410 IFTIMEOUT>2000 THEN RESP$="No Response": GOTO * REND
1420 IFLOC (1)=0 THEN * LOOP
1430 '
JN88Basic