INFICON XTM/2 Thin Film Deposition Monitor User Manual
Page 80
3 - 28
IP
N 07
4-
18
6S
XTM/2 Operating Manual
10 ’--XTM/2 RS232 COMMUNICATIONS PROGRAM WITH CHECKSUM USING THE INFICON FORMAT--
20 ’
30 ’------THIS PROGRAM IS DESIGNED TO TRANSMIT INDIVIDUAL COMMANDS TO THE XTM/2
AND ACCEPT THE APPROPRIATE RESPONSE FROM THE XTM/2, WRITTEN IN GWBASIC 2.32.
40 ’
50 OPEN “COM1:9600,N,8,1,cs,ds” AS #1
:’--OPEN COMM PORT 1
60 STX$ = CHR$(2) : NAK$ = CHR$(21) : ACK$ = CHR$(6)
:’--DEFINE ASCII CODES
70 ’
80 INPUT “ENTER COMMAND”; CMD$
:’--ENTER COMMAND TO XTM/2
90 GOSUB 170
:’--GOTO TRANSMIT COMMAND SUBROUTINE
100 IF RESPONSE$ = “RECEIVE TIMEOUT” THEN 140
110 L = LEN(RESPONSE$): L = L-1
:’--STRIP OFF THE ACK OR
120 RESPONSE$ = RIGHT$(RESPONSE$,L)
:’ NAK CHARACTER FROM THE
130 ’
:’ RESPONSE STRING.
140 PRINT RESPONSE$
:’--PRINT XTM/2 RESPONSE
150 GOTO 80
:’--LOOP BACK FOR ANOTHER COMMAND.
160 ’
170 ’----TRANSMIT COMMAND AND RECEIVE RESPONSE SUBROUTINE----
180 ’
190 ’--BUILD COMMAND MESSAGE STREAM AND SEND TO THE XTM/2--
200 SIZEM$ = CHR$(LEN(CMD$) / 256)
:’--CALCULATE THE 2 BYTE
210 SIZEL$ = CHR$(LEN(CMD$) MOD 256)
:’ SIZE OF THE COMMAND.
220 ’
230 CHECKSUM = 0
:’--INITIALIZE CHECKSUM TO
240 FOR X = 1 TO LEN(CMD$)
:’ ZERO AND CALCULATE A
250 CHECKSUM = CHECKSUM + ASC(MID$(CMD$,X,1))
:’ CHECKSUM ON THE COMMAND
260 NEXT X
:’ STRING.
270 CHECKSUM$ = CHR$(CHECKSUM AND 255)
:’--USE LOW ORDER BYTE AS CHECKSUM.
280 ’
290 PRINT #1, STX$ + SIZEM$ + SIZEL$ + CMD$ + CHECKSUM$
300 ’
310 ’----RECEIVE RESPONSE MESSAGE FROM THE XTM/2----
320 TOUT = 3: GOSUB 510
:’--SET TIMER AND WAIT FOR
330 IF I$ <> STX$ THEN 290
:’ START OF TRANSMISSION CHARACTER.
340 TOUT = 3: GOSUB 510
:’--RECIEVE HIGH ORDER BYTE
350 SIZE = 256 * ASC(I$)
:’ OF TWO BYTE RESPONSE SIZE.
360 TOUT = 3: GOSUB 510
:’--RECIEVE LOW ORDER BYTE
370 SIZE = SIZE + ASC(I$)
:’ OF TWO BYTE RESPONSE SIZE.
380 CHECKSUM = 0
:’--SET CHECKSUM TO ZERO
390 RESPONSE$ = “”
:’ AND NULL THE RESPONSE
400 FOR I = 1 TO SIZE
:’ STRING.BUILD THE
410 TOUT = 3: GOSUB 510
:’ RESPONSE STRING AND
420 RESPONSE$ = RESPONSE$ + I$
:’ CALCULATE THE CHECKSUM
430 CHECKSUM = CHECKSUM + ASC(I$)
:’ CHARACTER BY CHARACTER.
440 NEXT I
450 TOUT = 3: GOSUB 510
:’--RECIEVE THE CHECKSUM
460 N = ASC(I$)
:’ CHARACTER AND COMPARE
470 Z = (CHECKSUM AND 255)
:’ IT TO THE LOW ORDER
480 IF N <> Z THEN PRINT “RESPONSE CHECKSUM ERROR”
:’ BYTE OF THE CALCULATED
490 RETURN
:’ CHECKSUM.
500 ’
510 ’----READ SERIALLY EACH CHARACTER FROM THE INSTRUMENT INTO VARIABLE I$----
520 ON TIMER (TOUT) GOSUB 550: TIMER ON
530 IF LOC(1) < 1 THEN 530 ELSE TIMER OFF: I$ = INPUT$(1,#1)
540 RETURN
550 TIMER OFF
:’--INDICATE IF A CHARACTER
560 RESPONSE$ =”RECEIVE TIMEOUT”: RETURN 570
:’ IS NOT RECEIVED WITHIN
570 RETURN 490
:’ 3 SECS.