	.TITLE	SPOT
/
/  7 MAR 72 - MOD BY P. HENDERSON
/
/SET POTENTIOMETER SUBROUTINE
/EXECUTION TIME: DEVICE LIMITED
/CALLING SEQUENCE:
/      CALL SPOT(POT,COEFF,TOLER,ERROR)
/     POT: 0-119 INTEGER PATCHBOARD
/            ADDRESS
/     COEFF: UNNORMALIZED POSITIVE INTEGER
/             COEFFICIENT
/     TOLER: UNNORMALIZED POSITIVE INTEGER
/             TOLERANCE
/     ERROR=0: NO ERROR
/          =1: ILLEGAL POT REQUESTED
/          =2: ADDRESS OR MODE FAILED
/              TO SET PROPERLY
/          =3: 0<COEFF OR COEFF>9999
/          =4: HARDWARE MALFUNCTION
/          =5: COEFFICIENT FAILED TO SET
/              WITHIN TOLERANCE
/          =6: POT NULL FAILURE
/          =7: KEYBOARD INTERFERENCE
/              SPOT CANNOT PROCEED
/
	.GLOBL SPOT
	.GLOBL %SAMO,%SACO,%TAVA,%DVM
/
SPOT	XX
	.ARG	SPOT
	DAC POT     /POT LOCATION
	.ARG
	DAC COEFF   /COEFFICIENT LOC.
	.ARG
	DAC TOLER   /TOLERANCE LOCATION
	LAC* TOLER
	SMA	/AC=TOLERANCE
	JMP .+3
	CMA
	TAD (1	/AC=-TOLERANCE
	DAC TOLER	/TOLER=[TOLERANCE]
	.ARG
	DAC ERROR   /ERROR LOCATION
	LAC (7
	JMS* %SAMO  /SET MODE=SP
	DAC* ERROR  /ERROR CODE
	SZA
	JMP* SPOT   /MODE FAILURE
	LAC* POT
	LMQ         /POT ADDRESS IN MQ
	LAC (4      /TYPE 4 IN AC
	JMS* %SACO
	DAC* ERROR  /ERROR CODE
	SZA
	JMP* SPOT   /ADDRESS FAILURE
	LAC* COEFF
	JMS* %TAVA
	DAC* ERROR  /ERROR CODE
	SZA
	JMP* SPOT   /VALUE FAILURE
	IOT3
	JMP .-1
	SPT         /SET POTENTIOMETER
	.DEC
	LAC (-80000
	.OCT
	DAC POT     /FAIL-SAFE=1.74 SEC.
LOOP	IOT3
	JMP .-1
	RSW         /READ STATUS WORD
	AND (10
	SNA
	JMP .+6     /POT SET NULLED
	JMS FAULT   /POT SET BUSY
	ISZ POT
	JMP LOOP
	LAC (4      /HARD. MALFUNCTION
	JMP EXIT
	JMS FAULT   /CHECK POT NULL FAIL
	IOT3
	JMP .-1
	CDVM        /DVM CONVERT
	JMS* %DVM
	DAC* ERROR  /ERROR CODE
	SZA
	JMP* SPOT   /DVM FAILURE
	LACQ	/DVM
	CMA         /-DVM-1
	TAD (1      /-DVM
	TAD* COEFF  /COEFF-DVM
	SPA
	JMP .+3
	CMA         /DVM-COEFF-1
	TAD (1      /DVM-COEFF
	TAD TOLER	/[TOLER]-
	            /[COEFF-DVM]
	SPA!CLA
	LAC (5      /ERROR>TOLERANCE
EXIT	DAC* ERROR  /ERROR CODE
	JMP* SPOT
FAULT	0
	IOT3
	JMP .-1
	RFW         /READ FAULT WORD
	AND (100000
	SNA
	JMP* FAULT
	LAC (6      /POT NULL FAILURE
	JMP EXIT
COEFF
ERROR
POT
TOLER
IOT3=703003
RSW=703613
RFW=705313
SPT=703526
CDVM=703626
	.END
