DECLARE SUB imaggeti (imag!) DECLARE SUB imaglogi (logfile$, imag!) DECLARE SUB imaglogmeas (logfile$, imag!, simag!) DECLARE SUB imaglogramp (logfile$, inom!) DECLARE SUB imagramp (inom!) DECLARE SUB imagrampfr (rr!, fr!, ifin!) DECLARE SUB hp3457cmon (c%) DECLARE SUB hp3457cv (c%, v!) DECLARE SUB dac488getv (dacv!) DECLARE SUB dac488v (v!) '**************************************************************************** 'Module IMAG 'This module contains drivers to set and measure the magnet current. ' 'Zachary Wolf '5/31/94 '**************************************************************************** 'Include the parameters used in the module REM $INCLUDE: 'param.inc' SUB imaggeti (imag!) '**************************************************************************** 'This subroutine gets the transductor output voltage. It then applies 'the calibration constant to get the magnet current. ' 'Output: ' imag!, the measured magnet current ' 'Parameters from param.inc: ' imaghpchanP%, the HP3457 channel used to measure transductor voltage ' vtransperimagP!, the conversion factor from magnet current to transductor voltage ' 'Zachary Wolf '4/21/94, 1/5/95 '**************************************************************************** 'Simplify the notation c% = imaghpchanP% vperi! = vtransperimagP! 'Measure the voltage from the transductor CALL hp3457cv(c%, v!) 'Apply the conversion factor imag! = v! / vperi! 'Log the value CALL imaglogi(logfileP$, imag!) END SUB SUB imaglogi (logfile$, imag!) '**************************************************************************** 'This subroutine writes the magnet current to the log file. ' 'Input: ' logfile$, the name of the log file ' imag!, the measured current ' 'Zachary Wolf '9/22/94 '**************************************************************************** 'Open the log file filenum% = FREEFILE OPEN logfile$ FOR APPEND AS filenum% 'Print the results PRINT #filenum%, PRINT #filenum%, TIME$; " Magnet Current, Imag = "; imag!; " A" 'Close the log file CLOSE filenum% END SUB SUB imaglogmeas (logfile$, imag!, simag!) '**************************************************************************** 'This subroutine writes the magnet current to the log file. ' 'Input: ' logfile$, the name of the log file ' imag!, the average measured current ' simag!, the rms variation of imag ' 'Zachary Wolf '1/4/95 '**************************************************************************** 'Open the log file filenum% = FREEFILE OPEN logfile$ FOR APPEND AS filenum% 'Print the results PRINT #filenum%, PRINT #filenum%, TIME$; " Magnet Current Measurement:" PRINT #filenum%, "Imag = "; imag!; " +- "; simag!; " A" 'Close the log file CLOSE filenum% END SUB SUB imaglogramp (logfile$, inom!) '**************************************************************************** 'This subroutine records a magnet current ramp to the log file. ' 'Input: ' logfile$, the name of the log file ' inom!, the desired magnet current ' 'Zachary Wolf '1/10/95 '**************************************************************************** 'Open the log file filenum% = FREEFILE OPEN logfile$ FOR APPEND AS filenum% 'Print the results PRINT #filenum%, PRINT #filenum%, TIME$; " Magnet Current Ramping to "; inom!; " A..." 'Close the log file CLOSE filenum% END SUB SUB imagmeas (imag!, simag!) '**************************************************************************** 'This subroutine performs multiple measurements and returns average values 'and rms variations. ' 'Output: ' imag!, the average of the magnet current measurements ' simag!, rms variation of imag ' 'Zachary Wolf '1/3/95 '**************************************************************************** 'Simplify the notation nm% = nmeasaveP% 'Initialize data arrays DIM imeas!(1 TO nm%) 'Loop over the measurements FOR i% = 1 TO nm% 'Measure the magnet current CALL imaggeti(imeas!(i%)) 'End the loop over the measurements NEXT i% 'Compute average imag! = 0! FOR i% = 1 TO nm% imag! = imag! + imeas!(i%) NEXT i% imag! = imag! / nm% 'Compute rms deviations simag! = 0! FOR i% = 1 TO nm% simag! = simag! + (imeas!(i%) - imag!) ^ 2 NEXT i% simag! = SQR(simag! / nm%) 'Print the results to the screen PRINT PRINT "Magnet Current:" PRINT "Imag = "; imag!; " +- "; simag!; " A" 'Write these results to the log file CALL imaglogmeas(logfileP$, imag!, simag!) END SUB SUB imagramp (inom!) '**************************************************************************** 'This subroutine supervises the ramp of the magnet current. ' 'Input: ' inom!, the desired magnet current ' 'Zachary Wolf '1/1/95 '**************************************************************************** 'Simplify the notation c% = imaghpchanP% rr! = imagramprateP! 'Make an initial measurement of the magnet current 'The value is recorded in the log file CALL imaggeti(iinit!) 'Record the ramp in the log file CALL imaglogramp(logfileP$, inom!) 'Set the DVM so the current can be monitored CALL hp3457cmon(c%) 'Ramp 'First ramp to 90% of the desired current CALL imagrampfr(rr!, .9, inom!) 'Next ramp to 99% of the desired current at 10% of the ramp rate CALL imagrampfr(.1 * rr!, .9, inom!) 'Now finish the the remaining 1% of the ramp at 1% of the initial ramp rate CALL imagrampfr(.01 * rr!, 1!, inom!) 'Let the power supply and magnet stabilize at the final current SLEEP tstableP% 'Measure the magnet current after the ramp, record the value in the log file CALL imaggeti(ifin!) END SUB SUB imagrampfr (rr!, fr!, ifin!) '**************************************************************************** 'This subroutine generates a fraction of the magnet current ramp. 'The complete ramp (fr!=1) would be from the present current to ifin!. 'This routine generates a fraction fr! of this ramp. 'The points making up the ramp are updated every 0.1 second. 'This routine can be called several times to approach the final magnet 'current at a low ramp rate. ' 'Input: ' rr!, the magnet current ramp rate ' fr!, the fraction of the ramp to be done from the present current to ifin! ' ifin!, the desired final magnet current ' 'Parameters from param.inc: ' imagpervdacP!, the magnet current per DAC volt ' 'Zachary Wolf '4/18/94 '**************************************************************************** 'Simplify the notation iperv! = imagpervdacP! 'Define a local parameter, the time between ramp steps dt! = .1 'Find the voltage the DAC is putting out CALL dac488getv(vini!) 'Find the DAC final voltage we need vfin! = ifin! / iperv! 'Compute the DAC voltage ramp rate rrdac! = rr! / iperv! 'Compute the number of ramp points to give approximately this rate nr% = (ABS(vfin! - vini!) / rrdac!) / dt! 'See if we need to ramp IF nr% = 0 THEN EXIT SUB 'Find the size of each voltage step vstep! = (vfin! - vini!) / nr% 'Compute the voltage at each step DIM vdac!(0 TO nr%) FOR i% = 0 TO nr% vdac!(i%) = vini! + vstep! * i% NEXT i% 'Have the DAC output fraction fr! of the calculated ramp FOR i% = 0 TO nr% * fr! tstep! = TIMER CALL dac488v(vdac!(i%)) WHILE TIMER - tstep! < dt! WEND NEXT i% END SUB SUB imagstandardize '**************************************************************************** 'This procedure controls the standardization of the magnet. 'Parameters come from param.inc. ' 'Zachary Wolf '4/23/94 '**************************************************************************** 'Let the operator know what is happening PRINT PRINT "Standardizing the magnet..." 'Simplify the notation ni% = nimagstandP% 'Loop over currents FOR i% = 1 TO ni% 'Message PRINT PRINT "Ramping to "; imagstandP!(i%); " Amps." 'Ramp to the desired current CALL imagramp(imagstandP!(i%)) 'End loop over currents NEXT i% END SUB