DECLARE SUB buckfileinit (project$, magtype$, magname$, run$, logfile$, strdatfile$, hardatfile$, strpltfile$, harpltfile$, ok$) DECLARE SUB filemkdir (destdir$) DECLARE SUB fileopenout (destdir$, basename$, ext$, filename$, ok$) DECLARE SUB fileplot (file$, epfile$) DECLARE SUB fileprnt (file$) DECLARE SUB fileprot (file$) DECLARE SUB buckgettestpar (projectP$, magtypeP$, magnameP$, coilnameP$, operatorP$, runP$, commentP$) DECLARE SUB gettestparama (projectP$, magtypeP$, magnameP$, coilnameP$, operatorP$, runP$, commentP$) DECLARE SUB muxsetpar (logfile$, maincoilmxchan%, dpolcoilmxchan%, qpolcoilmxchan%, dbuckmxchan%, qbuckmxchan%, dqbuckmxchan%) DECLARE SUB k7011init () DECLARE SUB k7011setpar (gpibinf%, gpiboutf%, k7011addr$) DECLARE SUB hp3457init () DECLARE SUB vtlocateindex () DECLARE SUB buckcoilexit () DECLARE SUB buckcoilinit () DECLARE SUB buckcoilmeas () DECLARE SUB buckcoilsetpar () DECLARE SUB dpolmainbl () DECLARE SUB dpolmainblvsi () DECLARE SUB dpolsetpar (logfile$, strdatfile$, strpltfile$, hardatfile$, harpltfile$, magname$, run$, strdpolcoilconst!, blnmeasave%, nimagtest%, imagtest!(), imagharflag!(), nhardisplay%) DECLARE SUB qpolmaingl () DECLARE SUB qpolmainglvsi () DECLARE SUB qpolsetpar (logfile$, strdatfile$, strpltfile$, hardatfile$, harpltfile$, magname$, run$, strqpolcoilconst!, blnmeasave%, nimagtest%, imagtest!(), imagharflag!(), nhardisplay%) DECLARE SUB spolmainsl () DECLARE SUB spolmainslvsi () DECLARE SUB spolsetpar (logfile$, strdatfile$, strpltfile$, hardatfile$, harpltfile$, magname$, run$, strspolcoilconst!, blnmeasave%, nimagtest%, imagtest!(), imagharflag!(), nhardisplay%) DECLARE SUB blsetpar (logfile$, magname$, run$, harcoilradiusm!, harcoilnturns%, blnmeasave%) DECLARE SUB vtsetpar (logfile$, vtchan$, vtgain%, vtnpulseperrev%, vtnsampperrev%, vtnrevpermeas%, vtacc!, vtvel!, vtdis!) DECLARE SUB pmtsetpar (logfile$, datfile$, pmt1hpchan%, pmt2hpchan%, pmt3hpchan%, pmt1name$, pmt2name$, pmt3name$, pmtr25ctherm!, pmtdrdtat25ctherm!, pmttimbtwnmeassec%) DECLARE SUB gpibinit (gpibind%, gpiboutd%) DECLARE SUB pdiindexrd () DECLARE SUB pdiindexst (d$) DECLARE SUB pdiinit () DECLARE SUB pdisetpar (gpibin%, gpibout%, pdi5025addr$) DECLARE SUB pdivtrotencsetup (np%) DECLARE SUB cm2100avd (a!, v!, d!) DECLARE SUB cm2100init () DECLARE SUB cm2100setpar (gpibin%, gpibout%, cm2100addr$) DECLARE SUB hp3457setpar (gpibin%, gpibout%, hp3457addr$) DECLARE SUB fileheadera (logfile$, project$, magtype$, magname$, coilname$, operator$, run$, comment$) DECLARE SUB fileinitcoil (project$, magtype$, magname$, run$, logfile$, strdatfile$, hardatfile$, strpltfile$, harpltfile$, ok$) '**************************************************************************** 'Program BUCKCOIL 'This program makes bucking coil measurements on multipole magnets. ' 'Zachary Wolf '9/12/95 '**************************************************************************** 'Common area for run time parameters COMMON SHARED /gpibio/ gpibinP%, gpiboutP% COMMON SHARED /filenames/ logfileP$, strdatfileP$, hardatfileP$, strpltfileP$, harpltfileP$ COMMON SHARED /testinfo/ projectP$, magtypeP$, magnameP$, barcodeP$, teststandP$, coilnameP$, 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 BUCKCOIL" PRINT "This program performs rotating coil measurements in dipoles," PRINT "quadrupoles, and sextupoles using a bucking coil." PRINT "These measurements give magnet strengths and harmonics." 'Get test parameters from the operator testparam: CALL buckgettestpar(projectP$, magtypeP$, magnameP$, coilnameP$, operatorP$, runP$, commentP$) 'Initialize the files for this run CALL buckfileinit(projectP$, magtypeP$, magnameP$, runP$, logfileP$, strdatfileP$, hardatfileP$, strpltfileP$, harpltfileP$, 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 'Establish communication with the GPIB CALL gpibinit(gpibinP%, gpiboutP%) 'Distribute parameters CALL buckcoilsetpar 'Initialize all systems CALL buckcoilinit 'Perform the measurements CALL buckcoilmeas 'Get ready for exit CALL buckcoilexit 'Message PRINT PRINT "The test is complete." END SUB buckcoilexit '**************************************************************************** 'This subroutine gets the program ready to exit. ' 'Zachary Wolf '8/28/95 '**************************************************************************** END SUB SUB buckcoilinit '**************************************************************************** 'This subroutine does all initialization for the bucking coil measurements. ' 'Zachary Wolf '8/17/96 '**************************************************************************** 'Write headers to the log file and data files CALL fileheadera(logfileP$, projectP$, magtypeP$, magnameP$, coilnameP$, operatorP$, runP$, commentP$) CALL fileheadera(strdatfileP$, projectP$, magtypeP$, magnameP$, coilnameP$, operatorP$, runP$, commentP$) CALL fileheadera(hardatfileP$, projectP$, magtypeP$, magnameP$, 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 pdivtrotencsetup(vtnpulseperrevP%) 'Perform an offset adjustment 'CALL pdioffset(vtchanP$, vtgainP%) 'Locate the index pulse CALL vtlocateindex 'Power System Initialization 'Write headers describing the initial iron saturation 'IF imagsaturateP! > 0 THEN ' CALL fileisat(logfileP$, imagsaturateP!) ' CALL fileisat(strdatfileP$, imagsaturateP!) ' CALL fileisat(hardatfileP$, imagsaturateP!) 'END IF 'Write headers describing the standardization 'IF nstandcycleP% > 0 THEN ' CALL fileistand(logfileP$, nstandcycleP%, imagstandP!) ' CALL fileistand(strdatfileP$, nstandcycleP%, imagstandP!) ' CALL fileistand(hardatfileP$, nstandcycleP%, imagstandP!) 'END IF 'Write headers describing the test currents 'CALL fileitest(logfileP$, nimagtestP%, imagtestP!()) 'CALL fileitest(strdatfileP$, nimagtestP%, imagtestP!()) 'CALL fileitest(hardatfileP$, nimagtestP%, imagtestP!()) 'Initialize the power sypply system 'CALL imaginit END SUB SUB buckcoilmeas '**************************************************************************** 'This subroutine controls the magnetic measurements. ' 'Zachary Wolf '9/12/95 '**************************************************************************** 'Saturate the magnet steel 'IF imagsaturateP! > 0 THEN ' CALL imagsaturate(imagsaturateP!) 'END IF 'Standardize the magnet 'IF nstandcycleP% > 0 THEN ' CALL imagstandardize(nstandcycleP%, imagstandP!) 'END IF 'Message PRINT PRINT "Beginning the magnetic field measurement cycle..." 'Perform the measurements IF measurementP$ = "BL" THEN CALL dpolmainbl ELSEIF measurementP$ = "BLVSI" THEN CALL dpolmainblvsi ELSEIF measurementP$ = "GL" THEN CALL qpolmaingl ELSEIF measurementP$ = "GLVSI" THEN CALL qpolmainglvsi ELSEIF measurementP$ = "SL" THEN CALL spolmainsl ELSEIF measurementP$ = "SLVSI" THEN CALL spolmainslvsi ELSE PRINT PRINT "Unknown measurement requested." END IF END SUB SUB buckcoilsetpar '**************************************************************************** '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 integrated voltage measurement module CALL vtsetpar(logfileP$, vtchanP$, vtgainP%, vtnpulseperrevP%, vtnsampperrevP%, vtnrevpermeasP%, vtaccP!, vtvelP!, vtdisP!) 'Set parameters for the coil multiplexer CALL muxsetpar(logfileP$, maincoilmxchanP%, dpolcoilmxchanP%, qpolcoilmxchanP%, dbuckmxchanP%, qbuckmxchanP%, dqbuckmxchanP%) 'Set parameters for the main magnet measurements modules CALL dpolsetpar(logfileP$, strdatfileP$, strpltfileP$, hardatfileP$, harpltfileP$, magnameP$, runP$, strdpolcoilconstP!, blnmeasaveP%, nimagtestP%, imagtestP!(), imagharflagP!(), nhardisplayP%) CALL qpolsetpar(logfileP$, strdatfileP$, strpltfileP$, hardatfileP$, harpltfileP$, magnameP$, runP$, strqpolcoilconstP!, blnmeasaveP%, nimagtestP%, imagtestP!(), imagharflagP!(), nhardisplayP%) CALL spolsetpar(logfileP$, strdatfileP$, strpltfileP$, hardatfileP$, harpltfileP$, magnameP$, runP$, strspolcoilconstP!, blnmeasaveP%, nimagtestP%, imagtestP!(), imagharflagP!(), nhardisplayP%) 'Set parameters for the harmonics measurements, common to all magnet types CALL blsetpar(logfileP$, magnameP$, runP$, harcoilradiusmP!, harcoilnturnsP%, blnmeasaveP%) 'Set the parameters for the temperature measurement module CALL pmtsetpar(logfileP$, strdatfileP$, pmt1hpchanP%, pmt2hpchanP%, pmt3hpchanP%, pmt1nameP$, pmt2nameP$, pmt3nameP$, pmtr25cthermP!, pmtdrdtat25cthermP!, pmttimbtwnmeassecP%) 'Power System Parameters 'Set the parameters for the DAC488 (used for PS and the Reset signal) 'CALL dac488setpar(gpibinP%, gpiboutP%, dac488addrP$) 'Set the parameters for the DAC488HR 'CALL dac488hrsetpar(gpibinP%, gpiboutP%, dac488hraddrP$) 'Set the parameters for the Kepco supply 'CALL bit488setpar(gpibinP%, gpiboutP%, bit488addrP$) 'Set the parameters for the PS123 DAC488 'CALL psdac488setpar(gpibinP%, gpiboutP%, psdac488addrP$) 'Set the parameters for the PS123 HP3457 'CALL pshp3457setpar(gpibinP%, gpiboutP%, pshp3457addrP$) 'Set the parameters for the magnet current control 'CALL imagsetpar(logfileP$, imagconfigP$, imagramprateP!, imagnmeasaveP%, imaglimitP!) 'Set the parameters for the Kepco power supply control 'CALL ibopsetpar(imaghpchanP%, vtransperimagP!, imagtstableP%) 'Set the parameters for DAC488 power supply control 'CALL idacsetpar(imagdacchanP%, imagpervdacP!, imagtstableP%, imaghpchanP%, vtransperimagP!) 'Set the parameters for DAC488HR power supply control 'CALL idachrsetpar(imagdacchanP%, imagpervdacP!, imagtstableP%, imaghpchanP%, vtransperimagP!) 'Set the parameters for the PS123 power system 'CALL ips123setpar(logfileP$, imagconfigP$, imagtstableP%) 'Set the parameters for manual power system operation 'CALL imansetpar(imaghpchanP%, vtransperimagP!) END SUB SUB buckfileinit (project$, magtype$, magname$, run$, logfile$, strdatfile$, hardatfile$, strpltfile$, harpltfile$, ok$) '**************************************************************************** 'This subroutine initializes all files. ' 'Input: ' project$, project name ' magtype$, magnet type ' magname$, magnet name ' run$, run number ' 'Output: ' logfile$, path and name of the log file ' strdatfile$, path and name of the magnet strength data file ' hardatfile$, path and name of the magnet harmonics data file ' strpltfile$, path and name of the magnet strength plot file ' harpltfile$, path and name of the magnet harmonics plot file ' ok$, ="y" if the file handling went ok, "n" otherwise ' 'Zachary Wolf '7/26/95 '**************************************************************************** '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$(magtype$, 8) CALL filemkdir(subdir$) subdir$ = "c:\magdata\" + LEFT$(project$, 8) + "\" + LEFT$(magtype$, 8) + "\" + LEFT$(magname$, 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$, "bllog", ext$, logfile$, okopen$) IF okopen$ <> "y" THEN GOTO pblmexitbln 'MAGNET STRENGTH DATA FILE 'Initialize the dat file 'Exit with ok$="n" if there is a problem CALL fileopenout(subdir$, "blstrdat", ext$, strdatfile$, okopen$) IF okopen$ <> "y" THEN GOTO pblmexitbln 'Make a .bat file to write protect the data CALL fileprot(strdatfile$) 'Make a .bat file to print the dat file CALL fileprnt(strdatfile$) 'HARMONICS DATA FILE 'Initialize the dat file 'Exit with ok$="n" if there is a problem CALL fileopenout(subdir$, "blhardat", ext$, hardatfile$, okopen$) IF okopen$ <> "y" THEN GOTO pblmexitbln 'Make a .bat file to write protect the data CALL fileprot(hardatfile$) 'Make a .bat file to print the dat file CALL fileprnt(hardatfile$) 'MAGNET STRENGTH PLOT FILE 'Initialize the plt file 'Exit with ok$="n" if there is a problem CALL fileopenout(subdir$, "blstrplt", ext$, strpltfile$, okopen$) IF okopen$ <> "y" THEN GOTO pblmexitbln 'Make a .bat file to write protect the data CALL fileprot(strpltfile$) 'HARMONICS PLOT FILE 'Initialize the plt file 'Exit with ok$="n" if there is a problem CALL fileopenout(subdir$, "blharplt", ext$, harpltfile$, okopen$) IF okopen$ <> "y" THEN GOTO pblmexitbln 'Make a .bat file to write protect the data CALL fileprot(harpltfile$) 'Make a .bat file to plot the data CALL fileplot(harpltfile$, "ephar.dat") 'If we made it this far, things are ok ok$ = "y" pblmexitbln: END SUB SUB buckgettestpar (projectP$, magtypeP$, magnameP$, coilnameP$, operatorP$, runP$, commentP$) '**************************************************************************** 'This subroutine prompts the operator for the magnet name and other 'parameters of the test. ' 'Output: ' projectP$, name of the project ' magtypeP$, magnet type ' magnameP$, name of magnet (serial #) ' coilnameP$, the ID of the measurement coil ' operatorP$, name of the operator doing the test ' runP$, run number ' commentP$, comment about the test ' 'Zachary Wolf '7/8/94, 5/8/95, 7/26/95, 7/11/96, 10/28/96 '**************************************************************************** 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$ 'Get the magnet type PRINT "What is the magnet type (dipole, quad, ...)? " PRINT "(8 characters or less): ["; magtypeP$; "]"; INPUT magtype$ magtype$ = UCASE$(magtype$) IF magtype$ <> "" THEN magtypeP$ = magtype$ 'Get the name of the magnet PRINT "What is the name (serial #) of the magnet?" PRINT "(8 characters or less): ["; magnameP$; "]"; INPUT magname$ magname$ = UCASE$(magname$) IF magname$ <> "" THEN magnameP$ = magname$ 'Get the name of the measurement coil PRINT "Enter the name of the measurement coil or system: ["; coilnameP$; "] "; INPUT "", coil$ coil$ = UCASE$(coil$) IF coil$ <> "" THEN coilnameP$ = coil$ 'Get the operator's name(s) PRINT "Enter the operator(s) name(s): ["; operatorP$; "] "; INPUT "", operator$ IF operator$ <> "" THEN operatorP$ = operator$ '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 imaggetiav (i!, si!) END SUB SUB imagramp (inom!) END SUB