beautypg.com

Basic driver routine, Figure 5.3: basic driver routine, Computer interfacing page 5 - 4 – INFICON STM-100/MF Thin Film Deposition Monitor User Manual

Page 59

background image

4 REM SYCON STM-100 / MF COMMUNICATIONS DEMO ROUTINE. 6/12/1987 S. Bender

5 REM Sycon Instruments Inc. E. Syracuse, NY 13057

6 REM ***

8 REM Establish communications parameters and open as file #1.

10 OPEN "COM1:9600,N,8,1,CS,CD" AS #1

29 REM Get console user input to be sent to STM as a command.

30 INPUT "ENTER MESSAGE TO SEND";MSG$

34 REM Enter stop at prompt to exit program.

35 IF (MSG$="stop" OR MSG$="STOP") THEN 1000

39 REM Send message and get reply, or else some kind of error.

40 GOSUB 500

50 PRINT RPLY$

54 REM For debug purposes, show returned reply in hex codes too.

55 PRINT "HEX DATA IS {";

60 FOR CNT=1 TO LEN(RPLY$)

70 PRINT USING "\\" ;HEX$(ASC(MID$(RPLY$,CNT,1)));

75 IF CNT <> LEN(RPLY$) THEN PRINT ":";

80 NEXT CNT

90 PRINT "}"

99 REM Loop until break or user exit.

100 GOTO 30

101 REM ******* end of main program body ************

102 REM ******************************************************

103 REM **** start of msg/reply driver subroutine *****

499 REM initialize variables.

500 OUTCNT=LEN(MSG$):CKSUM=0

509 REM Compute outgoing message check sum.

510 FOR INDX= 1 TO OUTCNT:CKSUM=CKSUM+ASC(MID$(MSG$,INDX,1)):NEXT INDX

519 REM Send msg to STM, ASCII stx, count, and checksum.

520 PRINT#1,CHR$(2)+CHR$(OUTCNT)+MSG$+CHR$(CKSUM AND 255);

529 REM Get returned chars from STM-100 / MF and check for ASCII stx.

530 GOSUB 600:IF CHAR$ <> CHR$(2) THEN 520

539 REM Got ASCII stx, next data is length in binary, get it.

540 GOSUB 600:INCNT=ASC(CHAR$)

544 REM init variables for receiving incoming reply.

545 CKSUM=0:RPLY$=""

549 REM Loop inputting the remote reply message.

550 FOR INDX=1 TO INCNT

560 GOSUB 600:RPLY$=RPLY$+CHAR$:CKSUM=CKSUM+ASC(CHAR$)

565 NEXT INDX

569 REM Get final data, the checksum.

570 GOSUB 600

579 REM Check for valid checksum and data integrity.

580 IF (ASC(CHAR$))<>(CKSUM AND 255) THEN PRINT "BAD REPLY CHECKSUM"

590 RETURN

591 REM ******* End of msg/reply driver subroutine *********

592 REM ***********************************************************

593 REM ** Start of receive a char from COM1 subroutine **

600 ON TIMER(3) GOSUB 620 : TIMER ON

610 IF LOC(1)<1 THEN 610 ELSE TIMER OFF : CHAR$=INPUT$(1,#1) : RETURN

620 TIMER OFF : PRINT "RECEIVE TIMEOUT" : CLOSE #1 : RETURN 10

621 REM **** End of receive a char from COM1 subroutine **

1000 PRINT:PRINT "PROGRAM TERMINATED BY USER":PRINT

Figure 5.3: BASIC Driver Routine.

Basic Driver Routine

COMPUTER INTERFACING

Page 5 - 4