DECLARE SUB dac488hrdo0 (d%) DECLARE SUB dac488hrdo1 (d%) DECLARE SUB hp3457c1smax (c%, vmax!) DECLARE SUB hp3457extsig (sig%) '**************************************************************************** 'Module HP3457 'This module contains I/O subroutines for the HP3457. ' 'Zachary Wolf '5/8/95 '**************************************************************************** 'Open the parameter file REM $INCLUDE: 'param.inc' 'The required parameters are in 'GPIB 'HP3457 ' 'The required parameters are 'gpibinP% 'gpiboutP% 'hp3457gpibaddrP% ' 'Sample HP3457 parameters 'HP3457 'CONST hp3457gpibaddrP% = 22 'HP3457A DVM GPIB address 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 '**************************************************************************** 'Initialization DIM v!(1 TO 200) 'Put the address number into a string gpibaddr$ = LTRIM$(STR$(hp3457gpibaddrP%)) 'Set the GPIB terminators PRINT #gpiboutP%, "TERM IN CR LF" PRINT #gpiboutP%, "TERM OUT CR LF EOI" 'Preset the HP3457 PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";PRESET" 'Set the input source to rear terminal PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";TERM REAR" 'Set the channel PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";CHAN " + LTRIM$(STR$(c%)) 'Set the voltage range to a large value PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";DCV 30" 'Set the A/D integration time to a small value PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";NPLC .0005" 'Turn off the autozero PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";AZERO OFF" 'Turn off the display PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";DISP OFF" 'Turn on the keyboard lock PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";LOCK ON" 'Turn off the delay PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";DELAY 0" 'Set the timer PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";TIMER .005" 'Send the readings to the memory PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";MSIZE " + LTRIM$(STR$(200 * 2 + 10)) PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";MEM FIFO" PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";MFORMAT SINT" 'Trigger the reading PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";TARM AUTO" PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";NRDGS 200, TIMER" PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";TRIG SGL" 'Get the readings FOR i% = 1 TO 200 PRINT #gpiboutP%, "ENTER " + gpibaddr$ INPUT #gpibinP%, v!(i%) 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 '**************************************************************************** 'Put the address number into a string gpibaddr$ = LTRIM$(STR$(hp3457gpibaddrP%)) 'Set the GPIB terminators PRINT #gpiboutP%, "TERM IN CR LF" PRINT #gpiboutP%, "TERM OUT CR LF EOI" 'Preset the HP3457 PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";PRESET" 'Set the input source to rear terminal PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";TERM REAR" 'Set the channel to read PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";CHAN " + LTRIM$(STR$(c%)) 'Set the AC bandwidth PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";ACBAND 250" 'Set the frequency source PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";FSOURCE ACV" 'Set up the meter to measure frequency PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";FREQ AUTO" 'Trigger the reading PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";TRIG SGL" 'Get the reading PRINT #gpiboutP%, "ENTER " + gpibaddr$ INPUT #gpibinP%, freq! 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 '**************************************************************************** 'Put the address number into a string gpibaddr$ = LTRIM$(STR$(hp3457gpibaddrP%)) 'Set the GPIB terminators PRINT #gpiboutP%, "TERM IN CR LF" PRINT #gpiboutP%, "TERM OUT CR LF EOI" 'Preset the HP3457 PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";PRESET" 'Set the input source to rear terminal PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";TERM REAR" 'Set the channel to read PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";CHAN " + LTRIM$(STR$(c%)) 'Set the A/D integration time PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";NPLC 10" 'Trigger the reading PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";TRIG AUTO" 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!) 'Put the address number into a string gpibaddr$ = LTRIM$(STR$(hp3457gpibaddrP%)) 'Set the GPIB terminators PRINT #gpiboutP%, "TERM IN CR LF" PRINT #gpiboutP%, "TERM OUT CR LF EOI" 'Preset the HP3457 PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";PRESET" 'Set the input source to rear terminal PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";TERM REAR" 'Set the channel PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";CHAN " + LTRIM$(STR$(c%)) 'Set the voltage range PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";DCV " + LTRIM$(STR$(vmax!)) 'Print out the voltage range used (for debugging) 'PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";RANGE?" 'PRINT #gpiboutP%, "ENTER " + gpibaddr$ 'INPUT #gpibinP%, range! 'PRINT "HP3457CNVTRIG, vmax = "; vmax!; ", range = "; range! 'Set the A/D integration time PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";NPLC .005" 'Turn off the autozero PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";AZERO OFF" 'Turn off the display PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";DISP OFF" 'Turn on the keyboard lock PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";LOCK ON" 'Turn off the delay PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";DELAY 0" 'Send the readings to the memory PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";MSIZE " + LTRIM$(STR$(n% * 2 + 10)) PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";MEM FIFO" PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";MFORMAT SINT" 'Set up the trigger trigger: PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";TARM AUTO" PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";NRDGS " + LTRIM$(STR$(n%)) + ", EXT" 'Turn on the input buffer so the GPIB line is not held PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";INBUF ON" 'Clear the encoder interface to stop trigger pulses from reaching the DVM CALL hp3457extsig(1) 'Trigger PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";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 PRINT #gpiboutP%, "SPOLL " + gpibaddr$ INPUT #gpibinP%, spoll% ' PRINT spoll% WEND 'Turn off the input buffer PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";INBUF OFF" 'Get the readings FOR i% = 0 TO n% - 1 PRINT #gpiboutP%, "ENTER " + gpibaddr$ INPUT #gpibinP%, v!(i%) NEXT i% 'Check for errors PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";ERR?" PRINT #gpiboutP%, "ENTER " + gpibaddr$ INPUT #gpibinP%, a% IF a% <> 0 THEN PRINT : PRINT "HP3457, ERR = "; a% PRINT "Remeasuring..." GOTO trigger END IF 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 '**************************************************************************** 'Put the address number into a string gpibaddr$ = LTRIM$(STR$(hp3457gpibaddrP%)) 'Set the GPIB terminators PRINT #gpiboutP%, "TERM IN CR LF" PRINT #gpiboutP%, "TERM OUT CR LF EOI" 'Preset the HP3457 PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";PRESET" 'Set the input source to rear terminal PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";TERM REAR" 'Set the channel to read PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";CHAN " + LTRIM$(STR$(c%)) 'Set the number of power line cycles to reject noise (affects resolution) PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";NPLC 10" 'Set the function to measure resistance, autorange, % resolution PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";FUNC OHM, AUTO, .01" 'Set up the math function to convert resistance to temperature PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";MATH CTHRM" 'Trigger the reading PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";TRIG SGL" 'Get the reading PRINT #gpiboutP%, "ENTER " + gpibaddr$ INPUT #gpibinP%, tc! 'Put the DVM back in a high impedance state PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";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 '**************************************************************************** 'Put the address number into a string gpibaddr$ = LTRIM$(STR$(hp3457gpibaddrP%)) 'Set the GPIB terminators PRINT #gpiboutP%, "TERM IN CR LF" PRINT #gpiboutP%, "TERM OUT CR LF EOI" 'Preset the HP3457 PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";PRESET" 'Set the input source to rear terminal PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";TERM REAR" 'Set the channel to read PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";CHAN " + LTRIM$(STR$(c%)) 'Set the A/D integration time PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";NPLC 10" 'Trigger the reading PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";TRIG SGL" 'Get the reading PRINT #gpiboutP%, "ENTER " + gpibaddr$ INPUT #gpibinP%, v! END SUB SUB hp3457err '**************************************************************************** 'This subroutine asks the HP3457 about any errors and prints the result. ' 'Zachary Wolf '8/14/94 '**************************************************************************** 'Put the address number into a string gpibaddr$ = LTRIM$(STR$(hp3457gpibaddrP%)) 'Set the GPIB terminators PRINT #gpiboutP%, "TERM IN CR LF" PRINT #gpiboutP%, "TERM OUT CR LF EOI" 'Any errors? PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";ERR?" PRINT #gpiboutP%, "ENTER " + gpibaddr$ INPUT #gpibinP%, a% 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 dac488hrdo0(1) IF sig% = 1 THEN CALL dac488hrdo1(1) 'IF sig% = 0 THEN CALL dac488do1(1) 'IF sig% = 1 THEN CALL dac488do0(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 PRINT #gpiboutP%, "TERM IN CR LF" PRINT #gpiboutP%, "TERM OUT CR LF EOI" END SUB SUB hp3457init '**************************************************************************** 'This subroutine initializes the HP3457. ' 'Zachary Wolf '4/19/94 '**************************************************************************** 'Put the address number into a string gpibaddr$ = LTRIM$(STR$(hp3457gpibaddrP%)) 'Set the GPIB terminators PRINT #gpiboutP%, "TERM IN CR LF" PRINT #gpiboutP%, "TERM OUT CR LF EOI" 'Message PRINT PRINT "Resetting the HP3457..." 'Clear the HP3457 PRINT #gpiboutP%, "CLEAR " + gpibaddr$ 'Preset PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";PRESET" 'Display the ID PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";ID?" PRINT #gpiboutP%, "ENTER " + gpibaddr$ LINE INPUT #gpibinP%, id$ PRINT id$ END SUB SUB hp3457preset '**************************************************************************** 'This subroutine presets the HP3457. ' 'Zachary Wolf '8/18/94 '**************************************************************************** 'Put the address number into a string gpibaddr$ = LTRIM$(STR$(hp3457gpibaddrP%)) 'Set the GPIB terminators PRINT #gpiboutP%, "TERM IN CR LF" PRINT #gpiboutP%, "TERM OUT CR LF EOI" 'Preset the HP3457 PRINT #gpiboutP%, "OUTPUT " + gpibaddr$ + ";PRESET" END SUB