DECLARE SUB imagrampds335 (ifin!) DECLARE SUB ds335v (v!) DECLARE SUB hp3457cmon (c%) DECLARE SUB hp3457cv (c%, v!) DECLARE SUB ds335getv (dacv!) DECLARE SUB ds335hrv (v!) DECLARE SUB imaggeti (imag!) DECLARE SUB imaglogi (logfile$, imag!) DECLARE SUB imaglogiav (logfile$, imag!, simag!) DECLARE SUB imaglogramp (logfile$, inom!) DECLARE SUB imagramp (inom!) DECLARE SUB imagrampfr (rr!, fr!, ifin!) '**************************************************************************** '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' 'Required parameters 'Magnet current set and measurement parameters 'CONST imaghpchanP% = 3 'HP3457 channel for the transductor voltage 'CONST imagpervdacP! = 200 'power supply amps per DAC volts 'CONST vtransperimagP! = .005 'transductor voltage per magnet amp 'CONST imagramprateP! = 10 'power supply amperes per second during a ramp 'CONST tstableP% = 30 'the number of seconds to wait after a ramp 'CONST nmeasaveP% = 4 'the number of measurements for B average 'Make file names common to all procedures 'COMMON SHARED /filenames/ logfileP$, rawfileP$, rtdatP$, sldatP$, slpltP$, hardatP$, harpltP$ 'Define the standardization cycle 'CONST nimagstandP% = 8 'the number of standardization currents 'DIM imagstandP!(1 TO nimagstandP%) 'the current array 'imagstandP!(1) = 250! 'standardization currents 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 ' '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 imaggetiav (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 imaglogiav(logfileP$, imag!, simag!) 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 imaglogiav (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 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!) IF ABS(iinit! - inom!) < 20! THEN EXIT SUB 'Message PRINT PRINT "Ramping to "; inom!; " Amps..." 'Record the ramp in the log file CALL imaglogramp(logfileP$, inom!) 'Set the DVM so the current can be monitored CALL hp3457cmon(c%) 'Ramp 'Ramp to the desired current CALL imagrampds335(inom!) 'Measure the magnet current after the ramp, record the value in the log file CALL imaggeti(ifin!) END SUB SUB imagrampds335 (ifin!) '**************************************************************************** 'This routine has the DS335 output a voltage to give the desired current. ' 'Input: ' ifin!, the desired final magnet current ' 'Zachary Wolf '5/10/95 '**************************************************************************** 'Simplify the notation iperv! = imagpervdacP! 'Find the DAC final voltage we need vfin! = ifin! / iperv! 'Divide the ramp into 10 steps nr% = 20 'Find the voltage the DAC is putting out CALL ds335getv(vini!) '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 the calculated ramp FOR i% = 0 TO nr% CALL ds335v(vdac!(i%)) SLEEP 1 NEXT i% 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 ' '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 ds335getv(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 ds335v(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% 'Ramp to the desired current 'CALL imagramp(imagstandP!(i%)) 'End loop over currents NEXT i% END SUB