DECLARE SUB bit488savev (ctrl%, v!) DECLARE SUB bit488savei (ctrl%, i!) '**************************************************************************** 'Module BIT488 'This module contains I/O subroutines for the Kepco BOP supplies 'driven by the BIT488 controller. ' 'The following parameters must be present in param.inc. 'const gpibinP% = 1 'the GPIB input file number 'const gpiboutP% = 2 'the GPIB output file number 'const bit488addrP% = 1 'the Kepco BIT488 GPIB address '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 '**************************************************************************** 'Open the parameter file REM $INCLUDE: 'param.inc' 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 bit488i (i!) '**************************************************************************** 'This subroutine has the Kepco BIT488 output a current i!. ' 'Input: ' i!, the current to output ' 'Zachary Wolf '3/24/95 '**************************************************************************** 'Get the GPIB I/O file numbers and the BIT488 address gpibin% = gpibinP% gpibout% = gpiboutP% bit488addr% = bit488addrP% 'Put the BIT488 address in a string bit488addr$ = STR$(bit488addr%) 'Set the GPIB terminators for the BIT488 PRINT #gpibout%, "TERM OUT CR LF EOI" PRINT #gpibout%, "TERM IN CR LF EOI" '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 PRINT #gpibout%, "OUTPUT " + bit488addr$ + ";" + c$ + mmm$ + ll$ 'Save the updated output current CALL bit488savei(0, i!) END SUB SUB bit488init '**************************************************************************** 'This subroutine initializes the Kepco BIT488 controller for the BOP supply. ' 'Inputs from param.inc: ' gpibinP%, GPIB input file number ' gpiboutP%, GPIB output file number ' bit488addrP%, the BIT488 GPIB address ' 'Zachary Wolf '3/22/95 '**************************************************************************** 'Get the GPIB I/O file numbers and the BIT488 address from the parameters gpibin% = gpibinP% gpibout% = gpiboutP% bit488addr% = bit488addrP% 'Put the BIT488 address in a string bit488addr$ = STR$(bit488addr%) 'Set the GPIB terminators for the BIT488 PRINT #gpibout%, "TERM OUT CR LF EOI" PRINT #gpibout%, "TERM IN CR LF EOI" 'Message PRINT PRINT "Resetting the BIT488..." 'Reset the BIT488 PRINT #gpibout%, "CLEAR " + bit488addr$ 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 bit488v (v!) '**************************************************************************** 'This subroutine has the Kepco BIT488 output a voltage v!. ' 'Input: ' v!, the voltage to output ' 'Zachary Wolf '3/22/95 '**************************************************************************** 'Get the GPIB I/O file numbers and the BIT488 address gpibin% = gpibinP% gpibout% = gpiboutP% bit488addr% = bit488addrP% 'Put the BIT488 address in a string bit488addr$ = STR$(bit488addr%) 'Set the GPIB terminators for the BIT488 PRINT #gpibout%, "TERM OUT CR LF EOI" PRINT #gpibout%, "TERM IN CR LF EOI" '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 PRINT #gpibout%, "OUTPUT " + bit488addr$ + ";" + c$ + mmm$ + ll$ 'Save the updated output voltage CALL bit488savev(0, v!) END SUB