DECLARE SUB hp3457c1smax (c%, vmax!) DECLARE SUB hp3457extsig (sig%) DECLARE SUB gpibclr () DECLARE SUB gpibclrdev (addr$) DECLARE SUB gpibin (addr$, msg$) DECLARE SUB gpibout (addr$, cmd$) DECLARE SUB gpibspoll (addr$, value$) DECLARE SUB gpibterm (termin$, termout$) DECLARE SUB gpibtimeout (nseconds%) '**************************************************************************** 'Module HP3457 'This module contains I/O subroutines for the HP3457. ' 'Zachary Wolf '7/28/95 '**************************************************************************** 'Common area for shared parameters COMMON SHARED /hp3457/ gpibinP%, gpiboutP%, hp3457addrP$ 'Semi-permanent parameters CONST terminP$ = "CR LF" 'GPIB input terminator CONST termoutP$ = "CR LF EOI" 'GPIB output terminator CONST vrangeP$ = "3" 'CNTVTRIG: the voltage range the HP3457 is set to CONST nplcP$ = ".005" 'CNTVTRIG, CNVTRIG: sampling time, number of power line cycles SUB hp3457c1smax (c%, vmax!) '**************************************************************************** 'This subroutine takes 200 voltage readings spaced 5 ms apart (ie. sample 'for 1 sec) and returns the maximum value. ' 'Input: ' c%, the DVM channel to read ' 'Output: ' vmax!, the maximum absolute value of the measured voltages ' 'Zachary Wolf '10/3/94 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(terminP$, termoutP$) 'Initialization DIM v!(1 TO 200) 'Preset the HP3457 CALL gpibout(hp3457addrP$, "PRESET") 'Set the input source to rear terminal CALL gpibout(hp3457addrP$, "TERM REAR") 'Set the channel CALL gpibout(hp3457addrP$, "CHAN " + LTRIM$(STR$(c%))) 'Set the voltage range to a large value CALL gpibout(hp3457addrP$, "DCV 30") 'Set the A/D integration time to a small value CALL gpibout(hp3457addrP$, "NPLC .0005") 'Turn off the autozero CALL gpibout(hp3457addrP$, "AZERO OFF") 'Turn off the display CALL gpibout(hp3457addrP$, "DISP OFF") 'Turn on the keyboard lock CALL gpibout(hp3457addrP$, "LOCK ON") 'Turn off the delay CALL gpibout(hp3457addrP$, "DELAY 0") 'Set the timer CALL gpibout(hp3457addrP$, "TIMER .005") 'Send the readings to the memory CALL gpibout(hp3457addrP$, "MSIZE " + LTRIM$(STR$(200 * 2 + 10))) CALL gpibout(hp3457addrP$, "MEM FIFO") CALL gpibout(hp3457addrP$, "MFORMAT SINT") 'Trigger the reading CALL gpibout(hp3457addrP$, "TARM AUTO") CALL gpibout(hp3457addrP$, "NRDGS 200, TIMER") CALL gpibout(hp3457addrP$, "TRIG SGL") 'Get the readings FOR i% = 1 TO 200 CALL gpibin(hp3457addrP$, value$) v!(i%) = VAL(value$) NEXT i% 'Find the maximum vmax! = 0 FOR i% = 1 TO 200 IF ABS(v!(i%)) > vmax! THEN vmax! = ABS(v!(i%)) NEXT i% END SUB SUB hp3457cf (c%, freq!) '**************************************************************************** 'This routine reads the frequency of the voltage applied to a specified 'channel of the HP3457 DVM. ' 'Input: ' c%, the DVM channel to read ' 'Output: ' freq!, the measured frequency ' 'Zachary Wolf '4/21/94, 8/12/94 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(terminP$, termoutP$) 'Preset the HP3457 CALL gpibout(hp3457addrP$, "PRESET") 'Set the input source to rear terminal CALL gpibout(hp3457addrP$, "TERM REAR") 'Set the channel to read CALL gpibout(hp3457addrP$, "CHAN " + LTRIM$(STR$(c%))) 'Set the AC bandwidth CALL gpibout(hp3457addrP$, "ACBAND 250") 'Set the frequency source CALL gpibout(hp3457addrP$, "FSOURCE ACV") 'Set up the meter to measure frequency CALL gpibout(hp3457addrP$, "FREQ AUTO") 'Trigger the reading CALL gpibout(hp3457addrP$, "TRIG SGL") 'Get the reading CALL gpibin(hp3457addrP$, value$) freq! = VAL(value$) END SUB SUB hp3457cmon (c%) '**************************************************************************** 'This routine displays the voltage applied to a specified channel of the 'HP3457 DVM on the front panel. Voltages can be monitored while the 'program is running. ' 'Input: ' c%, the DVM channel to read and display ' 'Zachary Wolf '5/23/94 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(terminP$, termoutP$) 'Preset the HP3457 CALL gpibout(hp3457addrP$, "PRESET") 'Set the input source to rear terminal CALL gpibout(hp3457addrP$, "TERM REAR") 'Set the channel to read CALL gpibout(hp3457addrP$, "CHAN " + LTRIM$(STR$(c%))) 'Set the A/D integration time CALL gpibout(hp3457addrP$, "NPLC 10") 'Trigger the reading CALL gpibout(hp3457addrP$, "TRIG AUTO") END SUB SUB hp3457cntvtrig (c%, n%, t!, v!()) '**************************************************************************** 'This subroutine takes n voltage readings spaced t seconds apart and returns 'the values. ' 'Input: ' c%, the DVM channel to read ' n%, the number of voltage samples ' t!, the time between voltage samples ' 'Output: ' v!(0 to n%-1), the measured voltages ' 'Zachary Wolf '4/21/94, 3/18/95, 5/29/95, 5/21/96 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(terminP$, termoutP$) 'Preset the HP3457 CALL gpibout(hp3457addrP$, "PRESET") 'Set the input source to rear terminal CALL gpibout(hp3457addrP$, "TERM REAR") 'Set the channel CALL gpibout(hp3457addrP$, "CHAN " + LTRIM$(STR$(c%))) 'Set the voltage range CALL gpibout(hp3457addrP$, "DCV " + vrangeP$) 'Set the A/D integration time CALL gpibout(hp3457addrP$, "NPLC " + nplcP$) 'Turn off the autozero CALL gpibout(hp3457addrP$, "AZERO OFF") 'Turn off the display CALL gpibout(hp3457addrP$, "DISP OFF") 'Set the timer CALL gpibout(hp3457addrP$, "TIMER " + LTRIM$(STR$(t!))) 'Send the readings to the memory CALL gpibout(hp3457addrP$, "MATH OFF") CALL gpibout(hp3457addrP$, "MSIZE " + LTRIM$(STR$(n% * 2 + 10))) CALL gpibout(hp3457addrP$, "MEM FIFO") CALL gpibout(hp3457addrP$, "MFORMAT SINT") 'Trigger the reading CALL gpibout(hp3457addrP$, "TARM HOLD") CALL gpibout(hp3457addrP$, "NRDGS " + LTRIM$(STR$(n%)) + ", TIMER") CALL gpibout(hp3457addrP$, "TRIG EXT") CALL gpibtimeout(40) CALL gpibout(hp3457addrP$, "TARM SGL,1") 'Get the readings FOR i% = 0 TO n% - 1 CALL gpibin(hp3457addrP$, value$) v!(i%) = VAL(value$) NEXT i% 'Any errors? CALL gpibout(hp3457addrP$, "ERR?") CALL gpibin(hp3457addrP$, value$) a% = VAL(value$) IF a% <> 0 THEN PRINT "HP3457, ERR = "; a% END SUB SUB hp3457cnvtrig (c%, n%, v!()) '**************************************************************************** 'This subroutine takes n triggered voltage readings and returns the values. 'It uses an external signal to control the encoder interface which sends 'trigger pulses. ' 'Input: ' c%, the DVM channel to read ' n%, the number of voltage samples ' 'Output: ' v!(0 to n%-1), the measured voltages ' 'Zachary Wolf '4/21/94 '**************************************************************************** 'First sample for 1 sec and get the maximum voltage 'This is used to set the voltage range CALL hp3457c1smax(c%, vmax!) 'Set the GPIB terminators CALL gpibterm(terminP$, termoutP$) 'Preset the HP3457 CALL gpibout(hp3457addrP$, "PRESET") 'Set the input source to rear terminal CALL gpibout(hp3457addrP$, "TERM REAR") 'Set the channel CALL gpibout(hp3457addrP$, "CHAN " + LTRIM$(STR$(c%))) 'Set the voltage range CALL gpibout(hp3457addrP$, "DCV " + LTRIM$(STR$(vmax!))) 'Set the A/D integration time CALL gpibout(hp3457addrP$, "NPLC " + nplcP$) 'Turn off the autozero CALL gpibout(hp3457addrP$, "AZERO OFF") 'Turn off the display CALL gpibout(hp3457addrP$, "DISP OFF") 'Turn on the keyboard lock CALL gpibout(hp3457addrP$, "LOCK ON") 'Turn off the delay CALL gpibout(hp3457addrP$, "DELAY 0") 'Send the readings to the memory CALL gpibout(hp3457addrP$, "MSIZE " + LTRIM$(STR$(n% * 2 + 10))) CALL gpibout(hp3457addrP$, "MEM FIFO") CALL gpibout(hp3457addrP$, "MFORMAT SINT") 'Set up the trigger trigger: CALL gpibout(hp3457addrP$, "TARM AUTO") CALL gpibout(hp3457addrP$, "NRDGS " + LTRIM$(STR$(n%)) + ", EXT") 'Turn on the input buffer so the GPIB line is not held CALL gpibout(hp3457addrP$, "INBUF ON") 'Clear the encoder interface to stop trigger pulses from reaching the DVM CALL hp3457extsig(1) 'Trigger CALL gpibout(hp3457addrP$, "TRIG SGL") 'Add a delay to make sure the DVM is set up and waiting for trigger pulses t0! = TIMER WHILE TIMER - t0! < .1 'delay .1 second WEND 'Signal the encoder interface to allow trigger pulses to the DVM CALL hp3457extsig(0) 'Wait until the readings are complete spoll% = 0 WHILE NOT spoll% AND 16 CALL gpibspoll(hp3457addrP$, value$) spoll% = VAL(value$) ' PRINT spoll% WEND 'Turn off the input buffer CALL gpibout(hp3457addrP$, "INBUF OFF") 'Get the readings FOR i% = 0 TO n% - 1 CALL gpibin(hp3457addrP$, value$) v!(i%) = VAL(value$) NEXT i% 'Check for errors CALL gpibout(hp3457addrP$, "ERR?") CALL gpibin(hp3457addrP$, value$) a% = VAL(value$) IF a% <> 0 THEN PRINT : PRINT "HP3457, ERR = "; a% PRINT "Remeasuring..." GOTO trigger END IF 'Clear the extender boxes after an spoll CALL gpibclr END SUB SUB hp3457cr (c%, r!) '**************************************************************************** 'This routine reads the resistance connected to a specified channel of the 'HP3457 DVM. ' 'Input: ' c%, the DVM channel to read ' 'Output: ' r!, the measured resistance ' 'Zachary Wolf '6/8/94, 7/19/95 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(terminP$, termoutP$) 'Preset the HP3457 CALL gpibout(hp3457addrP$, "PRESET") 'Set the input source to rear terminal CALL gpibout(hp3457addrP$, "TERM REAR") 'Set the channel to read CALL gpibout(hp3457addrP$, "CHAN " + LTRIM$(STR$(c%))) 'Set the number of power line cycles to reject noise (affects resolution) CALL gpibout(hp3457addrP$, "NPLC 10") 'Set the function to measure resistance, autorange, % resolution CALL gpibout(hp3457addrP$, "FUNC OHM, AUTO, .01") 'Trigger the reading CALL gpibout(hp3457addrP$, "TRIG SGL") 'Get the reading CALL gpibin(hp3457addrP$, value$) r! = VAL(value$) 'Put the DVM back in a high impedance state CALL gpibout(hp3457addrP$, "PRESET") END SUB SUB hp3457ctc (c%, tc!) '**************************************************************************** 'This routine reads the temperature from a thermistor connected to a 'specified channel of the HP3457 DVM. ' 'Input: ' c%, the DVM channel to read ' 'Output: ' tc!, the measured temperature in degrees Celsius ' 'Zachary Wolf '6/10/94, 7/19/95 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(terminP$, termoutP$) 'Preset the HP3457 CALL gpibout(hp3457addrP$, "PRESET") 'Set the input source to rear terminal CALL gpibout(hp3457addrP$, "TERM REAR") 'Set the channel to read CALL gpibout(hp3457addrP$, "CHAN " + LTRIM$(STR$(c%))) 'Set the number of power line cycles to reject noise (affects resolution) CALL gpibout(hp3457addrP$, "NPLC 10") 'Set the function to measure resistance, autorange, % resolution CALL gpibout(hp3457addrP$, "FUNC OHM, AUTO, .01") 'Set up the math function to convert resistance to temperature CALL gpibout(hp3457addrP$, "MATH CTHRM") 'Trigger the reading CALL gpibout(hp3457addrP$, "TRIG SGL") 'Get the reading CALL gpibin(hp3457addrP$, value$) tc! = VAL(value$) 'Put the DVM back in a high impedance state CALL gpibout(hp3457addrP$, "PRESET") END SUB SUB hp3457ctf (c%, tf!) '**************************************************************************** 'This routine reads the temperature from a thermistor connected to a 'specified channel of the HP3457 DVM. ' 'Input: ' c%, the DVM channel to read ' 'Output: ' tf!, the measured temperature in degrees Fahrenheit ' 'Zachary Wolf '6/10/94, 7/19/95 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(terminP$, termoutP$) 'Preset the HP3457 CALL gpibout(hp3457addrP$, "PRESET") 'Set the input source to rear terminal CALL gpibout(hp3457addrP$, "TERM REAR") 'Set the channel to read CALL gpibout(hp3457addrP$, "CHAN " + LTRIM$(STR$(c%))) 'Set the number of power line cycles to reject noise (affects resolution) CALL gpibout(hp3457addrP$, "NPLC 10") 'Set the function to measure resistance, autorange, % resolution CALL gpibout(hp3457addrP$, "FUNC OHM, AUTO, .01") 'Set up the math function to convert resistance to temperature CALL gpibout(hp3457addrP$, "MATH FTHRM") 'Trigger the reading CALL gpibout(hp3457addrP$, "TRIG SGL") 'Get the reading CALL gpibin(hp3457addrP$, value$) tf! = VAL(value$) 'Put the DVM back in a high impedance state CALL gpibout(hp3457addrP$, "PRESET") END SUB SUB hp3457cv (c%, v!) '**************************************************************************** 'This routine reads the voltage applied to a specified channel of the 'HP3457 DVM. ' 'Input: ' c%, the DVM channel to read ' 'Output: ' v!, the measured voltage ' 'Zachary Wolf '4/21/94, 7/19/95 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(terminP$, termoutP$) 'Preset the HP3457 CALL gpibout(hp3457addrP$, "PRESET") 'Set the input source to rear terminal CALL gpibout(hp3457addrP$, "TERM REAR") 'Set the channel to read CALL gpibout(hp3457addrP$, "CHAN " + LTRIM$(STR$(c%))) 'Set the A/D integration time CALL gpibout(hp3457addrP$, "NPLC 10") 'Trigger the reading CALL gpibout(hp3457addrP$, "TRIG SGL") 'Get the reading CALL gpibin(hp3457addrP$, value$) v! = VAL(value$) END SUB SUB hp3457err '**************************************************************************** 'This subroutine asks the HP3457 about any errors and prints the result. ' 'Zachary Wolf '8/14/94, 7/19/95 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(terminP$, termoutP$) 'Any errors? CALL gpibout(hp3457addrP$, "ERR?") CALL gpibin(hp3457addrP$, value$) a% = VAL(value$) PRINT "HP3457, ERR = "; a% END SUB SUB hp3457extsig (sig%) '**************************************************************************** 'This subroutine uses other devices to send a signal required by the HP3457. ' 'Input: ' sig%, 0 or 1, the signal to be sent ' 'Zachary Wolf '10/3/94 '**************************************************************************** 'Output the requested signal (only if sig% = 0 or 1) 'IF sig% = 0 THEN CALL dac488digout(1, 0) 'IF sig% = 1 THEN CALL dac488digout(1, 1) 'IF sig% = 0 THEN CALL dac488hrdo0(1) 'IF sig% = 1 THEN CALL dac488hrdo1(1) 'IF sig% = 1 THEN OUT 6916, 1 'IF sig% = 0 THEN OUT 6916, 0 'Set the GPIB terminators for the HP3457 after a call to another hardware device CALL gpibterm(terminP$, termoutP$) END SUB SUB hp3457init '**************************************************************************** 'This subroutine initializes the HP3457. ' 'Zachary Wolf '4/19/94, 5/19/95 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(terminP$, termoutP$) 'Message PRINT PRINT "Resetting the HP3457..." 'Clear the HP3457 CALL gpibclrdev(hp3457addrP$) 'Preset CALL gpibout(hp3457addrP$, "PRESET") 'Display the ID CALL gpibout(hp3457addrP$, "ID?") CALL gpibin(hp3457addrP$, id$) PRINT id$ END SUB SUB hp3457preset '**************************************************************************** 'This subroutine presets the HP3457. ' 'Zachary Wolf '8/18/94 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(terminP$, termoutP$) 'Preset the HP3457 CALL gpibout(hp3457addrP$, "PRESET") END SUB SUB hp3457readtc (tc!) '**************************************************************************** 'This routine reads the temperature from a thermistor connected to 'the HP3457 DVM. It assumes the subroutine hp3457setuptc has already 'been called to set up the DVM for the measurement. ' 'Output: ' tc!, the measured temperature in degrees Celsius ' 'Zachary Wolf '8/18/94, 7/19/95 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(terminP$, termoutP$) 'Trigger the reading CALL gpibout(hp3457addrP$, "TRIG SGL") 'Get the reading CALL gpibin(hp3457addrP$, value$) tc! = VAL(value$) END SUB SUB hp3457readv (v!) '**************************************************************************** 'This routine reads the voltage applied to a specified channel of the 'HP3457 DVM. The meter is assumed to have been already configured. ' 'Output: ' v!, the measured voltage ' 'Zachary Wolf '8/18/94, 7/19/95 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(terminP$, termoutP$) 'Trigger the reading CALL gpibout(hp3457addrP$, "TRIG SGL") 'Get the reading CALL gpibin(hp3457addrP$, value$) v! = VAL(value$) END SUB SUB hp3457setpar (gpibinf%, gpiboutf%, hp3457addr$) '**************************************************************************** 'This subroutine initializes the HP3457. ' 'Input: ' gpibinf%, gpib input file number ' gpiboutf%, gpib output file number ' hp3457addr$, gpib address in a string ' 'Zachary Wolf '4/19/94, 5/19/95 '**************************************************************************** 'Make sure the input parameters have reasonable values IF gpibinf% < 0 OR gpibinf% > 100 THEN PRINT "HP3457: GPIB problem" EXIT SUB END IF IF gpiboutf% < 0 OR gpiboutf% > 100 THEN PRINT "HP3457: GPIB problem" EXIT SUB END IF IF hp3457addr$ = "" THEN PRINT "HP3457: GPIB problem" EXIT SUB END IF 'Save the GPIB information in a common block for future use gpibinP% = gpibinf% gpiboutP% = gpiboutf% hp3457addrP$ = hp3457addr$ END SUB SUB hp3457setuptc (c%) '**************************************************************************** 'This subroutine sets up the HP3457 to read temperatures in deg C from a 'specified channel. ' 'Input: ' c%, the DVM channel to read ' 'Zachary Wolf '8/18/94, 7/19/95 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(terminP$, termoutP$) 'Preset the HP3457 CALL gpibout(hp3457addrP$, "PRESET") 'Set the input source to rear terminal CALL gpibout(hp3457addrP$, "TERM REAR") 'Set the channel to read CALL gpibout(hp3457addrP$, "CHAN " + LTRIM$(STR$(c%))) 'Set the number of power line cycles to reject noise (affects resolution) CALL gpibout(hp3457addrP$, "NPLC 10") 'Set the function to measure resistance, autorange, % resolution CALL gpibout(hp3457addrP$, "FUNC OHM, AUTO, .01") 'Set up the math function to convert resistance to temperature CALL gpibout(hp3457addrP$, "MATH CTHRM") END SUB SUB hp3457setupv (c%) '**************************************************************************** 'This subroutine sets up the HP3457 to read the voltage from a specified 'channel. ' 'Input: ' c%, the DVM channel to prepare ' 'Zachary Wolf '8/18/94, 7/19/95 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(terminP$, termoutP$) 'Preset the HP3457 CALL gpibout(hp3457addrP$, "PRESET") 'Set the input source to rear terminal CALL gpibout(hp3457addrP$, "TERM REAR") 'Set the channel to read CALL gpibout(hp3457addrP$, "CHAN " + LTRIM$(STR$(c%))) 'Set the A/D integration time CALL gpibout(hp3457addrP$, "NPLC 10") END SUB