DECLARE SUB gpibclr () DECLARE SUB dac488hrsetupcv (c%) DECLARE SUB dac488hrsetupv () '**************************************************************************** 'Module DAC488HR 'This module contains I/O subroutines for the DAC488HR. ' 'Zachary Wolf '5/8/95 '**************************************************************************** 'Common area for shared parameters COMMON SHARED /dac488hr/ gpibinP%, gpiboutP%, dac488hraddrP$ 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 '**************************************************************************** '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 " + dac488hraddrP$ + ";D? X" PRINT #gpiboutP%, "ENTER " + dac488hraddrP$ 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 " + dac488hraddrP$ + ";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 '**************************************************************************** '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 " + dac488hraddrP$ + ";D? X" PRINT #gpiboutP%, "ENTER " + dac488hraddrP$ 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 " + dac488hraddrP$ + ";D" + p$ + " X" END SUB SUB dac488hrerr '**************************************************************************** 'This subroutine gets error messages from the IOTech DAC488HR/2. ' 'Zachary Wolf '9/21/94 '**************************************************************************** '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 " + dac488hraddrP$ + ";E? X" PRINT #gpiboutP%, "ENTER " + dac488hraddrP$ LINE INPUT #gpibinP%, a$ PRINT PRINT "DAC488HRERR error status: "; a$ END SUB SUB dac488hrgetcv (c%, dacv!) '**************************************************************************** 'This subroutine gets the output voltage from the IOTech DAC488HR/2 output. ' 'Input: ' c%, the DAC channel to give the voltage for ' 'Output: ' dacv!, the DAC voltage which is being output ' 'Zachary Wolf '4/19/94 '**************************************************************************** '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% > 2 THEN PRINT "DAC488HRGETCV: Bad channel number." EXIT SUB END IF 'Set the output port to # c% c$ = LTRIM$(STR$(c%)) PRINT #gpiboutP%, "OUTPUT " + dac488hraddrP$ + ";P" + c$ + " X" 'Get the DAC voltage value PRINT #gpiboutP%, "OUTPUT " + dac488hraddrP$ + ";V? X" PRINT #gpiboutP%, "ENTER " + dac488hraddrP$ 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 '**************************************************************************** '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 " + dac488hraddrP$ + ";U9 X" PRINT #gpiboutP%, "ENTER " + dac488hraddrP$ LINE INPUT #gpibinP%, a$ PRINT a$ END SUB SUB dac488hrinit '**************************************************************************** 'This subroutine initializes the IOTech DAC488HR/2. ' 'Zachary Wolf '4/19/94 '**************************************************************************** '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 " + dac488hraddrP$ + ";*RX" 'Wait until the DAC is reset SLEEP 2 spoll! = 0 WHILE NOT spoll AND 4 PRINT #gpiboutP%, "SPOLL " + dac488hraddrP$ INPUT #gpibinP%, spoll! ' PRINT "spoll = "; spoll! SLEEP 1 WEND 'Get the DAC ID PRINT #gpiboutP%, "OUTPUT " + dac488hraddrP$ + ";U9 X" PRINT #gpiboutP%, "ENTER " + dac488hraddrP$ LINE INPUT #gpibinP%, a$ PRINT a$ 'Setup for voltage output FOR c% = 1 TO 2 CALL dac488hrsetupcv(c%) NEXT c% 'Clear the GPIB system after an spoll CALL gpibclr END SUB SUB dac488hrsetcv (c%, v!) '**************************************************************************** 'This subroutine has the IOTech DAC488HR/2 output a voltage v! on channel c%. ' 'Input: ' c%, the DAC channel to output the voltage on ' v!, the voltage to output ' 'Zachary Wolf '4/19/94 '**************************************************************************** '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% > 2 THEN PRINT "DAC488HRGETCV: Bad channel number." EXIT SUB END IF 'Set the output port to # c% c$ = LTRIM$(STR$(c%)) PRINT #gpiboutP%, "OUTPUT " + dac488hraddrP$ + ";P" + c$ + " X" '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 " + dac488hraddrP$ + ";V"; PRINT #gpiboutP%, USING "###.#####"; v!; PRINT #gpiboutP%, " X" END SUB SUB dac488hrsetpar (gpibinf%, gpiboutf%, dac488hraddr$) '**************************************************************************** 'This subroutine sets the parameters for the IOTech DAC488HR. ' 'Input: ' gpibinf%, gpib input file number ' gpiboutf%, gpib output file number ' dac488hraddr$, 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 "DAC488HR: GPIB problem" EXIT SUB END IF IF gpiboutf% < 0 OR gpiboutf% > 100 THEN PRINT "DAC488HR: GPIB problem" EXIT SUB END IF IF dac488hraddr$ = "" THEN PRINT "DAC488HR: GPIB problem" EXIT SUB END IF 'Save the GPIB information in a common block for future use gpibinP% = gpibinf% gpiboutP% = gpiboutf% dac488hraddrP$ = dac488hraddr$ END SUB SUB dac488hrsetupcv (c%) '**************************************************************************** 'This subroutine sets up the IOTech DAC488HR/2 for static DC output. ' 'Input: ' c%, DAC channel to set up ' 'Zachary Wolf '4/19/94 '**************************************************************************** '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% > 2 THEN PRINT "DAC488HRGETCV: Bad channel number." EXIT SUB END IF 'Set the output port to # c% c$ = LTRIM$(STR$(c%)) PRINT #gpiboutP%, "OUTPUT " + dac488hraddrP$ + ";P" + c$ + " X" 'Set the voltage range to 5 V unipolar PRINT #gpiboutP%, "OUTPUT " + dac488hraddrP$ + ";R7 X" 'Set the data format to signed volts PRINT #gpiboutP%, "OUTPUT " + dac488hraddrP$ + ";F0 X" 'Set the initial voltage value to 0 PRINT #gpiboutP%, "OUTPUT " + dac488hraddrP$ + ";V0 X" END SUB