DECLARE SUB hp3457cv (c%, v!) DECLARE SUB k7011closecc (card%, chan%) DECLARE SUB k7011openall () DECLARE SUB sencalcb (id%, v!, b!) DECLARE SUB sencheckpar (ok$) DECLARE SUB sengetb (id%, b!) DECLARE SUB sengetbav (id%, b!, sb!) DECLARE SUB sengetname (id%, name$) DECLARE SUB sengetv (id%, v!) DECLARE SUB senlogcalcb (logfile$, id%, v!, voffset!, calib!, b!) DECLARE SUB senloggetb (logfile$, id%, b!) DECLARE SUB senloggetbav (logfile$, id%, b!, sb!) DECLARE SUB senloggetv (logfile$, id%, muxcard%, muxchan%, muxhpchan%, v!) DECLARE SUB senlogmeas (logfile$) '**************************************************************************** 'Module SENTRON ' 'This module contains routines for measuring the voltage from a Sentron Hall 'probe and applying a calibration to get a field reading. ' 'Zachary Wolf '10/3/97 '**************************************************************************** 'Common block for module level parameters COMMON SHARED /sentron/ logfileP$, muxhpchanP%, nmeasaveP%, nhallP%, nhallparamP%, hallparamP!(), hallnameP$() 'Hall probe parameter info 'DIM hallparamP!(1 TO nhallP%, 1 TO nhallparamP%) 'DIM hallnameP$(1 TO nhallP%) 'The first index (1 to nhallP%) is the Hall probe ID number 'The second index (1 to nhallparamP%) gives the parameter being stored 'Parameter 1 is the multiplexer channel number for the hall probe 'Parameter 2 is the calibration factor (T/V) 'Parameter 3 is the voltage offset with B = 0 (V) SUB sencalcb (id%, v!, b!) '*************************************************************************** 'This subroutine calculates the magnetic field strength from the Hall 'probe voltage. ' 'Input: ' id%, Hall probe ID number ' v!, Hall probe voltage (V) ' 'Output: ' b!, magnetic field strength (T) ' 'Zachary Wolf '10/3/97, 1/22/98 '*************************************************************************** 'Get the Hall probe's offset voltage voffset! = hallparamP!(id%, 3) 'Remove the offset from v! v! = v! - voffset! 'Get the Hall probe's calibration constant calib! = hallparamP!(id%, 2) 'Calculate the field strength b! = v! * calib! 'Log the calculation CALL senlogcalcb(logfileP$, id%, v!, voffset!, calib!, b!) END SUB SUB sencheckpar (ok$) '**************************************************************************** 'This subroutine checks that all required parameters have been assigned 'values. ' 'Output: ' ok$, "y" if parameter assignments are ok, "n" otherwise ' 'Zachary Wolf '10/3/97 '**************************************************************************** 'Default value ok$ = "n" 'Logfile IF logfileP$ = "" THEN PRINT "SENTRON: Log file not defined" EXIT SUB END IF 'HP3457 channel the multiplexer is plugged in to IF muxhpchanP% < 0 OR muxhpchanP% > 9 THEN PRINT "SENTRON: HP3457 channel number not allowed" EXIT SUB END IF 'Number of Hall probes IF nhallP% < 1 OR nhallP% > 80! THEN PRINT "SENTRON: improper number of Hall probes" EXIT SUB END IF 'Number of hall probe parameters IF nhallparamP% < 2 THEN PRINT "SENTRON: improper number of hall probe parameters" EXIT SUB END IF 'Loop over Hall probes FOR i% = 1 TO nhallP% 'Hall probe MUX channel IF hallparamP!(i%, 1) < 1 OR hallparamP!(i%, 1) > 80 THEN PRINT "SENTRON: multiplexer channel number not allowed" EXIT SUB END IF 'Hall probe calibration factor IF hallparamP!(i%, 2) <= 0! THEN PRINT "HALL: Hall probe calibration value not allowed" EXIT SUB END IF 'End loop over Hall probes NEXT i% 'If we made it this far, all parameters have values ok$ = "y" END SUB SUB sengetb (id%, b!) '**************************************************************************** 'This subroutine uses the Hall probe output voltage to determine the 'magnetic field strength. ' 'Input: ' id%, Hall probe ID number ' 'Output: ' b!, magnetic field strength (T) ' 'Zachary Wolf '10/3/97 '**************************************************************************** 'Check input parameters IF id% < 1 OR id% > nhallP% THEN PRINT PRINT "!!! Problem in SENGETB" b! = 0! EXIT SUB END IF 'Check module level parameters CALL sencheckpar(ok$) IF ok$ <> "y" THEN PRINT PRINT "!!! Problem in SENGETB" b! = 0! EXIT SUB END IF 'Get the Hall probe's output voltage CALL sengetv(id%, v!) 'Calculate the field strength CALL sencalcb(id%, v!, b!) 'Log the result CALL senloggetb(logfileP$, id%, b!) END SUB SUB sengetbav (id%, b!, sb!) '**************************************************************************** 'This subroutine finds the average field reading from repeated measurements. ' 'Input: ' id%, Hall probe ID number ' 'Output: ' b!, average field value (T) ' sb!, standard deviation b! (T) ' 'Zachary Wolf '1/14/98 '**************************************************************************** 'Check input parameters IF id% < 1 OR id% > nhallP% THEN PRINT PRINT "!!! Problem in SENGETBAV" b! = 0! sb! = 0! EXIT SUB END IF 'Check module level parameters CALL sencheckpar(ok$) IF ok$ <> "y" THEN PRINT PRINT "!!! Problem in SENGETBAV" b! = 0! sb! = 0! EXIT SUB END IF 'Simplify the notation nm% = nmeasaveP% 'Initialize data arrays DIM bmeas!(1 TO nm%) 'Log the measurement CALL senlogmeas(logfileP$) 'Loop over measurements for averaging FOR j% = 1 TO nm% 'Get the field reading CALL sengetb(id%, bmeas!(j%)) 'End averaging loop NEXT j% 'Compute the average of the measurements b! = 0! FOR j% = 1 TO nm% b! = b! + bmeas!(j%) NEXT j% b! = b! / nm% 'Compute the standard deviation of the measurements sb! = 0! FOR j% = 1 TO nm% sb! = sb! + (bmeas!(j%) - b!) ^ 2 NEXT j% sb! = SQR(sb! / nm%) 'Write the result to the log file CALL senloggetbav(logfileP$, id%, b!, sb!) END SUB SUB sengetname (id%, name$) '**************************************************************************** 'This subroutine gets the name of a given Hall probe. ' 'Input: ' id%, Hall probe ID number ' 'Output: ' name$, name of the specified Hall probe ' 'Zachary Wolf '10/3/97 '**************************************************************************** 'Check input parameters IF id% < 1 OR id% > nhallP% THEN PRINT PRINT "!!! Problem in SENGETNAME" name$ = "" EXIT SUB END IF 'Check all module level parameters CALL sencheckpar(ok$) IF ok$ <> "y" THEN PRINT PRINT "!!! Problem in SENGETNAME" name$ = "" EXIT SUB END IF 'Return the hall name name$ = hallnameP$(id%) END SUB SUB sengetpar (id%, calib!) '**************************************************************************** 'This subroutine returns the specified Hall probe's parameters. ' 'Input: ' id%, Hall probe ID number ' 'Output: ' calib!, calibration constant (T/V) ' 'Zachary Wolf '10/3/97 '**************************************************************************** 'Check input parameters IF id% < 1 OR id% > nhallP% THEN PRINT PRINT "!!! Problem in SENGETPAR" EXIT SUB END IF 'Check module level parameters CALL sencheckpar(ok$) IF ok$ <> "y" THEN PRINT PRINT "!!! Problem in SENGETPAR" EXIT SUB END IF 'Get the Hall probe's parameters calib! = hallparamP!(id%, 2) END SUB SUB sengetv (id%, v!) '**************************************************************************** 'This subroutine gets the output voltage from a given Hall probe. ' 'Input: ' id%, Hall probe ID number ' 'Output: ' v!, Hall probe output voltage (V) ' 'Zachary Wolf '10/3/97 '**************************************************************************** 'Check input parameters IF id% < 1 OR id% > nhallP% THEN PRINT PRINT "!!! Problem in SENGETV" v! = 0! EXIT SUB END IF 'Check all module level parameters CALL sencheckpar(ok$) IF ok$ <> "y" THEN PRINT PRINT "!!! Problem in SENGETV" v! = 0! EXIT SUB END IF 'Determine the multiplexer channel number muxchan% = hallparamP!(id%, 1) 'Determine the multiplexer card number IF muxchan% <= 40 THEN muxcard% = 1 ELSE muxcard% = 2 muxchan% = muxchan% - 40 END IF 'Get the Hall probe output voltage CALL k7011closecc(muxcard%, muxchan%) CALL hp3457cv(muxhpchanP%, v!) CALL k7011openall 'Log the result CALL senloggetv(logfileP$, id%, muxcard%, muxchan%, muxhpchanP%, v!) 'Debug 'PRINT USING "Vhall = ###.####### V"; v! END SUB SUB senlogcalcb (logfile$, id%, v!, voffset!, calib!, b!) '*************************************************************************** 'This subroutine logs the calculation of the field strength from the 'Hall voltage. ' 'Input: ' logfile$, log file ' id%, probe ID number ' v!, Hall voltage (V) ' voffset!, Hall probe offset voltage (V) ' calib!, calibration constant (T/V) ' b!, field strength (T) ' 'Zachary Wolf '10/3/97 '*************************************************************************** 'Open the log file filenum% = FREEFILE OPEN logfile$ FOR APPEND AS filenum% 'Write the parameters and result PRINT #filenum%, " Calib: ID = "; id%; PRINT #filenum%, USING ", Voffset = ##.####### V"; voffset!; PRINT #filenum%, USING ", Cal Const = ###.###### T/V"; calib! 'Close the log file CLOSE filenum% END SUB SUB senloggetb (logfile$, id%, b!) '**************************************************************************** 'This subroutine records the measured field strength to the log file. ' 'Input: ' logfile$, the name of the log file ' id%, Hall probe ID number ' b!, field strength (T) ' 'Zachary Wolf '10/3/97 '**************************************************************************** 'Open the log file filenum% = FREEFILE OPEN logfile$ FOR APPEND AS filenum% 'Write the field strength PRINT #filenum%, " Result: ID = "; id%; ", B = "; PRINT #filenum%, USING "###.######"; b!; PRINT #filenum%, " T" 'Close the log file CLOSE filenum% END SUB SUB senloggetbav (logfile$, id%, b!, sb!) '**************************************************************************** 'This subroutine records the measured field strength to the log file. ' 'Input: ' logfile$, the name of the log file ' id%, Hall probe ID number ' b!, field strength (T) ' sb!, rms variation of field strength readings (T) ' 'Zachary Wolf '1/14/98 '**************************************************************************** 'Open the log file filenum% = FREEFILE OPEN logfile$ FOR APPEND AS filenum% 'Write the field strength PRINT #filenum%, TIME$; " Hall Probe ID = "; id%; ", Bave = "; PRINT #filenum%, USING " ###.######"; b!; PRINT #filenum%, " +-"; PRINT #filenum%, USING " ###.######"; sb!; PRINT #filenum%, " T" 'Close the log file CLOSE filenum% END SUB SUB senloggetv (logfile$, id%, muxcard%, muxchan%, muxhpchan%, v!) '**************************************************************************** 'This subroutine records the Hall probes's output voltage to the log file. ' 'Input: ' logfile$, the name of the log file ' id%, Hall probe ID number ' muxcard%, multiplexer card number ' muxchan%, multiplexer channel number ' muxhpchan%, HP3457 channel the multiplexer is plugged in to ' v!, Hall probe output voltage (V) ' 'Zachary Wolf '10/3/97 '**************************************************************************** 'Open the log file filenum% = FREEFILE OPEN logfile$ FOR APPEND AS filenum% 'Write the integrated voltages PRINT #filenum%, TIME$; " Meas Vhall: ID = "; id%; ", MUX card = "; muxcard%; ", chan = "; muxchan%; PRINT #filenum%, ", V = "; PRINT #filenum%, USING " ##.#######"; v!; PRINT #filenum%, " V" 'Close the log file CLOSE filenum% END SUB SUB senlogmeas (logfile$) '**************************************************************************** 'This subroutine records an average field measurement to the log file. ' 'Input: ' logfile$, the name of the log file ' 'Zachary Wolf '1/19/98 '**************************************************************************** 'Open the log file filenum% = FREEFILE OPEN logfile$ FOR APPEND AS filenum% 'Print the results PRINT #filenum%, PRINT #filenum%, TIME$; " Average Field Measurement..." 'Close the log file CLOSE filenum% END SUB SUB sensetpar (logfile$, muxhpchan%, nmeasave%, nhall%, nhallparam%, hallparam!(), hallname$()) '**************************************************************************** 'This subroutine sets the parameters for the SENTRON module. ' 'Input: ' logfile$, log file ' muxhpchan%, HP3457 channel the multiplexer is plugged in to ' nmeasave%, number of measurements for average ' nhall%, number of Hall probes ' nhallparam%, number of Hall probe parameters ' hallparam!(), array of Hall probe parameters ' hallname$(), array of Hall probe names ' 'Zachary Wolf '10/24/97 '**************************************************************************** 'Save the information in a common block for future use logfileP$ = logfile$ muxhpchanP% = muxhpchan% nmeasaveP% = nmeasave% nhallP% = nhall% nhallparamP% = nhallparam% DIM hallparamP!(1 TO nhallP%, 1 TO nhallparamP%) FOR i% = 1 TO nhallP% FOR j% = 1 TO nhallparamP% hallparamP!(i%, j%) = hallparam!(i%, j%) NEXT j% NEXT i% DIM hallnameP$(1 TO nhallP%) FOR i% = 1 TO nhallP% hallnameP$(i%) = hallname$(i%) NEXT i% END SUB SUB senuser '**************************************************************************** 'This routine gives Hall probe information from the probe requested by 'the user. ' 'Zachary Wolf '11/14/97 '**************************************************************************** 'Get the Hall probe ID number from the user hallprobe: PRINT INPUT "Enter the Hall probe ID number to report on (0 to end): ", id$ IF id$ = "end" OR id$ = "END" OR id$ = "quit" OR id$ = "QUIT" OR id$ = "0" THEN EXIT SUB id% = VAL(id$) 'Check IF id% < 1 OR id% > nhallP% THEN PRINT "The Hall probe ID number must be between 1 and"; nhallP% GOTO hallprobe END IF 'Message PRINT "Hall probe ID number:"; id% 'Display the hall probe name CALL sengetname(id%, name$) PRINT "Name: "; name$ 'Display the probe's parameters PRINT "Multiplexer channel: "; hallparamP!(id%, 1) PRINT "Probe offset voltage: "; hallparamP!(id%, 3); " V" PRINT "Calibration constant: "; hallparamP!(id%, 2); " T/V" 'Display the field reading CALL sengetbav(id%, b!, sb!) PRINT "Field reading: "; b!; " +- "; sb!; " T" 'Debug CALL k7011closecc(1, INT(hallparamP!(id%, 1))) CALL k7011closecc(1, 31) INPUT "Holding the multiplexer channel. Press ENTER to continue.", a$ CALL k7011openall 'Return to beginning of loop GOTO hallprobe END SUB