Rockwell Automation 5370 Color CVIM Communications Manual User Manual

Page 100

Advertising
background image

Chapter 5
Using the RS–232 Ports

5–32

999 :

1000 REM Subroutine to trigger an inspection on tool set

1050 PRINT#1,”>t”; CHR$(13);: REM Send the command

1080 RETURN

1999 :

2000 REM Subroutine to read discrete results from tool set

2040 IF LOC(1) THEN R$=INPUT$(LOC(1),#1): REM clear out any garbage characters

2050 PRINT#1,”>rr,p1”; CHR$(13);: REM Send the command

2060 CR$=INPUT$(2,#1): REM get CR/LF or ?/CR

2070 IF CR$=CHR$(13)+CHR$(10) THEN 2090

2080 PRINT CR[0]:PRINT”Input error”: R$=INPUT$(LOC(1),#1): R1(0)=–1: RETURN

2090 R$=INPUT$(1,#1): IF ASC(R$)<32 THEN 2090: REM ignore junk

2100 LINE INPUT#1,RE$: RE$=R$+RE$: REM get entire response

2120 R1(0) = VAL(MID$(RE$,1,9)): R1(1) = VAL(MID$(RE$,10,9))

2130 R$=INPUT$(LOC(1),#1): RETURN: REM Clear out any remaining characters

2499 :

2500 REM Subroutine to convert hex values in discrete result string RE$

2501 REM to integer values

2510 FOR RN=0 TO 15

2515 REM The following line converts each pair of hex digits to an integer

2520 D1=INSTR(HE$,MID$(RE$,25+RN*3,1))–1: D2=INSTR(HE$,MID$(RE$,26+RN*3,1))–1

2530 R1(RN+2) = 16*D1+D2: NEXT RN: RETURN

Advertising