DECLARE SUB qpoldatgl (datfile$, gl!, sgl!, th!, sth!) DECLARE SUB qpolgetglav (gl!, sgl!, th!, sth!) DECLARE SUB testexit () DECLARE SUB testinit () DECLARE SUB testsetpar () DECLARE SUB muxopenall () DECLARE SUB muxsetchan (chan$) DECLARE SUB muxsetpar (logfile$, maincoilmxchan%, dpolcoilmxchan%, qpolcoilmxchan%, dbuckmxchan%, qbuckmxchan%, dqbuckmxchan%) DECLARE SUB vtautogain () DECLARE SUB vtlocateindex () DECLARE SUB vtoffsetcorr (n%, vt!(), vtn!) DECLARE SUB vtsetpar (logfile$, vtchan$, vtgain%, vtnpulseperrev%, vtnsampperrev%, vtnrevpermeas%, vtacc!, vtvel!, vtdis!) DECLARE SUB dpolsetpar (logfile$, strdatfile$, strpltfile$, hardatfile$, harpltfile$, magname$, run$, strdpolcoilconst!, blnmeasave%, nimagtest%, imagtest!(), imagharflag!(), nhardisplay%) DECLARE SUB qpolsetpar (logfile$, strdatfile$, strpltfile$, hardatfile$, harpltfile$, magname$, run$, strqpolcoilconst!, blnmeasave%, nimagtest%, imagtest!(), imagharflag!(), nhardisplay%) DECLARE SUB blcalcratio (nh%, bln!(), sbln!(), nmain%, rn!(), srn!()) DECLARE SUB bldatblhar (datfile$, nmain%, nh%, bln!(), sbln!(), thn!(), sthn!(), r!(), sr!()) DECLARE SUB blgetblnav (coilconfig$, nh%, bln!(), sbln!(), thn!(), sthn!()) DECLARE SUB bllogcalc (logfile$) DECLARE SUB blsetpar (logfile$, magname$, run$, harcoilradiusm!, harcoilnturns%, blnmeasave%) DECLARE SUB pmtsetpar (logfile$, datfile$, pmt1hpchan%, pmt2hpchan%, pmt3hpchan%, pmt1name$, pmt2name$, pmt3name$, pmtr25ctherm!, pmtdrdtat25ctherm!, pmttimbtwnmeassec%) DECLARE SUB gpibinit (ieeein%, ieeeout%) DECLARE SUB k7011init () DECLARE SUB k7011setpar (gpibinf%, gpiboutf%, k7011addr$) DECLARE SUB pdierr (er%) DECLARE SUB pdiinit () DECLARE SUB pdisetpar (gpibinf%, gpiboutf%, pdi5025addr$) DECLARE SUB pdivtrotencrd (c$, n%, vt!(), vtn!) DECLARE SUB pdivtrotencsetup (np%) DECLARE SUB pdivtrotencst (c$, g%, d$, np%, ns%, n%) DECLARE SUB cm2100avd (a!, v!, d!) DECLARE SUB cm2100init () DECLARE SUB cm2100setpar (gpibinf%, gpiboutf%, cm2100addr$) DECLARE SUB hp3457init () DECLARE SUB hp3457setpar (gpibinf%, gpiboutf%, hp3457addr$) DECLARE SUB spcalcfft (ns%, samp!(), fftm!(), fftp!()) DECLARE SUB spcalchar (ns%, fftm!(), fftp!(), nfun%, nh%, harm!(), harp!()) DECLARE SUB spplotfft (ns%, fftm!(), fftp!()) DECLARE SUB spplothar (nh%, harm!(), harp!()) DECLARE SUB spplotsamp (ns%, samp!()) '**************************************************************************** 'Program TEST 'This program makes measurements on permanent magnets in a Helmholtz coil. ' 'Zachary Wolf '9/12/95 '**************************************************************************** 'Common blocks for run time parameters COMMON SHARED /filenames/ logfileP$, datfileP$, pltfileP$ COMMON SHARED /testinfo/ projectP$, magtypeP$, magnameP$, barcodeP$, teststandP$, operatorP$, runP$, commentP$ COMMON SHARED /gpibio/ gpibinP%, gpiboutP% 'Include parameter file to assign parameters REM $INCLUDE: 'param.inc' 'Print a message about the program CLS PRINT PRINT "*************************Program HH*****************************" PRINT "This program measures the magnetic moment of a permanent magnet" PRINT "using a Helmholtz coil." 'Initialize the log file for the run filenum% = FREEFILE logfileP$ = "logfile.dat" OPEN logfileP$ FOR OUTPUT AS filenum% CLOSE filenum% 'Initialize the dat file for the run filenum% = FREEFILE datfileP$ = "datfile.dat" OPEN datfileP$ FOR OUTPUT AS filenum% CLOSE filenum% 'Initialize the plt file for the run filenum% = FREEFILE pltfileP$ = "pltfile.dat" OPEN pltfileP$ FOR OUTPUT AS filenum% CLOSE filenum% 'Establish communication with the GPIB CALL gpibinit(gpibinP%, gpiboutP%) 'Distribute parameters CALL testsetpar 'Initialize all systems CALL testinit 'Perform a move 'CALL cm2100avdst(vtaccP!, vtvelP!, vtdisP!) 'PRINT "Started move..." 'CALL cm2100avdend(vtdisP!) 'STOP 'Test a multiplexer channel 'CALL muxsetchan("dqbuck") 'STOP 'Do the PDI test 'CALL testpdi 'STOP 'Connect the dipole coil to the integrator 'CALL muxsetchan("dipole") 'Set the integrator gain 'CALL vtautogain 'Get the integrated dipole field strength 'CALL dpolgetblav(bl!, sbl!, th!, sth!) 'Write the strength measurement to the data file 'CALL dpoldatbl(datfileP$, bl!, sbl!, th!, sth!) 'STOP 'Connect the quadrupole coil to the integrator CALL muxsetchan("quadrupole") 'Set the integrator gain CALL vtautogain 'Get the integrated gradient CALL qpolgetglav(gl!, sgl!, th!, sth!) 'Write the strength measurement to the data file CALL qpoldatgl(datfileP$, gl!, sgl!, th!, sth!) STOP 'Connect the main coil to the integrator (can connect others also) coilconfig$ = "dqbuck" CALL muxsetchan(coilconfig$) 'Set the integrator gain CALL vtautogain 'Initialize data arrays nh% = nhardisplayP% DIM bln!(1 TO nh%) 'field strength at Rcoil of the n'th harmonic DIM sbln!(1 TO nh%) 'standard deviation of Bn DIM thn!(1 TO nh%) 'field angle DIM sthn!(1 TO nh%) 'standard deviation of THn DIM rn!(1 TO nh%) 'BLn/BL1 DIM srn!(1 TO nh%) 'standard deviation of rn 'Get the field harmonics at the coil radius CALL blgetblnav(coilconfig$, nh%, bln!(), sbln!(), thn!(), sthn!()) 'Compute the strength ratios of the harmonics CALL blcalcratio(nh%, bln!(), sbln!(), nmain%, rn!(), srn!()) 'Write the harmonics to the data file CALL bldatblhar(datfileP$, nmain%, nh%, bln!(), sbln!(), thn!(), sthn!(), rn!(), srn!()) 'Record how the calculations were done CALL bllogcalc(datfileP$) STOP 'Message 'PRINT 'PRINT "Measuring VT fundamental..." 'Get the integrated voltage harmonic at the fundamental frequency 'rotdir$ = "+" 'CALL vtgetvthar1(rotdir$, vtmag!, vtphase!) 'STOP 'Measure temperatures 'CALL pmtgettn(1, t1!) 'CALL pmtgettn(2, t2!) 'PRINT "T1 = "; t1!; ", T2 = "; t2! 'CALL pmtgettblock(temp!) 'STOP 'Get ready for exit CALL testexit 'Message PRINT PRINT "The test is complete." END SUB imaggetiav (imag!, simag!) END SUB SUB imagramp (imagtest!) END SUB SUB testexit '**************************************************************************** 'This subroutine gets the program ready to exit. ' 'Zachary Wolf '8/28/95 '**************************************************************************** END SUB SUB testinit '**************************************************************************** 'This subroutine does all initialization for the Helmholtz coil measurements. ' 'Zachary Wolf '1/8/96 '**************************************************************************** 'Write headers to the log file and data file 'CALL fileheader(logfileP$, projectP$, magtypeP$, magnameP$, barcodeP$, teststandP$, coilnameP$, operatorP$, runP$, commentP$) 'CALL fileheader(datfileP$, projectP$, magtypeP$, magnameP$, barcodeP$, teststandP$, coilnameP$, operatorP$, runP$, commentP$) 'Initialize the K7011 CALL k7011init 'Initialize the PDI5025 CALL pdiinit 'Initialize the CM2100 CALL cm2100init 'Initialize the HP3457 CALL hp3457init 'Set the PDI5025 for rotary encoder triggering CALL pdierr(e%) CALL pdivtrotencsetup(vtnpulseperrevP%) CALL pdierr(e%) 'Locate the index pulse CALL muxopenall CALL vtlocateindex END SUB SUB testoffset 'Use the encoder for triggers PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";TRS,E,1024" 'Select the integrator channel PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";CHA,A" 'Set the gain PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";SGA,10" 'Message PRINT PRINT "PDI-5025 Offset Adjustment" 'Put the PDI-5025 in offset adjustment mode PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";ADJ,A,1:" 'Get the register 1 status bits in a string PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";STB,1" PRINT #gpiboutP%, "ENTER " + pdi5025addrP$ LINE INPUT #gpibinP%, statbits$ PRINT PRINT "After begin offset adjust, register 1 = "; statbits$ 'Have the user adjust the offset PRINT PRINT "Adjust the offset screw on channel A" PRINT "until the integrator value is 000." INPUT "Press ENTER when finished.", a$ 'End offset adjustment mode PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";ADJ,A,0" 'Get the register 1 status bits in a string PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";STB,1" PRINT #gpiboutP%, "ENTER " + pdi5025addrP$ LINE INPUT #gpibinP%, statbits$ PRINT PRINT "After end offset adjust, register 1 = "; statbits$ END SUB SUB testpdi 'Message PRINT PRINT "Beginning PDI test..." 'Test the motor 'a! = .5 'v! = 1! 'd! = 2! 'CALL cm2100avd(a!, v!, d!) 'STOP 'Make a measurement using the timer 'c$ = "A" 'g% = 10 'n% = 512 't! = .02 'DIM vt!(0 TO n% - 1) 'CALL pdivttimer(c$, g%, n%, t!, vt!()) 'CALL spplotsamp(n%, vt!()) 'DIM fftm(0 TO n% / 2) 'DIM fftp(0 TO n% / 2) 'CALL spcalcfft(n%, vt!(), fftm!(), fftp!()) 'CALL spplotfft(n%, fftm!(), fftp!()) 'STOP 'Perform an offset adjustment of the integrator 'PRINT 'PRINT "Offset Adjustment" 'c$ = "A" 'g% = 10 'CALL pdioffset(c$, g%) 'CALL pdierr(e%) 'Do a measurement using the rotary encoder for triggering 'Assign Measurement Parameters c$ = "A" g% = 20 d$ = "+" notd$ = "-" np% = 1024 ns% = 64 n% = 512 a! = 1! v! = 1! d! = 10! DIM vt!(0 TO n% - 1) 'Initialize the PDI5025 for rotary encoder triggering 'CALL pdierr(e%) 'CALL pdivtrotencsetup(np%) 'CALL pdierr(e%) 'Locate the index pulse 'PRINT 'PRINT "-------------Index " + d$ 'CALL pdiindexst(d$) 'CALL cm2100avd(a!, v!, -2!) 'CALL pdiindexrd 'CALL pdierr(e%) 'Perform a measurement with d$ rotation PRINT PRINT "------------Measurement " + d$ CALL pdivtrotencst(c$, g%, d$, np%, ns%, n%) CALL cm2100avd(a!, v!, -d!) CALL pdivtrotencrd(c$, n%, vt!(), vtn!) 'CALL vtcheckdata(n%, vt!(), ok$) CALL vtoffsetcorr(n%, vt!(), vtn!) GOTO plot 'Locate the index pulse with notd$ rotation 'PRINT 'PRINT "-------------Index " + notd$ 'CALL pdiindexst(notd$) 'CALL cm2100avd(a!, v!, -2!) 'CALL pdiindexrd 'CALL pdierr(e%) 'Perform a measurement with notd$ rotation PRINT PRINT "------------Measurement " + notd$ CALL pdivtrotencst(c$, g%, notd$, np%, ns%, n%) CALL cm2100avd(a!, v!, -d!) CALL pdivtrotencrd(c$, n%, vt!(), vtn!) 'CALL vtcheckdata(n%, vt!(), ok$) 'Plot the samples, FFT, and the harmonics plot: CALL spplotsamp(n%, vt!()) DIM fftm(0 TO n% / 2) DIM fftp(0 TO n% / 2) CALL spcalcfft(n%, vt!(), fftm!(), fftp!()) CALL spplotfft(n%, fftm!(), fftp!()) nh% = 16 nfun% = n% / ns% DIM harm!(1 TO nh%) DIM harp(1 TO nh%) CALL spcalchar(n%, fftm!(), fftp!(), nfun%, nh%, harm!(), harp!()) CALL spplothar(n%, harm!(), harp!()) END SUB SUB testsetpar '**************************************************************************** 'This subroutine distributes required test parameters. ' 'Zachary Wolf '8/28/95, 1/8/96 '**************************************************************************** 'Set parameters for the stepping motor CALL cm2100setpar(gpibinP%, gpiboutP%, cm2100addrP$) 'Set parameters for the multiplexer CALL k7011setpar(gpibinP%, gpiboutP%, k7011addrP$) 'Set parameters for the integrator CALL pdisetpar(gpibinP%, gpiboutP%, pdi5025addrP$) 'Set parameters for the HP3457 CALL hp3457setpar(gpibinP%, gpiboutP%, hp3457addrP$) 'Set parameters for the coil multiplexer module CALL muxsetpar(logfileP$, maincoilmxchanP%, dpolcoilmxchanP%, qpolcoilmxchanP%, dbuckmxchanP%, qbuckmxchanP%, dqbuckmxchanP%) 'Set parameters for the integrated voltage measurement module CALL vtsetpar(logfileP$, vtchanP$, vtgainP%, vtnpulseperrevP%, vtnsampperrevP%, vtnrevpermeasP%, vtaccP!, vtvelP!, vtdisP!) 'Set parameters for the dipole measurement module CALL dpolsetpar(logfileP$, datfileP$, pltfileP$, datfileP$, pltfileP$, "test", "0", strdpolcoilconstP!, blnmeasaveP%, nimagtestP%, imagtestP!(), imagharflagP!(), nhardisplayP%) 'Set parameters for the quadrupole measurement module CALL qpolsetpar(logfileP$, datfileP$, pltfileP$, datfileP$, pltfileP$, "test", "0", strqpolcoilconstP!, blnmeasaveP%, nimagtestP%, imagtestP!(), imagharflagP!(), nhardisplayP%) 'Set parameters for the harmonics module CALL blsetpar(logfileP$, "test", "0", harcoilradiusmP!, harcoilnturnsP%, blnmeasaveP%) 'Set the parameters for the temperature measurement module CALL pmtsetpar(logfileP$, datfileP$, pmt1hpchanP%, pmt2hpchanP%, pmt3hpchanP%, pmt1nameP$, pmt2nameP$, pmt3nameP$, pmtr25cthermP!, pmtdrdtat25cthermP!, pmttimbtwnmeassecP%) END SUB