Rs-232C Communications (Cqm1/Srm1 Only) - Omron CPM1 Programming Manual

Hide thumbs Also See for CPM1:
Table of Contents

Advertisement

Communications Functions
Example Program
1-9-6

RS-232C Communications (CQM1/SRM1 Only)

Communications Procedure
1,2,3...
100
This example shows a BASIC program that reads the status of the SRM1's
inputs in IR 000. For more details, refer to SECTION 6 Host Link Commands.
An FCS (frame check sequence) check isn't performed on the received
response data in this program. Be sure that the host computer's RS-232C port
is configured correctly before executing the program.
1000 ' ----------------------------------------------
1010 'SRM1 Sample Program for PC-9801 N88-BASIC
1020 '
1050 ' ----------------------------------------------
1060 'Set value RS-232C SPEED:9600BPS,PARITY:EVEN,DA-
TA:7,STOP:2--
1070 OPEN "COM:E73" AS #1
1080 *REPEAT
1090 '---Transmission data input --------------------
1100 INPUT "send data:",SEND$
1110 '---FCS Calculation ----------------------------
1120 FCS=0
1130 FOR IFCS=1 TO LEN(SEND$)
1140 FCS=FCS XOR ASC(MID$(SEND$;IFCS,1)
1150 NEXT
1160 FCS$=RIGHT$("0"+HEX$(FCS),2)
1170 '---Communications execute ---------------------
1180 ZZZ$=SEND$+FCS$+"*"+CHR$(13)
1190 PRINT #1,ZZZ$;
1200 '---Response check -----------------------------
1210 RECCNT=0:TMP$=""
1220 *DRECLOOP
1230 IF LOC(1)<>0 THEN *DREC1
1240 RECCNT=RECCNT+1
1250 IF RECCNT=5000 THEN *DRECERR ELSE *DRECLOOP
1260 *DREC1
1270 TMP$=TMP$+INPUT$(LOC(1),#1)
1280 IF RIGHT$(TMP$,1)=CHR$(13) THEN *DRECEND ELSE
RECCNT=0:GOTO *DRECLOOP
1290 *DRECERR
1300 TMP$="No response!!"+CHR$(13)
1310 *DRECEND
1320 RECV$=TMP$
1330 PRINT "receive data:";RECV$
1340 '---Go to transmission data input --------------
1350 GOTO *REPEAT
1360 '---Processing complete ------------------------
1370 CLOSE #1
1380 END
This section explains RS-232C communications. By using RS-232C commu-
nications, the data can be printed out by a printer or read by a bar code
reader. Handshaking is not supported for RS-232C communications.
Transmissions
1. Check to see that AR 0805 (the RS-232C Port Transmit Ready Flag) has
turned ON.
Section 1-9

Advertisement

Table of Contents
loading

Table of Contents