DECLARE SUB sr850automeasure () DECLARE SUB sr850getfreq (freq!) DECLARE SUB sr850getphase (phase!) DECLARE SUB sr850getvrms (vrms!) DECLARE SUB sr850init () DECLARE SUB sr850setupv1ext () DECLARE SUB sr850v1reshigh () DECLARE SUB teletracgetx (x!) DECLARE SUB teletraczerox () DECLARE SUB teletracinit () DECLARE SUB cm2100getd (d!) DECLARE SUB cm2100avd (a!, v!, d!) DECLARE SUB cm2100init () DECLARE SUB cm2100zero () DECLARE SUB mtoollogbcoil (logfile$, vli!, phli!, freq!, vm!, vp!, btrans!, th!) DECLARE SUB mtoollogbh (logfile$, b!) DECLARE SUB mtoollogbnmrh (logfile$, bhall!, bnmr!) DECLARE SUB mtoollogxymove (logfile$, x!, y!) DECLARE SUB mtoollogzmove (logfile$, z!) DECLARE SUB gp3getb (b!) DECLARE SUB gp3init () DECLARE SUB gp3setrange (r%) DECLARE SUB gp3zero () DECLARE SUB par5209automeas () DECLARE SUB par5209getfreq (freq!) DECLARE SUB par5209getrphase (phase!) DECLARE SUB par5209getvrms (vli!) DECLARE SUB par5209init () DECLARE SUB b9900getb (b!) DECLARE SUB b9900setrange (r%) DECLARE SUB b9900zero () DECLARE SUB b9900init () DECLARE SUB ls450getb (b!) DECLARE SUB ls450init () DECLARE SUB ls450setrange (r%) DECLARE SUB ls450zero () DECLARE SUB pt2025getb (b!) DECLARE SUB pt2025init () DECLARE SUB pt2025search () DECLARE SUB mc4init () DECLARE SUB mc4moveabs (s$, at!, v!, x!) DECLARE SUB mc4zero () DECLARE SUB dac488digout (lin%, sig%) DECLARE SUB dac488init () '**************************************************************************** 'Module MAPTOOLS 'This module provides useful tools for maps through a magnet. ' 'Zachary Wolf '1/22/96 '**************************************************************************** 'Common area for shared parameters COMMON SHARED /maptools/ logfileP$, measdeviceP$, hallrangeP%, coilconstantP!, movedeviceP$, acctimeP!, velcmsP!, tmovesettleP%, xaxisP$, yaxisP$, zaxisP$, posreaddeviceP$, zcurrentnominalP! SUB mtoolcheckpar (ok$) '**************************************************************************** 'This subroutine checks that all required parameters have been assigned 'values. ' 'Output: ' ok$, "y" if parameter assignments are ok, "n" otherwise ' 'Zachary Wolf '9/18/95 '**************************************************************************** 'Default value ok$ = "n" 'logfileP$ IF logfileP$ = "" THEN PRINT "MTOOL: required file not defined" EXIT SUB END IF 'measdeviceP$, hallrangeP% IF measdeviceP$ = "" OR hallrangeP% < -1 OR hallrangeP% > 10 OR coilconstantP! <= 0 THEN PRINT "MTOOL: measurement device parameter error" EXIT SUB END IF 'movedeviceP$, acctimeP!, velcmsP!, tmovesettleP% IF movedeviceP$ = "" OR acctimeP! <= 0 OR velcmsP! < 0 OR tmovesettleP% <= 0 THEN PRINT "MTOOL: motion device parameter error" EXIT SUB END IF 'xyzaxisP$ IF xaxisP$ = "" OR yaxisP$ = "" OR zaxisP$ = "" THEN PRINT "MTOOL: axis not defined" EXIT SUB END IF 'posreaddeviceP$ IF posreaddeviceP$ = "" THEN PRINT "MTOOL: position read device error" EXIT SUB END IF 'If we made it this far, all parameters have values ok$ = "y" END SUB SUB mtoolgetbcoil (btrans!, th!) '**************************************************************************** 'This subroutine measures a transverse field using a rotating coil. ' 'Output: ' btrans!, the magnitude of the transverse field (T) ' th!, the field angle wrt the index pulse (deg) ' 'Zachary Wolf '12/27/95 '**************************************************************************** 'Perform the measurements according to the device being used IF measdeviceP$ = "PAR5209" THEN CALL par5209automeas CALL par5209getrphase(phli!) CALL par5209getvrms(vli!) CALL par5209getfreq(freq!) vm! = vli! * 1.4142136# 'rms -> 0 to peak vp! = phli! + 90! 'cosine convention IF vp! > 360! THEN vp! = vp! - 360! IF vp! > 180! THEN vp! = vp! - 360! ELSEIF measdeviceP$ = "SR850" THEN CALL sr850automeasure CALL sr850getvrms(vli!) CALL sr850getphase(phli!) CALL sr850getfreq(freq!) CALL sr850v1reshigh vm! = vli! * 1.4142136# 'rms -> 0 to peak vp! = phli! - 90! 'cosine convention IF vp! < -180! THEN vp! = vp! + 360! IF vp! > 180! THEN vp! = vp! - 360! ELSE PRINT PRINT "MAPGETBCOIL: Unknown measurement device requested." EXIT SUB END IF 'Apply the coil constant to get Btransverse btrans! = vm! * coilconstantP! 'Calculate the field angle from the voltage phase th! = -vp! 'Log the measurement CALL mtoollogbcoil(logfileP$, vli!, phli!, freq!, vm!, vp!, btrans!, th!) 'Debug PRINT "Debug Bcoil, V lock-in = "; vli!; " V" PRINT "Debug Bcoil, Phase lock-in = "; phli!; " deg" PRINT "Debug Bcoil, Coil Freq = "; freq!; " Hz" PRINT "Debug Bcoil, Vm = "; vm!; " V" PRINT "Debug Bcoil, Vp = "; vp!; " deg" PRINT "Debug Bcoil, Btransverse = "; btrans! * 10000!; " G" PRINT "Debug Bcoil, Theta = "; th!; " deg" END SUB SUB mtoolgetbh (bhall!) '**************************************************************************** 'This subroutine gets the field measurement from a Hall probe. ' 'Output: ' bhall!, the field measured by the Hall probe (T) ' 'Zachary Wolf '12/23/95 '**************************************************************************** 'Perform the measurement according to the probe being used IF measdeviceP$ = "GP3" THEN CALL gp3getb(bhall!) ELSEIF measdeviceP$ = "LS450" THEN CALL ls450getb(bhall!) ELSEIF measdeviceP$ = "B9900" THEN CALL b9900getb(bhall!) ELSE PRINT PRINT "MAPGETBH: Unknown measurement device requested." EXIT SUB END IF 'Log the measurement CALL mtoollogbh(logfileP$, bhall!) END SUB SUB mtoolgetbnmrh (bhall!, bnmr!) '**************************************************************************** 'This subroutine gets field measurements from an NMR and a Hall probe. ' 'Output: ' bhall!, the field measured by the Hall probe (T) ' bnmr!, the file measured by the NMR probe (T) ' 'Zachary Wolf '12/23/95 '**************************************************************************** 'Perform the measurements according to the probes being used IF measdeviceP$ = "GP3NMR" THEN CALL gp3getb(bhall!) CALL pt2025getb(bnmr!) ELSEIF measdeviceP$ = "LS450NMR" THEN CALL ls450getb(bhall!) CALL pt2025getb(bnmr!) ELSE PRINT PRINT "MAPGETBNMRH: Unknown measurement device requested." EXIT SUB END IF 'Log the measurement CALL mtoollogbnmrh(logfileP$, bhall!, bnmr!) END SUB SUB mtoolgetz (z!) '**************************************************************************** 'This subroutine reads the z position. ' 'Input: ' z!, z position in cm ' 'Zachary Wolf '4/23/98 '**************************************************************************** 'Get the z position appropriate to the readout device 'Teletrac IF posreaddeviceP$ = "TELETRAC" THEN CALL teletracgetx(z!) 'None ELSEIF posreaddeviceP$ = "NONE" THEN z! = zcurrentnominalP! 'Unknown ELSE PRINT PRINT "MAPGETZ: Unknown position read device." EXIT SUB END IF END SUB SUB mtoolinit '**************************************************************************** 'This subroutine initializes the mapping system. ' 'Zachary Wolf '12/14/95, 1/23/96 '**************************************************************************** 'Initialize the measurement device IF measdeviceP$ = "GP3" THEN CALL gp3init ELSEIF measdeviceP$ = "LS450" THEN CALL ls450init ELSEIF measdeviceP$ = "B9900" THEN CALL b9900init ELSEIF measdeviceP$ = "GP3NMR" THEN CALL pt2025init CALL gp3init ELSEIF measdeviceP$ = "LS450NMR" THEN CALL pt2025init CALL ls450init ELSEIF measdeviceP$ = "PAR5209" THEN CALL par5209init ELSEIF measdeviceP$ = "SR850" THEN CALL sr850init CALL sr850setupv1ext CALL sr850v1reshigh ELSEIF measdeviceP$ = "NONE" THEN ' don't do anything ELSE PRINT PRINT "MAPINIT: Unknown measurement device" STOP END IF 'Initialize the motion device IF movedeviceP$ = "MANUAL" THEN 'Don't need to do anything ELSEIF movedeviceP$ = "LEADSCREW" THEN CALL dac488init ELSEIF movedeviceP$ = "KLINGER" THEN CALL mc4init ELSEIF movedeviceP$ = "LINMOTOR" THEN CALL cm2100init CALL teletracinit ELSEIF movedeviceP$ = "NONE" THEN 'don't do anything ELSE PRINT PRINT "MAPINIT: Unknown motion device" STOP END IF 'Zero any Hall probes IF measdeviceP$ = "GP3" THEN CALL gp3zero ELSEIF measdeviceP$ = "LS450" THEN CALL ls450zero ELSEIF measdeviceP$ = "B9900" THEN CALL b9900zero ELSEIF measdeviceP$ = "GP3NMR" THEN CALL gp3zero ELSEIF measdeviceP$ = "LS450NMR" THEN CALL ls450zero END IF 'Zero the motion device IF movedeviceP$ = "MANUAL" THEN 'Don't need to do anything ELSEIF movedeviceP$ = "LEADSCREW" THEN 'Don't need to do anything ELSEIF movedeviceP$ = "KLINGER" THEN PRINT PRINT "Position Zero" PRINT "Please place the stage(s) at the zero position." PRINT "The stage readouts will be zeroed." INPUT "Press ENTER when ready. ", a$ CALL mc4zero PRINT "All stages are zeroed." ELSEIF movedeviceP$ = "LINMOTOR" THEN PRINT PRINT "Position Zero" PRINT "Please place the stage(s) at the zero position." PRINT "The stage readout will be zeroed." INPUT "Press ENTER when ready. ", a$ CALL cm2100zero CALL teletraczerox PRINT "The stage is zeroed." ELSEIF movedeviceP$ = "NONE" THEN 'don't do anything ELSE PRINT PRINT "MAPINIT: Unknown motion device" STOP END IF END SUB SUB mtoollogbcoil (logfile$, vli!, phli!, freq!, vm!, vp!, btrans!, th!) '**************************************************************************** 'This subroutine records a field measurement to the log file. ' 'Input: ' logfile$, the name of the log file ' vli!, voltage from the lock-in (V) ' phli!, phase from the lock-in (deg) ' freq!, coil frequency measured by the lock-in (Hz) ' vm!, voltage magnitude zero to peak (V) ' vp!, voltage phase in v = vm cos(wt + vp) (deg) ' btrans!, magnitude of the transverse field (T) ' th!, angle of the transverse field wrt the index pulse (deg) ' 'Zachary Wolf '11/27/95 '**************************************************************************** 'Open the log file filenum% = FREEFILE OPEN logfile$ FOR APPEND AS filenum% 'Print the results PRINT #filenum%, TIME$; " Lock-In, V = "; vli!; "V, Phase = "; phli!; " deg" PRINT #filenum%, " Freq = "; freq!; " Hz" PRINT #filenum%, " Processed Voltage, |V| = "; vm!; " V, Vph = "; vp!; " deg" PRINT #filenum%, " Coil Constant = "; coilconstantP!; " T/V" PRINT #filenum%, " Btrans = "; btrans!; " T, Angle = "; th!; " deg" 'Close the log file CLOSE filenum% END SUB SUB mtoollogbh (logfile$, b!) '**************************************************************************** 'This subroutine records a field measurement to the log file. ' 'Input: ' logfile$, the name of the log file ' b!, the measured field in Tesla ' 'Zachary Wolf '11/25/95 '**************************************************************************** 'Open the log file filenum% = FREEFILE OPEN logfile$ FOR APPEND AS filenum% 'Print the results PRINT #filenum%, TIME$; " Field Measurement, B = "; b!; " T" 'Close the log file CLOSE filenum% END SUB SUB mtoollogbnmrh (logfile$, bhall!, bnmr!) '**************************************************************************** 'This subroutine records a field measurement to the log file. ' 'Input: ' logfile$, the name of the log file ' bhall!, the hall probe measurement in Tesla ' bnmr!, the nmr measurement in Tesla ' 'Zachary Wolf '11/25/95 '**************************************************************************** 'Open the log file filenum% = FREEFILE OPEN logfile$ FOR APPEND AS filenum% 'Print the results PRINT #filenum%, TIME$; " Field Measurement, Bhall = "; bhall!; " T" PRINT #filenum%, " Field Measurement, Bnmr = "; bnmr!; " T" 'Close the log file CLOSE filenum% END SUB SUB mtoollogxymove (logfile$, x!, y!) '**************************************************************************** 'This subroutine logs xy movements to the log file. ' 'Input: ' logfile$, the name of the log file ' x!, the x position the probe is moved to ' y!, the y position the probe is moved to ' 'Zachary Wolf '11/23/94 '**************************************************************************** 'Open the log file filenum% = FREEFILE OPEN logfile$ FOR APPEND AS filenum% 'Print the results PRINT #filenum%, TIME$; " Probe moved to X = "; x!; ", Y = "; y!; " cm" 'Close the log file CLOSE filenum% END SUB SUB mtoollogzmove (logfile$, z!) '**************************************************************************** 'This subroutine logs probe movements. ' 'Input: ' logfile$, the name of the log file ' z!, the z position the probe is moved to ' 'Zachary Wolf '12/23/94 '**************************************************************************** 'Open the log file filenum% = FREEFILE OPEN logfile$ FOR APPEND AS filenum% 'Print the results PRINT #filenum%, TIME$; " Probe moved to Z = "; z!; " cm" 'Close the log file CLOSE filenum% END SUB SUB mtoolmovexy (x!, y!) '**************************************************************************** 'This subroutine supervises motions in the xy plane. ' 'Input: ' x!, desired x position in cm ' y!, desired y position in cm ' 'Zachary Wolf '1/22/96 '**************************************************************************** 'Move the probes according to the motion device 'Manual IF movedeviceP$ = "MANUAL" THEN VIEW PRINT 21 TO 24 CLS PRINT PRINT "Please move to X = "; x!; " cm, Y = "; y!; " cm." INPUT "Press ENTER when ready.", a$ CLS 'KLINGER ELSEIF movedeviceP$ = "KLINGER" THEN CALL mc4moveabs(xaxisP$, acctimeP!, velcmsP!, x!) CALL mc4moveabs(yaxisP$, acctimeP!, velcmsP!, y!) SLEEP tmovesettleP% 'Unknown ELSE PRINT PRINT "MAPXYMOVE: Unknown motion device." EXIT SUB END IF 'Log the xy position CALL mtoollogxymove(logfileP$, x!, y!) END SUB SUB mtoolmovez (z!) '**************************************************************************** 'This subroutine supervises motions along the z axis. ' 'Input: ' z!, desired z position in cm ' 'Zachary Wolf '12/21/95 '**************************************************************************** 'Move appropriate to the motion device 'Manual IF movedeviceP$ = "MANUAL" THEN VIEW PRINT 21 TO 24 CLS PRINT PRINT "Please move to Z = "; z!; " cm." 'PRINT "Please move to Z = "; z! / 100!; " m." 'PRINT "Please move to Z = "; z! / 2.54; " in." INPUT "Press ENTER when ready.", a$ CLS 'Leadscrew ELSEIF movedeviceP$ = "LEADSCREW" THEN CALL dac488digout(2, 0) CALL dac488digout(2, 1) CALL dac488digout(2, 0) 'send a pulse SLEEP tmovesettleP% 'wait until the lead screw is done turning 'KLINGER ELSEIF movedeviceP$ = "KLINGER" THEN CALL mc4moveabs(zaxisP$, acctimeP!, velcmsP!, z!) SLEEP tmovesettleP% 'Linear Motor ELSEIF movedeviceP$ = "LINMOTOR" THEN nrevpercm! = .19685 '12500 steps per inch, 25000 steps per rev a! = nrevpercm! * velcmsP! / acctimeP! v! = nrevpercm! * velcmsP! ddesired! = nrevpercm! * z! CALL cm2100getd(dpresent!) d! = ddesired! - dpresent! CALL cm2100avd(a!, v!, d!) SLEEP tmovesettleP% 'Unknown ELSE PRINT PRINT "MAPZMOVE: Unknown motion device." EXIT SUB END IF 'Log the z position CALL mtoollogzmove(logfileP$, z!) 'Save the nominal position zcurrentnominalP! = z! END SUB SUB mtoolsethallrng '**************************************************************************** 'This subroutine supervises setting the Hall probe range if one is used. ' 'Zachary Wolf '1/29/95 '**************************************************************************** 'Set the Hall probe range IF measdeviceP$ = "GP3" THEN CALL gp3setrange(hallrangeP%) ELSEIF measdeviceP$ = "LS450" THEN CALL ls450setrange(hallrangeP%) ELSEIF measdeviceP$ = "B9900" THEN CALL b9900setrange(hallrangeP%) ELSEIF measdeviceP$ = "GP3NMR" THEN CALL gp3setrange(hallrangeP%) ELSEIF measdeviceP$ = "LS450NMR" THEN CALL ls450setrange(hallrangeP%) ELSE PRINT PRINT "MAPTOOLS: Unknown measurement device" STOP END IF END SUB SUB mtoolsetnmrrng '**************************************************************************** 'This subroutine supervises the NMR coarse adjust. ' 'Zachary Wolf '1/29/95 '**************************************************************************** 'Do an NMR search until it locks on the field, freeze the DAC setting PRINT PRINT "NMR Coarse Adjust" PRINT "Please place the NMR probe into the middle of the magnet." INPUT "Press ENTER when ready. ", a$ CALL pt2025search PRINT "NMR coarse adjust finished." PRINT PRINT "Now reassemble the NMR-Hall probe in preparation for the measurements." INPUT "Press ENTER when ready. ", a$ END SUB SUB mtoolsetpar (logfile$, measdevice$, hallrange%, coilconstant!, movedevice$, acctime!, velcms!, tmovesettle%, xaxis$, yaxis$, zaxis$, posreaddevice$) '**************************************************************************** 'This subroutine sets the parameters for the XY mapping module. ' 'Input: ' logfile$, name of the log file ' measdevice$, field measurement device ' hallrange%, Hall probe range to use ' coilconstant!, coil constant for a rotating coil ' movedevice$, probe motion device ' acctime!, acceleration time in sec ' velcms!, velocity in cm/sec ' tmovesettle%, time to wait after a move in sec ' xaxis$, ID of the x axis stage ' yaxis$, ID of the y axis stage ' zaxis$, ID of the z axis stage ' posreaddevice$, device to read positions ' 'Zachary Wolf '12/11/95, 1/23/96, 4/23/98 '**************************************************************************** 'Save the parameters in a common block for future use logfileP$ = logfile$ measdeviceP$ = measdevice$ hallrangeP% = hallrange% coilconstantP! = coilconstant! movedeviceP$ = movedevice$ acctimeP! = acctime! velcmsP! = velcms! tmovesettleP% = tmovesettle% xaxisP$ = xaxis$ yaxisP$ = yaxis$ zaxisP$ = zaxis$ posreaddeviceP$ = posreaddevice$ END SUB SUB mtooltrapint (ns%, x!(), y!(), iydx!) '**************************************************************************** 'This subroutine uses the trapezoidal rule to perform a numerical 'integration. ' 'Input: ' ns%, the number of steps for the integration ' x!(1 to ns%), the x values ' y!(1 to ns%), the y values ' 'Output: ' iydx!, the value of the integral ' 'Zachary Wolf '7/7/94 '**************************************************************************** 'Initialize iydx! = 0 'Sum the areas of the trapezoids to get the integral FOR i% = 2 TO ns% iydx! = iydx! + .5 * (y!(i%) + y!(i% - 1)) * (x!(i%) - x!(i% - 1)) NEXT i% END SUB