DECLARE SUB hp3457cnvtrig (c%, n%, v!()) DECLARE SUB dac488do0 (d%) DECLARE SUB imagramp (inom!) DECLARE SUB imagstandardize () DECLARE SUB dac488do1 (d%) DECLARE SUB gettestparam () DECLARE SUB meashar () DECLARE SUB quadcalcxy (nh%, bl!(), sbl!(), th!(), sth!(), x!, sx!, y!, sy!) DECLARE SUB quadlogcalc (logfile$) DECLARE SUB quadlogglvsi (logfile$, rcoil!, nturns%, nrot%, nmeas%, ni%, imag!(), simag!(), gl!(), sgl!(), tf!(), stf!()) DECLARE SUB quadlogharvsi (logfile$, rcoil!, nturns%, nrot%, nmeas%, nh%, imag!, simag!, bl!(), sbl!(), th!(), sth!(), r!(), sr!()) DECLARE SUB quadlognewpage (logfile$) DECLARE SUB quadlogxy (logfile$, th!(), x!, sx!, y!, sy!) DECLARE SUB quadmeasglav (gl!, sgl!) DECLARE SUB quadmeasharav (nh%, bl!(), sbl!(), th!(), sth!(), r!(), sr!()) DECLARE SUB quadpltglvsi (logfile$, magname$, run$, ni%, imag!(), gl!(), sgl!(), tf!(), stf!()) DECLARE SUB quadpltharvsi (logfile$, magname$, run$, nh%, ni%, inom!(), rvsi!(), srvsi!()) DECLARE SUB coilplotv () DECLARE SUB imagmeas (imag!, simag!) DECLARE SUB fileinit (ok$) DECLARE SUB gpibinit () DECLARE SUB hp3457init () DECLARE SUB dac488init () DECLARE SUB dac488setupv () DECLARE SUB k7011init () '**************************************************************************** 'Program TEST 'This program is used to make the rotating coil measurements. 'It samples the voltage from the rotating 'coil and Fourier analyzes the samples to get the strengths of 'each component of the field. ' 'Zachary Wolf '1/5/95 '**************************************************************************** 'Include the constants used in the program REM $INCLUDE: 'param.inc' 'Prepare the screen CLS 'Initialize the GPIB CALL gpibinit 'Initialize the HP3457 CALL hp3457init 'Initialize the DAC 'CALL dac488init 'CALL dac488setupv 'Initialize the multiplexer CALL k7011init 'Test the reset signal 'PRINT : PRINT "Check the Reset Signal..." 'CALL dac488do1(1) 'PRINT "Wait 5 seconds" 'SLEEP 5 'CALL dac488do0(1) 'STOP 'Test the trigger 'DIM v!(0 TO 2000) 'CALL hp3457cnvtrig(1, 2001, v!()) 'STOP 'Get test parameters from the operator testparam: CALL gettestparam 'Initialize the files for this run CALL fileinit(ok$) IF ok$ <> "y" THEN PRINT PRINT "Problem initializing the data files." PRINT "Make sure you are using a new run number." GOTO testparam: END IF 'CALL imagramp(0!) 'STOP 'Standardize the magnet 'CALL imagstandardize 'Ramp to 200 A 'PRINT 'PRINT "Ramping to 200 A..." 'CALL imagramp(200!) 'Measure the harmonics CALL meashar 'Plot tachometer voltage measurements 'CALL tachplotv 'Plot coil voltage measurements 'CALL coilplotv 'Ramp to 0 A 'PRINT 'PRINT "Ramping to 0 A..." 'CALL imagramp(0!) 'Message PRINT "The test is complete." END SUB gettestparam '**************************************************************************** 'This subroutine prompts the operator for the magnet name and other 'parameters of the test. ' 'Outputs put in the /testparam/ common block: ' magnameP$, name of magnet ' operatorP$, name of the operator doing the test ' teststandP$, the teststand being used ' coilP$, the ID of the measurement coil ' runP$, run number ' commentP$, comment about the test ' 'Zachary Wolf '7/8/94 '**************************************************************************** begin: 'Get the name of the magnet PRINT PRINT "What is the name of the quadrupole being tested?" PRINT "(8 characters or less): ["; magnameP$; "]"; INPUT magname$ magname$ = UCASE$(magname$) IF magname$ <> "" THEN magnameP$ = magname$ 'Get the operator's name(s) PRINT "Enter the operator(s) name(s): ["; operatorP$; "]"; INPUT operator$ IF operator$ <> "" THEN operatorP$ = operator$ 'Get the name of the test stand 'stand: 'PRINT "Enter which test stand is being used (Q1, Q2): ["; teststandP$; "]"; 'INPUT teststand$ 'teststand$ = UCASE$(teststand$) 'IF teststand$ <> "" THEN teststandP$ = teststand$ 'IF teststandP$ <> "Q1" AND teststandP$ <> "Q2" THEN GOTO stand 'Get the name of the measurement coil 'meascoil: 'PRINT "Enter the name of the measurement coil (QC1, or QC2): ["; coilP$; "]"; 'INPUT coil$ 'coil$ = UCASE$(coil$) 'IF coil$ <> "" THEN coilP$ = coil$ 'IF coilP$ <> "QC1" AND coilP$ <> "QC2" THEN GOTO meascoil 'Get the run number PRINT "What is the run number (1, 2, 3, ...): ["; runP$; "]"; INPUT run$ IF run$ <> "" THEN runP$ = run$ 'Get a comment PRINT "Enter any comment about the run: ["; commentP$; "]"; LINE INPUT comment$ IF comment$ <> "" THEN commentP$ = comment$ 'See if everything was entered correctly PRINT INPUT "Do you wish to make any changes to the values entered (Y or N): ", yn$ IF yn$ = "Y" OR yn$ = "y" THEN GOTO begin END SUB SUB meashar '**************************************************************************** 'This subroutine controls the integrated gradient and harmonics measurements. 'Constants come from param.inc. ' 'Zachary Wolf '1/5/95 '**************************************************************************** 'Message PRINT PRINT "Beginning the magnetic field measurement cycle..." 'Simplify the notation ni% = 1 i% = 1 nh% = nhardisplayP% 'Initialize data arrays and counters ih% = 0 DIM imagvsi!(1 TO ni%) 'measured magnet current DIM simagvsi!(1 TO ni%) 'standard deviation of imag DIM glvsi!(1 TO ni%) 'integrated gradient at each current DIM sglvsi!(1 TO ni%) 'standard deviation of gl DIM tfvsi!(1 TO ni%) 'transfer function DIM stfvsi!(1 TO ni%) 'standard deviation of tf DIM bl!(1 TO nh%) 'field strength at Rcoil of the n'th harmonic DIM sbl!(1 TO nh%) 'standard deviation of Bn DIM th!(1 TO nh%) 'field angle DIM sth!(1 TO nh%) 'standard deviation of THn DIM r!(1 TO nh%) 'BLn/BL2 DIM sr!(1 TO nh%) 'standard deviation of r DIM rvsi!(1 TO nh%, 1 TO ni%) 'BLn/BL2 vs I DIM srvsi!(1 TO nh%, 1 TO ni%) 'standard deviation of BLn/BL2 vs I DIM inomhar!(1 TO ni%) 'nominal harmonics currents 'Measure the current CALL imagmeas(imag!, simag!) GOTO harmonly 'GL 'Measure the integrated gradient CALL quadmeasglav(gl!, sgl!) 'Compute the transfer function tf! = gl! / imag! stf! = tf! * SQR((sgl! / gl!) ^ 2 + (simag! / imag!) ^ 2) 'Save the results for summaries and plots imagvsi!(i%) = imag! simagvsi!(i%) = simag! glvsi(i%) = gl! sglvsi(i%) = sgl! tfvsi!(i%) = tf! stfvsi!(i%) = stf! 'GOTO glonly harmonly: 'HARMONICS 'Measure the harmonics CALL quadmeasharav(nh%, bl!(), sbl!(), th!(), sth!(), r!(), sr!()) 'Write the results to the harmonics dat file CALL quadlogharvsi(hardatP$, rcoilP!, nturnscoilP%, nrotaveP%, nmeasaveP%, nh%, imag!, simag!, bl!(), sbl!(), th!(), sth!(), r!(), sr!()) 'Save the ratios for plotting ih% = ih% + 1 inomhar!(ih%) = imagtestP!(i%) FOR j% = 1 TO nh% rvsi!(j%, ih%) = r!(j%) srvsi!(j%, ih%) = sr!(j%) NEXT j% 'Compute the location of the magnetic center CALL quadcalcxy(nh%, bl!(), sbl!(), th!(), sth!(), x!, sx!, y!, sy!) 'Record the magnetic center CALL quadlogxy(hardatP$, th!(), x!, sx!, y!, sy!) 'GL data and plot files glonly: 'Write a summary of the results to the dat file and log file CALL quadlogglvsi(gldatP$, rcoilP!, nturnscoilP%, nrotaveP%, nmeasaveP%, ni%, imagvsi!(), simagvsi!(), glvsi!(), sglvsi!(), tfvsi!(), stfvsi!()) CALL quadlogglvsi(logfileP$, rcoilP!, nturnscoilP%, nrotaveP%, nmeasaveP%, ni%, imagvsi!(), simagvsi!(), glvsi!(), sglvsi!(), tfvsi!(), stfvsi!()) 'Write the results to the plotting file CALL quadpltglvsi(glpltP$, magnameP$, runP$, ni%, imagvsi!(), glvsi!(), sglvsi!(), tfvsi!(), stfvsi!()) 'Write a summary of the calculations to the dat file CALL quadlognewpage(gldatP$) CALL quadlogcalc(gldatP$) 'Harmonics data and plot files 'Plot the results CALL quadpltharvsi(harpltP$, magnameP$, runP$, nh%, ih%, inomhar!(), rvsi!(), srvsi!()) 'Write a summary of the calculations to the dat file CALL quadlognewpage(hardatP$) CALL quadlogcalc(hardatP$) 'Log file 'Write a summary of the calculations to the log file CALL quadlognewpage(logfileP$) CALL quadlogcalc(logfileP$) END SUB