DECLARE SUB mapsetpar (datfile$, logfile$, pltfile$, slicedir$, zminlimit!, zmaxlimit!, tminlimit!, tmaxlimit!, bnmrnom!, nsen%) DECLARE SUB filemkdir (destdir$) DECLARE SUB fileopenout (destdir$, basename$, ext$, filename$, ok$) DECLARE SUB ibabinit () DECLARE SUB ibabsetpar (logfile$, imag1hpchan%, vtrans1perimag!, imag2hpchan%, vtrans2perimag!, imag3hpchan%, vtrans3perimag!, nmeasave%) DECLARE SUB tbabinit () DECLARE SUB tbabsetpar (logfile$, temp1hpchan%, temp2hpchan%) DECLARE SUB moveinit () DECLARE SUB movesetparth (logfile$, tdrivers232addr$, tdrivendegperrev!, treadndegperline!, tccwsoftlimit!, tcwsoftlimit!, tlimitdecel!, taccel!, tdecel!, tvel!) DECLARE SUB movesetparz (logfile$, zdrivers232addr$, zdrivenmeterperrev!, zreadnmeterperline!, zccwsoftlimit!, zcwsoftlimit!, zlimitdecel!, zaccel!, zdecel!, zvel!) DECLARE SUB movethuser () DECLARE SUB movezuser () DECLARE SUB gpibinit (ieeein%, ieeeout%) DECLARE SUB rs232init () DECLARE SUB rs232setpar (openpar$) DECLARE SUB hp3457init () DECLARE SUB hp3457setpar (gpibinf%, gpiboutf%, hp3457addr$) DECLARE SUB k7011init () DECLARE SUB ibabuser () DECLARE SUB babinit () DECLARE SUB babmeas () DECLARE SUB babsetpar () DECLARE SUB mapmain () DECLARE SUB k7011setpar (gpibinP%, gpiboutP%, k7011gpibaddrP$) DECLARE SUB sensetpar (logfile$, muxhpchan%, nmeasave%, nhall%, nhallparam%, hallparam!(), hallname$()) DECLARE SUB senuser () DECLARE SUB gp3init (probenum%) DECLARE SUB gp3setpar (gpibinP%, gpiboutP%, gp31addr$, gp32addr$, gp33addr$) DECLARE SUB gp3setrange (probenum%, r%) DECLARE SUB gp3user () DECLARE SUB pt2025init () DECLARE SUB pt2025setpar (gpibinf%, gpiboutf%, pt2025addr$) DECLARE SUB pt2025user () DECLARE SUB babexit () DECLARE SUB babfileheader (logfile$, project$, magnettype$, magnetname$, platepos$, operator$, run$, comment$) DECLARE SUB babfileinit (project$, magnettype$, magnetname$, run$, logfile$, datfile$, pltfile$, slicedir$, ok$) DECLARE SUB babgettestparam (projectP$, magnettypeP$, magnetnameP$, plateposP$, operatorP$, runP$, commentP$) '**************************************************************************** 'Program BABAR ' 'This program is used to perform the field map of the Babar detector 'solenoid. ' 'Zachary Wolf '10/5/97 '**************************************************************************** 'Common area for run time parameters COMMON SHARED /gpibio/ gpibinP%, gpiboutP% COMMON SHARED /filenames/ logfileP$, datfileP$, pltfileP$, slicedirP$ COMMON SHARED /testinfo/ projectP$, magnettypeP$, magnetnameP$, plateposP$, operatorP$, runP$, commentP$ 'Include the constants used in the program 'Execute assignment statements REM $INCLUDE: 'param.inc' 'Prepare the screen CLS 'Print a message about the program PRINT PRINT "Program BABAR" PRINT "This program is used to map the Babar detector solenoid." 'Get test parameters from the operator testparam: CALL babgettestparam(projectP$, magnettypeP$, magnetnameP$, plateposP$, operatorP$, runP$, commentP$) 'Open all files CALL babfileinit(projectP$, magnettypeP$, magnetnameP$, runP$, logfileP$, datfileP$, pltfileP$, slicedirP$, ok$) IF ok$ <> "y" THEN PRINT : PRINT "Problem opening the data files. Try a different run number.": PRINT GOTO testparam: END IF 'Initialize the GPIB system CALL gpibinit(gpibinP%, gpiboutP%) 'Initialize the RS232 system CALL rs232setpar(sxrs232openparP$) CALL rs232init 'Distribute parameters CALL babsetpar 'Initialize the software and hardware CALL babinit 'Perform the field map CALL babmeas 'Prepare to exit the program CALL babexit 'Message PRINT "The measurement is complete." END SUB babexit '**************************************************************************** 'This subroutine prepares for the program to exit. ' 'Zachary Wolf '9/21/95 '**************************************************************************** END SUB SUB babfileheader (logfile$, project$, magnettype$, magnetname$, platepos$, operator$, run$, comment$) '**************************************************************************** 'This subroutine writes the header of a log file. ' 'Input: ' logfile$, name, including the path, of the log file ' project$, name of the project ' magnettype$, device type ' magnetname$, name of device (serial #) ' platepos$, position of the probe plate ' operator$, name of the operator doing the test ' run$, run number ' comment$, comment about the test ' 'Zachary Wolf '10/5/97 '**************************************************************************** 'Open the log file filenum% = FREEFILE OPEN logfile$ FOR APPEND AS filenum% 'Print a general header PRINT #filenum%, "SLAC Magnetic Measurements" PRINT #filenum%, "Date: "; DATE$ PRINT #filenum%, "Time: "; TIME$ PRINT #filenum%, 'Print the sensornet test parameters to the log file PRINT #filenum%, "Project: "; project$ PRINT #filenum%, "Magnet Type: "; magnettype$ PRINT #filenum%, "Test Description: "; magnetname$ PRINT #filenum%, "Probe Plate Position: "; platepos$; " (R1 to R4 = 13.0, 20.5, 65.5, 73.0 cm)" PRINT #filenum%, "Operator: "; operator$ PRINT #filenum%, "Run Number: "; run$ PRINT #filenum%, "Comment: "; comment$ 'Close the log file CLOSE filenum% END SUB SUB babfileinit (project$, magnettype$, magnetname$, run$, logfile$, datfile$, pltfile$, slicedir$, ok$) '**************************************************************************** 'This subroutine initializes all files. ' 'Input: ' project$, project name ' magnettype$, magnet type ' magnetname$, magnet name ' run$, run number ' 'Output: ' logfile$, path and name of the log file ' datfile$, path and name of the data file ' pltfile$, path and name of the plot file ' ok$, ="y" if the file handling went ok, "n" otherwise ' 'Zachary Wolf '10/5/97 '**************************************************************************** 'Initialize ok$ = "n" 'Create the \magdata subdirectory to store the file subdir$ = "C:\MAGDATA\" + LEFT$(project$, 8) CALL filemkdir(subdir$) subdir$ = "C:\MAGDATA\" + LEFT$(project$, 8) + "\" + LEFT$(magnettype$, 8) CALL filemkdir(subdir$) subdir$ = "C:\MAGDATA\" + LEFT$(project$, 8) + "\" + LEFT$(magnettype$, 8) + "\" + LEFT$(magnetname$, 8) CALL filemkdir(subdir$) 'Form the extension for the file r% = VAL(run$) IF r% < 10 THEN ext$ = "RU" + run$ IF r% >= 10 THEN ext$ = "R" + run$ 'LOGFILE 'Initialize the log file for the run 'Exit with ok$="n" if there is a problem CALL fileopenout(subdir$, "maplog", ext$, logfile$, okopen$) IF okopen$ <> "y" THEN GOTO pblmexitbabar 'DATA FILE 'Initialize the dat file 'Exit with ok$="n" if there is a problem CALL fileopenout(subdir$, "mapdat", ext$, datfile$, okopen$) IF okopen$ <> "y" THEN GOTO pblmexitbabar 'PLOT FILE 'Initialize the plt file 'Exit with ok$="n" if there is a problem CALL fileopenout(subdir$, "mapplt", ext$, pltfile$, okopen$) IF okopen$ <> "y" THEN GOTO pblmexitbabar 'SLICE FILES slicedir$ = subdir$ 'If we made it here, then things went ok ok$ = "y" pblmexitbabar: END SUB SUB babgettestparam (projectP$, magnettypeP$, magnetnameP$, plateposP$, operatorP$, runP$, commentP$) '**************************************************************************** 'This subroutine prompts the operator for the magnet name and other 'parameters of the test. ' 'Output: ' projectP$, name of the project ' magnettypeP$, magnet type ' magnetnameP$, name of magnet (serial #) ' plateposP$, position of the probe plate ' operatorP$, name of the operator doing the test ' runP$, run number ' commentP$, comment about the test ' 'Zachary Wolf '10/5/97 '**************************************************************************** begin: 'Get the project name 'PRINT 'PRINT "What is the name of the project the magnet is for? " 'PRINT "(8 characters or less): ["; projectP$; "]"; 'INPUT project$ 'project$ = UCASE$(project$) 'IF project$ <> "" THEN projectP$ = project$ PRINT projectP$ = "BABAR" PRINT "Project: "; projectP$ 'Get the magnet type 'PRINT "What is the magnet type? " 'PRINT "(8 characters or less): ["; magnettypeP$; "]"; 'INPUT magnettype$ 'magnettype$ = UCASE$(magnettype$) 'IF magnettype$ <> "" THEN magnettypeP$ = magnettype$ magnettypeP$ = "SOLENOID" PRINT "Magnet Type: "; magnettypeP$ 'Get the name of the magnet (test description) PRINT "Enter a subdirectory name to describe this test." PRINT "(8 characters or less): ["; magnetnameP$; "]"; INPUT magnetname$ magnetname$ = UCASE$(magnetname$) IF magnetname$ <> "" THEN magnetnameP$ = magnetname$ 'Get the position of the probe plate platepos: PRINT "Enter the position of the probe plate (1, 2, 3, or 4): ["; plateposP$; "] "; LINE INPUT "", platepos$ IF platepos$ <> "" THEN plateposP$ = platepos$ IF plateposP$ <> "1" AND plateposP$ <> "2" AND plateposP$ <> "3" AND plateposP$ <> "4" THEN PRINT "The plate position must be 1, 2, 3, or 4. Try again." GOTO platepos END IF 'Get the operator's name(s) PRINT "Enter the operator(s) name(s): ["; operatorP$; "] "; LINE INPUT "", operator$ IF operator$ <> "" THEN operatorP$ = operator$ 'Get the run number runnum: PRINT "What is the run number (1, 2, 3, ...): ["; runP$; "]"; INPUT run$ IF run$ <> "" THEN runP$ = run$ IF runP$ = "" THEN PRINT "A run number must be entered. Try again." GOTO runnum END IF '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 babinit '**************************************************************************** 'This subroutine does all the initialization for the program. ' 'Zachary Wolf '10/5/97 '**************************************************************************** 'Hardware init 'Initialize the HP3457 CALL hp3457init 'Initialize the K7011 CALL k7011init 'Initialize the first Group 3 probe CALL gp3init(1) CALL gp3setrange(1, 3) 'Initialize the second Group 3 probe CALL gp3init(2) CALL gp3setrange(2, 3) 'Initialize the third Group 3 probe 'CALL gp3init(3) 'CALL gp3setrange(3, 3) 'Initialize the PT2025 CALL pt2025init 'Initialize the mapper motion system CALL moveinit 'Initialize the current measurement system CALL ibabinit 'Initialize the temperature measurement system CALL tbabinit 'Software init 'Write general headers to the log and dat files CALL babfileheader(datfileP$, projectP$, magnettypeP$, magnetnameP$, plateposP$, operatorP$, runP$, commentP$) CALL babfileheader(logfileP$, projectP$, magnettypeP$, magnetnameP$, plateposP$, operatorP$, runP$, commentP$) END SUB SUB babmeas '**************************************************************************** 'This subroutine supervises the field measurements. ' 'Zachary Wolf '10/5/97 '**************************************************************************** 'See what type of measurement is desired measurement: PRINT PRINT "What type of measurement do you wish to perform?" INPUT "(MAP, SENUSER, GP3USER, NMRUSER, IMAGUSER, MOVEZUSER, MOVEPUSER, or NONE): ", measurementP$ 'Perform the measurements IF measurementP$ = "MAP" OR measurementP$ = "map" THEN CALL mapmain ELSEIF measurementP$ = "SENUSER" OR measurementP$ = "senuser" THEN CALL senuser ELSEIF measurementP$ = "GP3USER" OR measurementP$ = "gp3user" THEN CALL gp3user ELSEIF measurementP$ = "NMRUSER" OR measurementP$ = "nmruser" THEN CALL pt2025user ELSEIF measurementP$ = "IMAGUSER" OR measurementP$ = "imaguser" THEN CALL ibabuser ELSEIF measurementP$ = "MOVEZUSER" OR measurementP$ = "movezuser" THEN CALL movezuser ELSEIF measurementP$ = "MOVEPUSER" OR measurementP$ = "movepuser" THEN CALL movethuser ELSEIF measurementP$ = "NONE" OR measurementP$ = "none" THEN EXIT SUB ELSE PRINT PRINT "Unknown measurement requested, try again..." GOTO measurement END IF 'See if another measurement is desired GOTO measurement END SUB SUB babsetpar '**************************************************************************** 'This subroutine sets all parameters for the program. 'Most parameters come from param.inc. ' 'Zachary Wolf '10/5/97 '**************************************************************************** 'Set parameters for the HP3457 CALL hp3457setpar(gpibinP%, gpiboutP%, hp3457gpibaddrP$) 'Set parameters for the K7011 CALL k7011setpar(gpibinP%, gpiboutP%, k7011gpibaddrP$) 'Set parameters for the Group 3 probes CALL gp3setpar(gpibinP%, gpiboutP%, gp31gpibaddrP$, gp32gpibaddrP$, gp33gpibaddrP$) 'Set parameters for the PT2025 CALL pt2025setpar(gpibinP%, gpiboutP%, pt2025gpibaddrP$) 'Set parameters for moving the mapper CALL movesetparz(logfileP$, zdrivers232addrP$, zdrivenmeterperrevP!, zreadnmeterperlineP!, zccwsoftlimitP!, zcwsoftlimitP!, zlimitdecelP!, zaccelP!, zdecelP!, zvelP!) CALL movesetparth(logfileP$, tdrivers232addrP$, tdrivendegperrevP!, treadndegperlineP!, tccwsoftlimitP!, tcwsoftlimitP!, tlimitdecelP!, taccelP!, tdecelP!, tvelP!) 'Set parameters for the Hall probe measurement module CALL sensetpar(logfileP$, muxhpchanP%, nmeasaveP%, nhallP%, nhallparamP%, hallparamP!(), hallnameP$()) 'Set parameters for reading the magnet current CALL ibabsetpar(logfileP$, imag1hpchanP%, vtrans1perimagP!, imag2hpchanP%, vtrans2perimagP!, imag3hpchanP%, vtrans3perimagP!, imagnmeasaveP%) 'Set parameters for the temperature sensors CALL tbabsetpar(logfileP$, temp1hpchanP%, temp2hpchanP%) 'Set parameters for the main mapping module CALL mapsetpar(datfileP$, logfileP$, pltfileP$, slicedirP$, zminlimitP!, zmaxlimitP!, tminlimitP!, tmaxlimitP!, bnmrnomP!, nhallP%) END SUB