DECLARE SUB dac488setupcv (c%) '**************************************************************************** 'Module DAC488 'This module contains I/O subroutines for the IOtech DAC488/4. ' 'Zachary Wolf '7/23/95 '**************************************************************************** 'Common area for shared parameters COMMON SHARED /dac488/ gpibinP%, gpiboutP%, dac488addrP$ SUB dac488digout (linenum%, lohi%) '**************************************************************************** 'This subroutine has the IOTech DAC488 output a TTL level on digital line 'number linenum% (1 to 8). ' 'Input: ' linenum%, line number 1 to 8 ' lohi%, TTL level 0 or 1 ' 'Zachary Wolf '6/24/94, 7/19/95 '**************************************************************************** 'Set the GPIB terminators for the DAC PRINT #gpiboutP%, "TERM OUT LF EOI" PRINT #gpiboutP%, "TERM IN LF EOI" 'Get the existing output digital port configuration PRINT #gpiboutP%, "OUTPUT " + dac488addrP$ + ";D?" PRINT #gpiboutP%, "ENTER " + dac488addrP$ INPUT #gpibinP%, config$ 'Remove the leading D config$ = MID$(config$, 2) 'Extract the value as an integer config% = VAL(config$) 'Convert the line number to an integer with the appropriate bit pattern linecode% = 2 ^ (linenum% - 1) 'Leave existing lines alone, except make linenum% high or low IF lohi% = 0 THEN linecode% = NOT linecode% config% = config% AND linecode% END IF IF lohi% = 1 THEN config% = config% OR linecode% END IF 'Get the integer equivalent of the bit pattern and put it in a string config$ = LTRIM$(STR$(config%)) 'Send the new port configuration PRINT #gpiboutP%, "OUTPUT " + dac488addrP$ + ";D" + config$ + " X" END SUB SUB dac488getcv (c%, v!) '**************************************************************************** 'This subroutine gets the output voltage from the IOTech DAC488 analog output 'channel # c%. ' 'Input: ' c%, the DAC channel to read the voltage from ' 'Output: ' v!, the DAC voltage which is being output ' 'Zachary Wolf '4/19/94, 9/10/94, 7/19/95 '**************************************************************************** 'Set the GPIB terminators for the DAC PRINT #gpiboutP%, "TERM OUT LF EOI" PRINT #gpiboutP%, "TERM IN LF EOI" 'Test the channel number IF c% < 1 OR c% > 4 THEN PRINT "DAC488GETCV: Bad channel number." EXIT SUB END IF 'Set the output port to # c% c$ = LTRIM$(STR$(c%)) PRINT #gpiboutP%, "OUTPUT " + dac488addrP$ + ";P" + c$ + " X" 'Get the DAC voltage value PRINT #gpiboutP%, "OUTPUT " + dac488addrP$ + ";V? X" PRINT #gpiboutP%, "ENTER " + dac488addrP$ INPUT #gpibinP%, v$ v$ = MID$(v$, 2) v! = VAL(v$) END SUB SUB dac488init '**************************************************************************** 'This subroutine initializes the IOTech DAC488 in the 123 power system 'of bldg 26. ' 'Zachary Wolf '6/24/94, 7/19/95 '**************************************************************************** 'Set the GPIB terminators for the DAC PRINT #gpiboutP%, "TERM OUT LF EOI" PRINT #gpiboutP%, "TERM IN LF EOI" 'Message PRINT PRINT "Resetting the DAC..." 'Reset the DAC PRINT #gpiboutP%, "CLEAR " + dac488addrP$ 'Set the DAC terminators to LF EOI PRINT #gpiboutP%, "OUTPUT " + dac488addrP$ + ";Y3 X" 'LF PRINT #gpiboutP%, "OUTPUT " + dac488addrP$ + ";K0 X" 'EOI 'Turn the test LED on and off PRINT #gpiboutP%, "OUTPUT " + dac488addrP$ + ";W1 X" PRINT #gpiboutP%, "OUTPUT " + dac488addrP$ + ";W0 X" 'Get the DAC ID PRINT #gpiboutP%, "OUTPUT " + dac488addrP$ + ";U0 X" PRINT #gpiboutP%, "ENTER " + dac488addrP$ LINE INPUT #gpibinP%, a$ PRINT a$ 'Set up all channels of the DAC FOR c% = 1 TO 4 CALL dac488setupcv(c%) NEXT c% END SUB SUB dac488setcv (c%, v!) '**************************************************************************** 'This subroutine has the IOTech DAC488 output a voltage v! on channel c%. ' 'Input: ' c%, the DAC488 channel (1 to 4) to output the voltage on ' v!, the voltage to output ' 'Zachary Wolf '9/10/94, 7/19/95 '**************************************************************************** 'Set the GPIB terminators for the DAC PRINT #gpiboutP%, "TERM OUT LF EOI" PRINT #gpiboutP%, "TERM IN LF EOI" 'Test the channel number IF c% < 1 OR c% > 4 THEN PRINT "DAC488CV: Bad channel number." EXIT SUB END IF 'Set the output port to # c% c$ = LTRIM$(STR$(c%)) PRINT #gpiboutP%, "OUTPUT " + dac488addrP$ + ";P" + c$ + " X" 'Make sure the voltage is within the proper range IF v! < 0! THEN v! = 0! IF v! > 10! THEN v! = 10! 'Output the voltage to the DAC PRINT #gpiboutP%, "OUTPUT " + dac488addrP$ + ";V"; PRINT #gpiboutP%, USING "###.#####"; v!; PRINT #gpiboutP%, " X" END SUB SUB dac488setpar (gpibinf%, gpiboutf%, dac488addr$) '**************************************************************************** 'This subroutine sets the parameters for the IOTech DAC488 in the '123 power system of bldg 26. ' 'Input: ' gpibinf%, gpib input file number ' gpiboutf%, gpib output file number ' dac488addr$, gpib address in a string ' 'Zachary Wolf '6/24/94, 7/19/95 '**************************************************************************** 'Make sure the input parameters have reasonable values IF gpibinf% < 0 OR gpibinf% > 100 THEN PRINT "dac488: GPIB problem" EXIT SUB END IF IF gpiboutf% < 0 OR gpiboutf% > 100 THEN PRINT "dac488: GPIB problem" EXIT SUB END IF IF dac488addr$ = "" THEN PRINT "dac488: GPIB problem" EXIT SUB END IF 'Save the GPIB information in a common block for future use gpibinP% = gpibinf% gpiboutP% = gpiboutf% dac488addrP$ = dac488addr$ END SUB SUB dac488setupcv (c%) '**************************************************************************** 'This subroutine sets up the IOTech DAC488 for static DC output. ' 'Input: ' c%, channel number (1 to 4) to set up ' 'Zachary Wolf '9/10/94, 7/19/95 '**************************************************************************** 'Test the channel number IF c% < 1 OR c% > 4 THEN PRINT "DAC488SETUPCV: Bad channel number." EXIT SUB END IF 'Set the GPIB terminators for the DAC PRINT #gpiboutP%, "TERM OUT LF EOI" PRINT #gpiboutP%, "TERM IN LF EOI" 'Set the control mode to trigger on X PRINT #gpiboutP%, "OUTPUT " + dac488addrP$ + ";C0 X" 'Set the output port to # c% c$ = LTRIM$(STR$(c%)) PRINT #gpiboutP%, "OUTPUT " + dac488addrP$ + ";P" + c$ + " X" 'Turn off autoranging PRINT #gpiboutP%, "OUTPUT " + dac488addrP$ + ";A0 X" 'Set the voltage range to +-10 V PRINT #gpiboutP%, "OUTPUT " + dac488addrP$ + ";R3 X" 'Set the output data format to signed volts PRINT #gpiboutP%, "OUTPUT " + dac488addrP$ + ";O0 X" 'Set the initial voltage value to 0 PRINT #gpiboutP%, "OUTPUT " + dac488addrP$ + ";V0 X" END SUB