4. COMMUNICATION PROTOCOL
IMSRM04-E8
34
4.4 Examples of Selecting and Polling Check Programs
The following is the sample program for NEC PC-9800 series computers in BASIC language for
carrying out polling and selecting checking by RS-422A (4-wire system) or RS-232C specification.
Please be noted that there will be some differences in the computer languages according to the type of
computer.
Before executing the program, confirm that there is no mistake in the wiring of the communications
cable and check that the control unit data bit structure is set to 8 for data bit and None for parity
check.
In addition, the communications speed setting should be set to match the host computer speed setting.
Example of temperature set values polling check program
1000 '-------------------- Identifier setting ----------------------
1010 ID$="S1"
1020 '
1030 '--------------- Communications initial setting ---------------
1040 CM$="N81NN"
1050 INPUT "Control unit address=";ADD$
1060 STX$=CHR$(&H2) : EOT$=CHR$(&H4) : ENQ$=CHR$(&H5)
1070 ACK$=CHR$(&H6) : NAC$=CHR$(&H15): ETX$=CHR$(&H3)
1080 OPEN "COM1:"+CM$ AS #1
1090 CONSOLE ,,,1
1100 COLOR 7:CLS 3
1110 '
1120 '------------------ Program main routine ---------------------
1130 *POL
1140 PRINT " (Polling check) "
1150 PRINT "*********Receiving the set values************"
1160 PRINT " "
1170 DT$=EOT$+ADD$+ID$+ENQ$
1180 GOSUB *TEXT
1190 GOSUB *RXDT
1200 '
1210 *J10
1220 J=0
1230 '
1240 *IF1
1250 IF LOC(1)=0 THEN J=J+1:IF J<500 THEN *IF1 ELSE PRINT "
TIME OUT ":END
1260 '
1270 K$=INPUT$(1,#1)
1280 IF K$=ETX$ GOTO *ETXRX
1290 IF K$=NAK$ THEN PRINT " NAK":END
1300 IF K$=EOT$ THEN PRINT " EOT":END
1310 IF K$=ACK$ THEN PRINT " ACK":END
1320 '
1330 DT$=DT$+K$
1340 GOTO *J10
1350 '
Identifier setting
Communications data configuration setting
Control unit address input
Communications character setting
Open RS-232C circuit
Data configuration setting
Setting of the receiving waiting time
(Timeout processing)
Communications condition checking
(Continued on the next page.)