DECLARE SUB pmtlogtslice (logfile$, name1$, t1!, name2$, t2!, name3$, t3!) DECLARE SUB pmtcalctemp (r!, t!) DECLARE SUB pmtcheckpar (ok$) DECLARE SUB pmtdattempvstim (logfile$, tim$, t1!, t2!, t3!) DECLARE SUB pmtgettn (n%, tn!) DECLARE SUB pmtlogtn (logfile$, n%, r!, tn!, tlin!) DECLARE SUB hp3457cr (c%, r!) '**************************************************************************** 'Module PMTEMP 'This module contains drivers to measure permanent magnet temperatures. ' 'Zachary Wolf '11/18/95 '**************************************************************************** 'Common block for module parameters COMMON SHARED /pmtemp/ logfileP$, datfileP$, pmt1hpchanP%, pmt2hpchanP%, pmt3hpchanP%, pmt1nameP$, pmt2nameP$, pmt3nameP$, pmtr25cthermP!, pmtdrdtat25cthermP!, pmttimbtwnmeassecP% SUB pmtcalctemp (r!, t!) '**************************************************************************** 'This subroutine calculates the temperature from the resistance of a 'thermistor. The resistance at 25C and its derivative come from the 'module common parameters. ' 'Input: ' r!, thermistor resistance in ohms ' 'Output: ' t!, calculated thermistor temperature ' 'Zachary Wolf '6/8/96 '**************************************************************************** 'Simplify the notation r25! = pmtr25cthermP! drdt25! = pmtdrdtat25cthermP! t25! = 273.15 + 25! 'The functional dependance is R = A e^(beta/T) 'Calculate beta beta! = -(t25! ^ 2) * drdt25! / r25! 'Calculate A a! = r25! * EXP(-beta / t25!) 'Now we can calculate T given R 'beta/T = ln(R/A) 'T = beta / ln(R/A) 'Calculate T t! = beta! / LOG(r! / a!) 'Convert from deg K to deg C t! = t! - 273.15 END SUB SUB pmtcheckpar (ok$) '**************************************************************************** 'This subroutine checks that all required parameters have been assigned 'values. ' 'Output: ' ok$, "y" if parameter assignments are ok, "n" otherwise ' 'Zachary Wolf '11/18/95 '**************************************************************************** 'Default value ok$ = "n" IF logfileP$ = "" THEN PRINT "PMT: Log file not defined" EXIT SUB END IF IF datfileP$ = "" THEN PRINT "PMT: Data file not defined" EXIT SUB END IF IF pmt1hpchanP% < 0 OR pmt1hpchanP% > 9 THEN PRINT "PMT: T1 HP channel not defined" EXIT SUB END IF IF pmt2hpchanP% < 0 OR pmt2hpchanP% > 9 THEN PRINT "PMT: T2 HP channel not defined" EXIT SUB END IF IF pmt3hpchanP% < 0 OR pmt3hpchanP% > 9 THEN PRINT "PMT: T3 HP channel not defined" EXIT SUB END IF IF pmt1nameP$ = "" THEN PRINT "PMT: T1 name not defined" EXIT SUB END IF IF pmt2nameP$ = "" THEN PRINT "PMT: T2 name not defined" EXIT SUB END IF IF pmt3nameP$ = "" THEN PRINT "PMT: T3 name not defined" EXIT SUB END IF IF pmtr25cthermP! <= 0 OR pmtr25cthermP! > 60000! THEN PRINT "PMT: Thermistor resistance not defined" EXIT SUB END IF IF ABS(pmtdrdtat25cthermP!) > 700 THEN PRINT "PMT: Thermistor dR/dT not defined" EXIT SUB END IF IF pmttimbtwnmeassecP% <= 0 OR pmttimbtwnmeassecP% > 1000 THEN PRINT "PMT: Thermistor time between measurements not defined" EXIT SUB END IF 'If we made it this far, all parameters have values ok$ = "y" END SUB SUB pmtdattemp (logfile$, temp!) '**************************************************************************** 'This subroutine writes a temperature to the data file. ' 'Input: ' logfile$, the name of the log file ' temp!, the Helmholtz coil temperature ' 'Zachary Wolf '1/8/96 '**************************************************************************** 'Open the log file filenum% = FREEFILE OPEN logfile$ FOR APPEND AS filenum% 'Print the results PRINT #filenum%, "Temperature near block, T = "; temp!; " deg C" 'Close the log file CLOSE filenum% END SUB SUB pmtdattempvstim (logfile$, tim$, t1!, t2!, t3!) '**************************************************************************** 'This subroutine writes the temperature measurements to the data file. ' 'Inputs: ' logfile$, the name of the log file ' tim$, the time the measurement was taken ' t1!, temperature T1 in deg C ' t2!, temperature T2 in deg C ' t3!, temperature T3 in deg C ' 'Zachary Wolf '11/18/95 '**************************************************************************** 'Keep track of Ncall for header STATIC ncall% ncall% = ncall% + 1 'Open the log file filenum% = FREEFILE OPEN logfile$ FOR APPEND AS filenum% 'On the first call, write the header IF ncall% = 1 THEN PRINT #filenum%, PRINT #filenum%, PRINT #filenum%, " Temperature Measurements " PRINT #filenum%, PRINT #filenum%, "T1 = "; pmt1nameP$ PRINT #filenum%, "T2 = "; pmt2nameP$ PRINT #filenum%, "T3 = "; pmt3nameP$ PRINT #filenum%, PRINT #filenum%, " Time T1 T2 T3 " PRINT #filenum%, " (deg C) (deg C) (deg C)" PRINT #filenum%, "-------- ------- ------- -------" END IF 'Write the values PRINT #filenum%, USING "&"; tim$; PRINT #filenum%, USING " ####.##"; t1!; PRINT #filenum%, USING " ####.##"; t2!; PRINT #filenum%, USING " ####.##"; t3! 'Close the log file CLOSE filenum% END SUB SUB pmtdattslice (logfile$, name1$, t1!, name2$, t2!, name3$, t3!) '**************************************************************************** 'This subroutine writes temperatures to the data file. ' 'Input: ' logfile$, the name of the log file ' name1$, name of temperature measurement 1 ' t1!, temperature # 1 ' name2$, name of temperature measurement 2 ' t2!, temperature # 2 ' name3$, name of temperature measurement 3 ' t3!, temperature # 3 ' 'Zachary Wolf '1/8/96 '**************************************************************************** 'Open the log file filenum% = FREEFILE OPEN logfile$ FOR APPEND AS filenum% 'Print the results PRINT #filenum%, PRINT #filenum%, "Temperature Measurements" PRINT #filenum%, name1$; ", T = "; t1!; " deg C" PRINT #filenum%, name2$; ", T = "; t2!; " deg C" PRINT #filenum%, name3$; ", T = "; t3!; " deg C" 'Close the log file CLOSE filenum% END SUB SUB pmtempvstim '**************************************************************************** 'This subroutine controls the magnet temperature measurements as a function 'of time. ' 'Zachary Wolf '11/18/95 '**************************************************************************** 'Message PRINT PRINT "Beginning the temperature measurement cycle..." 'Get the measurement time gettime: INPUT "How long do you wish to measure the temperature? (min) ", tmin! tsec! = tmin! * 60 'Calculate the number of measurements which will be made nt% = 1 + (tsec! / pmttimbtwnmeassecP%) 'Record the temperatures at regular intervals up to tsec FOR i% = 1 TO nt% 'Record the time of the measurement tim$ = TIME$ tm! = TIMER 'TEMPERATURE MEASUREMENTS 'Measure T1 CALL pmtgettn(1, t1!) 'Measure T2 CALL pmtgettn(2, t2!) 'Measure T3 'CALL pmtgettn(3, t3!) t3! = 0! 'Write the results to the screen IF i% = 1 THEN CLS PRINT PRINT " Temperature Measurements" PRINT PRINT "T1 = "; tmagt1nameP$ PRINT "T2 = "; tmagt2nameP$ PRINT "T3 = "; tmagt3nameP$ PRINT PRINT " Time T1 T2 T3 " PRINT " (deg C) (deg C) (deg C)" PRINT "-------- ------- ------- -------" VIEW PRINT 13 TO 23 END IF PRINT USING "&"; tim$; PRINT USING " ####.##"; t1!; PRINT USING " ####.##"; t2!; PRINT USING " ####.##"; t3! 'Write the results to the data file CALL pmtdattempvstim(datfileP$, tim$, t1!, t2!, t3!) 'Wait between measurements, check for early exit WHILE TIMER - tm! < pmttimbtwnmeassecP% IF INKEY$ = CHR$(27) THEN GOTO loopexit WEND 'End of measurement loop NEXT i% loopexit: 'Reset the screen viewing area VIEW PRINT END SUB SUB pmtgettblock (temp!) '**************************************************************************** 'This subroutine gets the permanent magnet block temperature. The thermistors 'are mounted on the Helmholtz coil near the block, so this is an estimate. ' 'Output: ' temp!, block temperature in deg C ' 'Zachary Wolf '11/18/95 '**************************************************************************** 'Get the temperature of sensor #1 near the block CALL pmtgettn(1, t1!) 'Get the temperature of sensor #2 near the block CALL pmtgettn(2, t2!) 'Check IF ABS(t1! - t2!) > .5 THEN PRINT PRINT "Problem with the thermistors!!!" END IF 'Message PRINT PRINT "Temperature Measurement:" PRINT pmt1nameP$; ": T1 = "; t1!; " C" PRINT pmt2nameP$; ": T2 = "; t2!; " C" 'Check IF ABS(t1! - t2!) > .5 THEN PRINT PRINT "Problem with the thermistors!!!" PRINT "The two temperature measurements do not agree." END IF 'Return T1 as the block temperature temp! = t1! END SUB SUB pmtgettn (n%, tn!) '**************************************************************************** 'This subroutine gets a temperature. ' 'Input: ' n%, identifier giving which temperature to measure ' 'Output: ' tn!, the measured magnet temperature ' 'Zachary Wolf '1/5/95 '**************************************************************************** 'Make sure all required parameters have been defined CALL pmtcheckpar(ok$) IF ok$ <> "y" THEN tn! = 0! EXIT SUB END IF 'Determine which channel to use IF n% = 1 THEN c% = pmt1hpchanP% ELSEIF n% = 2 THEN c% = pmt2hpchanP% ELSEIF n% = 3 THEN c% = pmt3hpchanP% ELSE PRINT "PMTGETTN: Unknown temperature requested." tn! = 0! EXIT SUB END IF 'Measure the thermistor resistance CALL hp3457cr(c%, r!) 'Calculate the temperature CALL pmtcalctemp(r!, tn!) 'Estimate the temperature as a check (linear approximation) tlin! = 25! + (r! - pmtr25cthermP!) / pmtdrdtat25cthermP! 'Log the result CALL pmtlogtn(logfileP$, n%, r!, tn!, tlin!) END SUB SUB pmtgettslice (pmt1name$, t1!, pmt2name$, t2!, pmt3name$, t3!) '**************************************************************************** 'This subroutine gets the permanent magnet slice temperature. ' 'Zachary Wolf '10/24/96 '**************************************************************************** 'Get the temperature of sensor #1 CALL pmtgettn(1, t1!) 'Get the temperature of sensor #2 CALL pmtgettn(2, t2!) 'Get the temperature of sensor #3 CALL pmtgettn(3, t3!) 'Return the measurement names pmt1name$ = pmt1nameP$ pmt2name$ = pmt2nameP$ pmt3name$ = pmt3nameP$ 'Message PRINT PRINT "Temperature Measurement:" PRINT pmt1nameP$; ": T1 = "; t1!; " C" PRINT pmt2nameP$; ": T2 = "; t2!; " C" PRINT pmt2nameP$; ": T3 = "; t3!; " C" 'Check IF ABS(t2! - t3!) > .5 THEN PRINT PRINT "Problem with the thermistors!!!" PRINT "The two slice temperature measurements do not agree." END IF 'Write the temperatures to the log file CALL pmtlogtslice(logfileP$, pmt1nameP$, t1!, pmt2nameP$, t2!, pmt3nameP$, t3!) END SUB SUB pmtlogtn (logfile$, n%, r!, tn!, tlin!) '**************************************************************************** 'This subroutine writes a temperature to the log file. ' 'Input: ' logfile$, the name of the log file ' n%, identifier giving which temperature ' r!, the measured thermistor resistance ' tn!, the calculated temperature ' tlin!, estimate of the temperature using a linear approximation ' 'Zachary Wolf '1/5/95 '**************************************************************************** 'Open the log file filenum% = FREEFILE OPEN logfile$ FOR APPEND AS filenum% 'Print the results PRINT #filenum%, TIME$; " Temperature: Channel "; n% PRINT #filenum%, " Rthermistor = "; r!; " ohm" PRINT #filenum%, " T = "; tn!; " deg C" PRINT #filenum%, " Linear estimate as a check, Tlin = "; tlin!; " deg C" 'Close the log file CLOSE filenum% END SUB SUB pmtlogtslice (logfile$, name1$, t1!, name2$, t2!, name3$, t3!) '**************************************************************************** 'This subroutine writes temperatures to the data file. ' 'Input: ' logfile$, the name of the log file ' name1$, name of temperature measurement 1 ' t1!, temperature # 1 ' name2$, name of temperature measurement 2 ' t2!, temperature # 2 ' name3$, name of temperature measurement 3 ' t3!, temperature # 3 ' 'Zachary Wolf '1/8/96 '**************************************************************************** 'Open the log file filenum% = FREEFILE OPEN logfile$ FOR APPEND AS filenum% 'Log the results PRINT #filenum%, TIME$; " Temperature Measurements:" PRINT #filenum%, " "; name1$; ", T = "; t1!; " deg C" PRINT #filenum%, " "; name2$; ", T = "; t2!; " deg C" PRINT #filenum%, " "; name3$; ", T = "; t3!; " deg C" 'Close the log file CLOSE filenum% END SUB SUB pmtsetpar (logfile$, datfile$, pmt1hpchan%, pmt2hpchan%, pmt3hpchan%, pmt1name$, pmt2name$, pmt3name$, pmtr25ctherm!, pmtdrdtat25ctherm!, pmttimbtwnmeassec%) '**************************************************************************** 'This subroutine sets all required parameters for a Helmholtz coil 'measurement of a magnetic moment. ' 'Input: ' logfile$, path and name of the log file ' datfile$, path and name of the data file ' pmt1hpchan%, T1 HP channel ' pmt2hpchan%, T2 HP channel ' pmt3hpchan%, T3 HP channel ' pmt1name$, T1 description ' pmt2name$, T2 description ' pmt3name$, T3 description ' pmtr25ctherm!, thermistor resistance at 25 C ' pmtdrdtat25ctherm!, thermistor dR/dT at 25 C ' pmttimbtwnmeassec%, time between temperature measurements ' 'Zachary Wolf '11/18/95 '**************************************************************************** 'Put the parameters in the common area logfileP$ = logfile$ datfileP$ = datfile$ pmt1hpchanP% = pmt1hpchan% pmt2hpchanP% = pmt2hpchan% pmt3hpchanP% = pmt3hpchan% pmt1nameP$ = pmt1name$ pmt2nameP$ = pmt2name$ pmt3nameP$ = pmt3name$ pmtr25cthermP! = pmtr25ctherm! pmtdrdtat25cthermP! = pmtdrdtat25ctherm! pmttimbtwnmeassecP% = pmttimbtwnmeassec% END SUB