'**************************************************************************** 'Module DAC488HR 'This module contains I/O subroutines for the DAC488HR. ' 'Zachary Wolf '5/8/95 '**************************************************************************** 'Open the parameter file REM $INCLUDE: 'param.inc' 'The required parameters are in 'GPIB 'DAC488HR ' 'The required parameters are 'gpibinP% 'gpiboutP% 'dac488hrgpibaddrP% ' 'Sample DAC488HR parameters 'DAC488HR 'CONST dac488hrgpibaddrP% = 10 'IOTech DAC488HR/2 GPIB address 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 ' 'Zachary Wolf '6/24/94, 8/9/94 '**************************************************************************** 'Put the DAC address in a string gpibaddr$ = LTRIM$(STR$(dac488hrgpibaddrP%)) '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 " + gpibaddr$ + ";D? X" PRINT #gpiboutP%, "ENTER " + gpibaddr$ INPUT #gpibinP%, 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 #gpiboutP%, "OUTPUT " + gpibaddr$ + ";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 ' 'Zachary Wolf '6/24/94, 8/9/94 '**************************************************************************** 'Put the DAC address in a string gpibaddr$ = LTRIM$(STR$(dac488hrgpibaddrP%)) '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 " + gpibaddr$ + ";D? X" PRINT #gpiboutP%, "ENTER " + gpibaddr$ INPUT #gpibinP%, 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 #gpiboutP%, "OUTPUT " + gpibaddr$ + ";D" + p$ + " X" END SUB SUB dac488hrerr '**************************************************************************** 'This subroutine gets error messages from the IOTech DAC488HR/2. ' 'Zachary Wolf '9/21/94 '**************************************************************************** 'Put the DAC address in a string gpibaddr$ = LTRIM$(STR$(dac488hrgpibaddrP%)) 'Set the GPIB terminators for the DAC PRINT #gpiboutP%, "TERM OUT LF EOI" PRINT #gpiboutP%, "TERM IN LF EOI" 'Perform the error query PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";E? X" PRINT #gpiboutP%, "ENTER " + gpibaddr$ LINE INPUT #gpibinP%, a$ PRINT PRINT "DAC488HRERR error status: "; a$ END SUB SUB dac488hrgetv (dacv!) '**************************************************************************** 'This subroutine gets the output voltage from the IOTech DAC488HR/2 output. ' 'Output: ' dacv!, the DAC voltage which is being output ' 'Zachary Wolf '4/19/94 '**************************************************************************** 'Put the DAC address in a string gpibaddr$ = LTRIM$(STR$(dac488hrgpibaddrP%)) 'Set the GPIB terminators for the DAC PRINT #gpiboutP%, "TERM OUT LF EOI" PRINT #gpiboutP%, "TERM IN LF EOI" 'Get the DAC voltage value PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";V? X" PRINT #gpiboutP%, "ENTER " + gpibaddr$ INPUT #gpibinP%, dacv$ dacv$ = MID$(dacv$, 2) dacv! = VAL(dacv$) END SUB SUB dac488hrid '**************************************************************************** 'This subroutine initializes the IOTech DAC488HR/2. ' 'Zachary Wolf '4/19/94 '**************************************************************************** 'Put the DAC address in a string gpibaddr$ = LTRIM$(STR$(dac488hrgpibaddrP%)) 'Set the GPIB terminators for the DAC PRINT #gpiboutP%, "TERM OUT LF EOI" PRINT #gpiboutP%, "TERM IN LF EOI" 'Message PRINT PRINT "Verifying the DAC..." 'Get the DAC ID PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";U9 X" PRINT #gpiboutP%, "ENTER " + gpibaddr$ LINE INPUT #gpibinP%, a$ PRINT a$ END SUB SUB dac488hrinit '**************************************************************************** 'This subroutine initializes the IOTech DAC488HR/2. ' 'Zachary Wolf '4/19/94 '**************************************************************************** 'Put the DAC address in a string gpibaddr$ = LTRIM$(STR$(dac488hrgpibaddrP%)) '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%, "OUTPUT " + gpibaddr$ + ";*RX" 'Wait until the DAC is reset SLEEP 2 spoll! = 0 WHILE NOT spoll AND 4 PRINT #gpiboutP%, "SPOLL " + gpibaddr$ INPUT #gpibinP%, spoll! ' PRINT "spoll = "; spoll! SLEEP 1 WEND 'Get the DAC ID PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";U9 X" PRINT #gpiboutP%, "ENTER " + gpibaddr$ LINE INPUT #gpibinP%, a$ PRINT a$ END SUB SUB dac488hrqsetv '**************************************************************************** 'This subroutine sets up the IOTech DAC488HR/2 for static DC output. ' 'Zachary Wolf '4/19/94 '**************************************************************************** 'Put the DAC address in a string gpibaddr$ = LTRIM$(STR$(dac488hrgpibaddrP%)) 'Set the GPIB terminators for the DAC PRINT #gpiboutP%, "TERM OUT LF EOI" PRINT #gpiboutP%, "TERM IN LF EOI" 'Set the output port to # 1 PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";P1 X" 'Set the data format to signed volts PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";F0 X" END SUB SUB dac488hrsetupv '**************************************************************************** 'This subroutine sets up the IOTech DAC488HR/2 for static DC output. ' 'Zachary Wolf '4/19/94 '**************************************************************************** 'Put the DAC address in a string gpibaddr$ = LTRIM$(STR$(dac488hrgpibaddrP%)) 'Set the GPIB terminators for the DAC PRINT #gpiboutP%, "TERM OUT LF EOI" PRINT #gpiboutP%, "TERM IN LF EOI" 'Set the output port to # 1 PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";P1 X" 'Set the voltage range to 5 V unipolar PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";R7 X" 'Set the data format to signed volts PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";F0 X" 'Set the initial voltage value to 0 PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";V0 X" END SUB SUB dac488hrv (v!) '**************************************************************************** 'This subroutine has the IOTech DAC488HR/2 output a voltage v!. ' 'Input: ' v!, the voltage to output ' 'Zachary Wolf '4/19/94 '**************************************************************************** 'Put the DAC address in a string gpibaddr$ = LTRIM$(STR$(dac488hrgpibaddrP%)) 'Set the GPIB terminators for the DAC PRINT #gpiboutP%, "TERM OUT LF EOI" PRINT #gpiboutP%, "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 #gpiboutP%, "OUTPUT " + gpibaddr$ + ";V"; PRINT #gpiboutP%, USING "###.#####"; v!; PRINT #gpiboutP%, " X" END SUB