Omron CPM1 - PROGRAMING MANUAL 02-2001 Programming Manual page 269

Hide thumbs Also See for CPM1 - PROGRAMING MANUAL 02-2001:
Table of Contents

Advertisement

CPM2A/CPM2C Communications Functions
Issuing Commands from
a Host Computer
1000 ' ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
1010 ' CPM2A/CPM2C Sample Program for BASIC
1020 '
1050 ' ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
1060 ' –––Set value RS–232C SPEED:9600BPS,PARITY:EVEN,DATA:7,STOP:2–––
1070 OPEN "COM:E73"
1080 *REPEAT
1090
–––Transmission data input–––––––––––––––––––––––––––––––––––––––––––––––
1100 INPUT
" send
1110 ' –––FCS Calculation–––––––––––––––––––––––––––––––––––––––––––––––
1120 FCS=0
1130 FOR
IFCS = 1
1140
FCS = FCS
1150 NEXT
1160 FCS$ = RIGHT$ ( "0" + HEX$ ( FCS ) , 2 )
1170 ' –––Communications execute–––––––––––––––––––––––––––––––––––––––––––––––
1180 ZZZ$ = SEND$ + SCS$ + "*" + CHR$(13)
1190 PRINT
#1 , ZZZ$ ;
1200 ' –––Response check–––––––––––––––––––––––––––––––––––––––––––––––
1210 RECCNT = 0 : TMP$ – ""
1220 *DRECLOOP
1230 IF
LOC ( 1 ) < > 0
1240 RECCNT = RECCNT + 1
1250 IF
RECCNT = 5000
1260 *DREC1
1270 TMP$ = TMP$ + INPUT$ ( LOC (1 ) , #1 )
1280 IF
RIGHT$ ( TMP$ , 1 ) = CHR$ (13)
DRECLOOP
1290 *DRECERR
1300 TMP$ = " No response !! " + CHR$ ( 13 )
1310 *DRECEND
1320 PRINT " receive data : " ; RECV$
1340 ' –––Go to transmission data input––––––––––––––––––––––––––––––––––––––––
1350 GOTO *REPEAT
1360 ' –––Processing complete–––––––––––––––––––––––––––––––––––––––––––––––
1370 CLOSE
#1
1380 END
This example shows a BASIC program that reads the status of the CPM2A/
CPM2C's inputs in IR 000. For more details see 4-5 Host Link Commands.
An FCS (frame check sequence) check isn't performed on the received re-
sponse data in this program.
Be sure that the host computer's RS-232C port is configured correctly before
executing the program.
AS
#1
data
: ",send$
TO
LEN ( send$ )
XOR
ASC( MID$ ( SEND$ , IFCS , 1 ) )
THEN *DREC1
THEN *DRECERR ELSE
*DRECLOOP
THEN *DRECEND ELSE RECCNT = 0 : GOTO *
Section
4-3
249

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents