DECLARE SUB gpibclrdev (addr$) DECLARE SUB gpibout (addr$, cmd$) DECLARE SUB gpibterm (termin$, termout$) DECLARE SUB bit488savei (ctrl%, i!) DECLARE SUB bit488savev (ctrl%, v!) '**************************************************************************** 'Module BIT488 'This module contains I/O subroutines for the Kepco BOP supplies 'driven by the BIT488 controller. ' 'Zachary Wolf '7/28/95 '**************************************************************************** 'Common area for shared parameters COMMON SHARED /bit488/ gpibinP%, gpiboutP%, bit488addrP$ 'Semi-permanent parameters CONST bit488terminP$ = "CR LF EOI" 'input GPIB terminator CONST bit488termoutP$ = "CR LF EOI" 'output GPIB terminator CONST bit488vminP! = -20! 'the minimum Kepco bop supply voltage CONST bit488vmaxP! = 20! 'the maximum Kepco bop supply voltage CONST bit488iminP! = -20! 'the minimum Kepco bop supply current CONST bit488imaxP! = 20! 'the maximum Kepco bop supply current CONST bit488vlimP! = 20! 'the voltage magnitude limit in constant current mode CONST bit488ilimP! = 20! 'the current magnitude limit in constant voltage mode SUB bit488geti (i!) '**************************************************************************** 'This subroutine gets the output current from the Kepco BOP. ' 'Output: ' i!, the BOP current which is being output ' 'Zachary Wolf '3/24/95 '**************************************************************************** 'Get the output current last requested CALL bit488savei(1, i!) END SUB SUB bit488getv (v!) '**************************************************************************** 'This subroutine gets the output voltage from the Kepco BOP. ' 'Output: ' v!, the BOP voltage which is being output ' 'Zachary Wolf '3/24/95 '**************************************************************************** 'Get the output voltage last requested CALL bit488savev(1, v!) END SUB SUB bit488init '**************************************************************************** 'This subroutine initializes the Kepco BIT488 controller for the BOP supply. ' 'Zachary Wolf '3/22/95 '**************************************************************************** 'Set the GPIB terminators for the BIT488 CALL gpibterm(bit488terminP$, bit488termoutP$) 'Message PRINT PRINT "Resetting the BIT488..." 'Reset the BIT488 CALL gpibclrdev(bit488addrP$) END SUB SUB bit488savei (ctrl%, i!) '**************************************************************************** 'This subroutine saves the current the Kepco BOP was last requested 'to output. ' 'Input/Output ' ctrl%, control number indicating whether to save or return i! ' 0 = save, 1 = return ' i!, the current to store or return ' 'Zachary Wolf '3/24/95 '**************************************************************************** 'Define the storage variable STATIC savei! 'Save or return v! IF ctrl% = 0 THEN savei! = i! IF ctrl% = 1 THEN i! = savei! END SUB SUB bit488savev (ctrl%, v!) '**************************************************************************** 'This subroutine saves the voltage the Kepco BOP was last requested 'to output. ' 'Input/Output ' ctrl%, control number indicating whether to save or return v! ' 0 = save, 1 = return ' v!, the voltage to store or return ' 'Zachary Wolf '3/24/95 '**************************************************************************** 'Define the storage variable STATIC savev! 'Save or return v! IF ctrl% = 0 THEN savev! = v! IF ctrl% = 1 THEN v! = savev! END SUB SUB bit488seti (i!) '**************************************************************************** 'This subroutine has the Kepco BIT488 output a current i!. ' 'Input: ' i!, the current to output ' 'Zachary Wolf '3/24/95 '**************************************************************************** 'Set the GPIB terminators for the BIT488 CALL gpibterm(bit488terminP$, bit488termoutP$) 'Simplify the notation imax! = bit488imaxP! imin! = bit488iminP! vlim! = bit488vlimP! vmax! = bit488vmaxP! 'Make sure the current is within the proper range '(Polarity is checked here. This is not done in the mmm check.) IF i! < imin! THEN i! = imin! IF i! > imax! THEN i! = imax! 'Determine the control code to send to the BIT488 IF i! >= 0 THEN c$ = "4" IF i! < 0 THEN c$ = "5" 'Determine the magnitude code to send to the BIT488 mmm% = ABS((i! / imax!) * 999) IF mmm% < 10 THEN mmm$ = "00" + LTRIM$(STR$(mmm%)) IF mmm% < 100 AND mmm% >= 10 THEN mmm$ = "0" + LTRIM$(STR$(mmm%)) IF mmm% < 1000 AND mmm% >= 100 THEN mmm$ = LTRIM$(STR$(mmm%)) IF mmm% >= 1000 THEN mmm$ = "999" 'Determine the limit code to send to the BIT488 ll% = ABS((vlim! / vmax!) * 99) IF ll% < 10 THEN ll$ = "0" + LTRIM$(STR$(ll%)) IF ll% < 100 AND ll% >= 10 THEN ll$ = LTRIM$(STR$(ll%)) IF ll% >= 100 THEN ll$ = "99" 'Output the current to the BIT488 CALL gpibout(bit488addrP$, c$ + mmm$ + ll$) 'Save the updated output current CALL bit488savei(0, i!) END SUB SUB bit488setpar (gpibinf%, gpiboutf%, bit488addr$) '**************************************************************************** 'This subroutine sets the parameters for the Kepco BIT488 controller 'for the BOP supply. ' 'Input: ' gpibinf%, gpib input file number ' gpiboutf%, gpib output file number ' bit488addr$, gpib address in a string ' 'Zachary Wolf '3/22/95 '**************************************************************************** 'Make sure the input parameters have reasonable values IF gpibinf% < 0 OR gpibinf% > 100 THEN PRINT "BIT488: GPIB problem" EXIT SUB END IF IF gpiboutf% < 0 OR gpiboutf% > 100 THEN PRINT "BIT488: GPIB problem" EXIT SUB END IF IF bit488addr$ = "" THEN PRINT "BIT488: GPIB problem" EXIT SUB END IF 'Save the GPIB information in a common block for future use gpibinP% = gpibinf% gpiboutP% = gpiboutf% bit488addrP$ = bit488addr$ END SUB SUB bit488setv (v!) '**************************************************************************** 'This subroutine has the Kepco BIT488 output a voltage v!. ' 'Input: ' v!, the voltage to output ' 'Zachary Wolf '3/22/95 '**************************************************************************** 'Set the GPIB terminators for the BIT488 CALL gpibterm(bit488terminP$, bit488termoutP$) 'Simplify the notation vmax! = bit488vmaxP! vmin! = bit488vminP! ilim! = bit488ilimP! imax! = bit488imaxP! 'Make sure the voltage is within the proper range '(Polarity is checked here. This is not done in the mmm check.) IF v! < vmin! THEN v! = vmin! IF v! > vmax! THEN v! = vmax! 'Determine the control code to send to the BIT488 IF v! >= 0 THEN c$ = "0" IF v! < 0 THEN c$ = "1" 'Determine the magnitude code to send to the BIT488 mmm% = ABS((v! / vmax!) * 999) IF mmm% < 10 THEN mmm$ = "00" + LTRIM$(STR$(mmm%)) IF mmm% < 100 AND mmm% >= 10 THEN mmm$ = "0" + LTRIM$(STR$(mmm%)) IF mmm% < 1000 AND mmm% >= 100 THEN mmm$ = LTRIM$(STR$(mmm%)) IF mmm% >= 1000 THEN mmm$ = "999" 'Determine the limit code to send to the BIT488 ll% = ABS((ilim! / imax!) * 99) IF ll% < 10 THEN ll$ = "0" + LTRIM$(STR$(ll%)) IF ll% < 100 AND ll% >= 10 THEN ll$ = LTRIM$(STR$(ll%)) IF ll% >= 100 THEN ll$ = "99" 'Output the voltage to the BIT488 CALL gpibout(bit488addrP$, c$ + mmm$ + ll$) 'Save the updated output voltage CALL bit488savev(0, v!) END SUB