'**************************************************************************** 'Module DAC488HR 'This module contains I/O subroutines for the DAC488HR. ' 'The following parameters must be present in param.inc. 'gpibinP%, the GPIB input file number 'gpiboutP%, the GPIB output file number 'dac488hraddrP%, the IOTech DAC488HR/2 GPIB address '**************************************************************************** 'Open the parameter file REM $INCLUDE: 'param.inc' SUB dac488hrdo0 (d%) '**************************************************************************** 'This subroutine has the IOTech DAC488 output a low TTL level on digital line 'number d% (1 to 8). The other lines are not changed. ' 'Input: ' d%, line number 1 to 8 ' 'Input parameters: ' gpibinP%, GPIB input file number ' gpiboutP%, GPIB output file number ' dac488hraddrP%, the DAC GPIB address ' 'Zachary Wolf '6/24/94, 8/9/94 '**************************************************************************** 'Get the GPIB I/O file numbers and the DAC address gpibin% = gpibinP% gpibout% = gpiboutP% dacaddr% = dac488hraddrP% 'Put the DAC address in a string dacaddr$ = STR$(dacaddr%) 'Set the GPIB terminators for the DAC PRINT #gpibout%, "TERM OUT LF EOI" PRINT #gpibout%, "TERM IN LF EOI" 'Get the existing output digital port configuration PRINT #gpibout%, "OUTPUT " + dacaddr$ + ";D? X" PRINT #gpibout%, "ENTER " + dacaddr$ INPUT #gpibin%, p$ 'Remove the leading D p$ = MID$(p$, 2) 'Extract the value p% = VAL(p$) 'Convert the line number to an integer with the appropriate bit pattern dp% = 2 ^ (d% - 1) 'Leave existing lines alone, except make line d% low dp% = NOT dp% p% = p% AND dp% 'Get the integer equivalent of the bit pattern and put it in a string p$ = LTRIM$(STR$(p%)) 'Send the new port configuration PRINT #gpibout%, "OUTPUT " + dacaddr$ + ";D" + p$ + " X" END SUB SUB dac488hrdo1 (d%) '**************************************************************************** 'This subroutine has the IOTech DAC488 output a high TTL level on digital line 'number d% (1 to 8). The other lines are not changed. ' 'Input: ' d%, line number 1 to 8 ' 'Input parameters: ' gpibinP%, GPIB input file number ' gpiboutP%, GPIB output file number ' dac488hraddrP%, the DAC GPIB address ' 'Zachary Wolf '6/24/94, 8/9/94 '**************************************************************************** 'Get the GPIB I/O file numbers and the DAC address gpibin% = gpibinP% gpibout% = gpiboutP% dacaddr% = dac488hraddrP% 'Put the DAC address in a string dacaddr$ = STR$(dacaddr%) 'Set the GPIB terminators for the DAC PRINT #gpibout%, "TERM OUT LF EOI" PRINT #gpibout%, "TERM IN LF EOI" 'Get the existing output digital port configuration PRINT #gpibout%, "OUTPUT " + dacaddr$ + ";D? X" PRINT #gpibout%, "ENTER " + dacaddr$ INPUT #gpibin%, p$ 'Remove the leading D p$ = MID$(p$, 2) 'Extract the value p% = VAL(p$) 'Convert the line number to an integer with the appropriate bit pattern dp% = 2 ^ (d% - 1) 'Leave existing lines alone, except make line d% high p% = p% OR dp% 'Get the integer equivalent of the bit pattern and put it in a string p$ = LTRIM$(STR$(p%)) 'Send the new port configuration PRINT #gpibout%, "OUTPUT " + dacaddr$ + ";D" + p$ + " X" END SUB SUB dac488hrerr '**************************************************************************** 'This subroutine gets error messages from the IOTech DAC488HR/2. ' 'Inputs from param.inc: ' gpibinP%, GPIB input file number ' gpiboutP%, GPIB output file number ' dacaddrP%, the DAC GPIB address ' 'Zachary Wolf '9/21/94 '**************************************************************************** 'Get the GPIB I/O file numbers and the DAC address from the parameters gpibin% = gpibinP% gpibout% = gpiboutP% dacaddr% = dac488hraddrP% 'Put the DAC address in a string dacaddr$ = STR$(dacaddr%) 'Set the GPIB terminators for the DAC PRINT #gpibout%, "TERM OUT LF EOI" PRINT #gpibout%, "TERM IN LF EOI" 'Perform the error query PRINT #gpibout%, "OUTPUT " + dacaddr$ + ";E? X" PRINT #gpibout%, "ENTER " + dacaddr$ LINE INPUT #gpibin%, a$ PRINT PRINT "DAC488HRERR error status: "; a$ END SUB SUB dac488hrgetv (dacv!) '**************************************************************************** 'This subroutine gets the output voltage from the IOTech DAC488HR/2 output. ' 'Input parameters: ' gpibinP%, GPIB input file number ' gpiboutP%, GPIB output file number ' dacaddrP%, the DAC GPIB address ' 'Output: ' dacv!, the DAC voltage which is being output ' 'Zachary Wolf '4/19/94 '**************************************************************************** 'Get the GPIB I/O file numbers and the DAC address gpibin% = gpibinP% gpibout% = gpiboutP% dacaddr% = dac488hraddrP% 'Put the DAC address in a string dacaddr$ = STR$(dacaddr%) 'Set the GPIB terminators for the DAC PRINT #gpibout%, "TERM OUT LF EOI" PRINT #gpibout%, "TERM IN LF EOI" 'Get the DAC voltage value PRINT #gpibout%, "OUTPUT " + dacaddr$ + ";V? X" PRINT #gpibout%, "ENTER " + dacaddr$ INPUT #gpibin%, dacv$ dacv$ = MID$(dacv$, 2) dacv! = VAL(dacv$) END SUB SUB dac488hrid '**************************************************************************** 'This subroutine initializes the IOTech DAC488HR/2. ' 'Inputs from param.inc: ' gpibinP%, GPIB input file number ' gpiboutP%, GPIB output file number ' dacaddrP%, the DAC GPIB address ' 'Zachary Wolf '4/19/94 '**************************************************************************** 'Get the GPIB I/O file numbers and the DAC address from the parameters gpibin% = gpibinP% gpibout% = gpiboutP% dacaddr% = dac488hraddrP% 'Put the DAC address in a string dacaddr$ = STR$(dacaddr%) 'Set the GPIB terminators for the DAC PRINT #gpibout%, "TERM OUT LF EOI" PRINT #gpibout%, "TERM IN LF EOI" 'Message PRINT PRINT "Verifying the DAC..." 'Get the DAC ID PRINT #gpibout%, "OUTPUT " + dacaddr$ + ";U9 X" PRINT #gpibout%, "ENTER " + dacaddr$ LINE INPUT #gpibin%, a$ PRINT a$ END SUB SUB dac488hrinit '**************************************************************************** 'This subroutine initializes the IOTech DAC488HR/2. ' 'Inputs from param.inc: ' gpibinP%, GPIB input file number ' gpiboutP%, GPIB output file number ' dacaddrP%, the DAC GPIB address ' 'Zachary Wolf '4/19/94 '**************************************************************************** 'Get the GPIB I/O file numbers and the DAC address from the parameters gpibin% = gpibinP% gpibout% = gpiboutP% dacaddr% = dac488hraddrP% 'Put the DAC address in a string dacaddr$ = STR$(dacaddr%) 'Set the GPIB terminators for the DAC PRINT #gpibout%, "TERM OUT LF EOI" PRINT #gpibout%, "TERM IN LF EOI" 'Message PRINT PRINT "Resetting the DAC..." 'Reset the DAC PRINT #gpibout%, "OUTPUT " + dacaddr$ + ";*RX" 'Wait until the DAC is reset SLEEP 2 spoll! = 0 WHILE NOT spoll AND 4 PRINT #gpibout%, "SPOLL " + dacaddr$ INPUT #gpibin%, spoll! ' PRINT "spoll = "; spoll! SLEEP 1 WEND 'Get the DAC ID PRINT #gpibout%, "OUTPUT " + dacaddr$ + ";U9 X" PRINT #gpibout%, "ENTER " + dacaddr$ LINE INPUT #gpibin%, a$ PRINT a$ END SUB SUB dac488hrqsetv '**************************************************************************** 'This subroutine sets up the IOTech DAC488HR/2 for static DC output. ' 'Inputs from param.inc: ' gpibinP%, GPIB input file number ' gpiboutP%, GPIB output file number ' dacaddrP%, the DAC GPIB address ' 'Zachary Wolf '4/19/94 '**************************************************************************** 'Get the GPIB I/O file numbers and the DAC address from the parameters gpibin% = gpibinP% gpibout% = gpiboutP% dacaddr% = dac488hraddrP% 'Put the DAC address in a string dacaddr$ = STR$(dacaddr%) 'Set the GPIB terminators for the DAC PRINT #gpibout%, "TERM OUT LF EOI" PRINT #gpibout%, "TERM IN LF EOI" 'Set the output port to # 1 PRINT #gpibout%, "OUTPUT " + dacaddr$ + ";P1 X" 'Set the data format to signed volts PRINT #gpibout%, "OUTPUT " + dacaddr$ + ";F0 X" END SUB SUB dac488hrsetupv '**************************************************************************** 'This subroutine sets up the IOTech DAC488HR/2 for static DC output. ' 'Inputs from param.inc: ' gpibinP%, GPIB input file number ' gpiboutP%, GPIB output file number ' dacaddrP%, the DAC GPIB address ' 'Zachary Wolf '4/19/94 '**************************************************************************** 'Get the GPIB I/O file numbers and the DAC address from the parameters gpibin% = gpibinP% gpibout% = gpiboutP% dacaddr% = dac488hraddrP% 'Put the DAC address in a string dacaddr$ = STR$(dacaddr%) 'Set the GPIB terminators for the DAC PRINT #gpibout%, "TERM OUT LF EOI" PRINT #gpibout%, "TERM IN LF EOI" 'Set the output port to # 1 PRINT #gpibout%, "OUTPUT " + dacaddr$ + ";P1 X" 'Set the voltage range to 5 V unipolar PRINT #gpibout%, "OUTPUT " + dacaddr$ + ";R7 X" 'Set the data format to signed volts PRINT #gpibout%, "OUTPUT " + dacaddr$ + ";F0 X" 'Set the initial voltage value to 0 PRINT #gpibout%, "OUTPUT " + dacaddr$ + ";V0 X" END SUB SUB dac488hrv (v!) '**************************************************************************** 'This subroutine has the IOTech DAC488HR/2 output a voltage v!. ' 'Input: ' v!, the voltage to output ' 'Input parameters: ' gpibinP%, GPIB input file number ' gpiboutP%, GPIB output file number ' dac488hraddrP%, the DAC GPIB address ' 'Zachary Wolf '4/19/94 '**************************************************************************** 'Get the GPIB I/O file numbers and the DAC address gpibin% = gpibinP% gpibout% = gpiboutP% dacaddr% = dac488hraddrP% 'Put the DAC address in a string dacaddr$ = STR$(dacaddr%) 'Set the GPIB terminators for the DAC PRINT #gpibout%, "TERM OUT LF EOI" PRINT #gpibout%, "TERM IN LF EOI" 'Make sure the voltage is within the proper range IF v! < 0! THEN v! = 0! IF v! > 5! THEN v! = 5! 'Output the voltage to the DAC PRINT #gpibout%, "OUTPUT " + dacaddr$ + ";V"; PRINT #gpibout%, USING "###.#####"; v!; PRINT #gpibout%, " X" END SUB