DECLARE SUB lgpsoff () DECLARE SUB lgpson () DECLARE SUB vaximagmeas (imag!) DECLARE SUB vaximagramp (imag!) DECLARE SUB vaxstandardize () DECLARE SUB imangeti (imag!) DECLARE SUB imaninit () DECLARE SUB imanmonitor () DECLARE SUB imanramp (inom!) DECLARE SUB dac488init () DECLARE SUB dac488hrinit () DECLARE SUB idacgeti (imag!) DECLARE SUB idacinit () DECLARE SUB idacmonitor () DECLARE SUB idacramp (rr!, inom!) DECLARE SUB idachrgeti (imag!) DECLARE SUB idachrinit () DECLARE SUB idachrmonitor () DECLARE SUB idachrramp (rr!, inom!) DECLARE SUB imaglogmeas (logfile$) DECLARE SUB bit488init () DECLARE SUB psdac488init () DECLARE SUB pshp3457init () DECLARE SUB hp3457init () DECLARE SUB imagcheckpar (ok$) DECLARE SUB imaggeti (imag!) DECLARE SUB imaggetiav (imag!, simag!) DECLARE SUB imaglogi (logfile$, imag!) DECLARE SUB imaglogiav (logfile$, imag!, simag!) DECLARE SUB imaglogramp (logfile$, inom!) DECLARE SUB imagmonitor () DECLARE SUB imagramp (inom!) DECLARE SUB imagstandardize (nstand%, istand!) DECLARE SUB ibopgeti (imag!) DECLARE SUB ibopinit () DECLARE SUB ibopmonitor () DECLARE SUB ibopramp (rr!, inom!) DECLARE SUB ips123geti (imag!) DECLARE SUB ips123init () DECLARE SUB ips123monitor () DECLARE SUB ips123ramp (rr!, inom!) '**************************************************************************** 'Module IMAG 'This module contains drivers to set and measure the magnet current. ' 'Zachary Wolf '8/30/95 '**************************************************************************** 'Common block for the parameters required by this module COMMON SHARED /imag/ logfileP$, imagconfigP$, imagramprateP!, imagnmeasaveP%, imaglimitP! SUB imagcheckpar (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 "IMAG: logfile not defined" EXIT SUB END IF 'imagconfigP$ IF imagconfigP$ = "" THEN PRINT "IMAG: configuration not defined" EXIT SUB END IF 'imagramprateP! IF imagramprateP! <= 0! OR imagramprateP! > 100! THEN PRINT "IMAG: ramp rate has improper value" EXIT SUB END IF 'imagnmeasaveP% IF imagnmeasaveP% <= 0 OR imagnmeasaveP% > 20 THEN PRINT "IMAG: imagnmeasave has improper value" EXIT SUB END IF 'imaglimit IF imaglimitP! <= 0! THEN PRINT "IMAG: imaglimit has improper value" EXIT SUB END IF 'If we made it this far, all parameters have values ok$ = "y" END SUB SUB imagexit '**************************************************************************** 'This subroutine is used to power down and exit the magnet current system. ' 'Zachary Wolf '9/1/95 '**************************************************************************** 'Make sure all parameters have been defined with acceptable values CALL imagcheckpar(ok$) IF ok$ <> "y" THEN EXIT SUB 'Ramp to 0 A CALL imagramp(0!) 'VAX IF imagconfigP$ = "IVAX" THEN CALL lgpsoff END IF END SUB SUB imaggeti (imag!) '**************************************************************************** 'This subroutine gets the magnet current. ' 'Output: ' imag!, the measured magnet current ' 'Zachary Wolf '7/21/95 '**************************************************************************** 'Make sure all parameters have been defined with acceptable values CALL imagcheckpar(ok$) IF ok$ <> "y" THEN imag! = 0! EXIT SUB END IF 'Power supplies 1, 2, 3 IF imagconfigP$ = "1" OR imagconfigP$ = "2" OR imagconfigP$ = "3" OR imagconfigP$ = "12S" OR imagconfigP$ = "12P" OR imagconfigP$ = "123P" THEN CALL ips123geti(imag!) 'Kepco ELSEIF imagconfigP$ = "KEPCO" THEN CALL ibopgeti(imag!) 'DAC488 ELSEIF imagconfigP$ = "IDAC" THEN CALL idacgeti(imag!) 'DAC488HR ELSEIF imagconfigP$ = "IDACHR" THEN CALL idachrgeti(imag!) 'VAX ELSEIF imagconfigP$ = "IVAX" THEN CALL vaximagmeas(imag!) 'Manual ELSEIF imagconfigP$ = "IMAN" THEN CALL imangeti(imag!) 'NONE ELSEIF imagconfigP$ = "NONE" THEN imag! = 0! EXIT SUB 'Otherwise, unknown power supply configuration ELSE PRINT "IMAGGETI: unknown power supply configuration." imag! = 0! EXIT SUB END IF 'Log the value CALL imaglogi(logfileP$, imag!) END SUB SUB imaggetiav (imag!, simag!) '**************************************************************************** 'This subroutine performs multiple measurements and returns average values 'and rms variations. ' 'Output: ' imag!, the average of the magnet current measurements ' simag!, rms variation of imag ' 'Zachary Wolf '1/3/95, 7/21/95 '**************************************************************************** 'Make sure all parameters have been defined with acceptable values CALL imagcheckpar(ok$) IF ok$ <> "y" THEN imag! = 0! simag = 0! EXIT SUB END IF 'Make sure a power supply is being used IF imagconfigP$ = "NONE" THEN imag! = 0! simag! = 0! EXIT SUB END IF 'Log that a measurement is being made CALL imaglogmeas(logfileP$) 'Simplify the notation nm% = imagnmeasaveP% 'Initialize data arrays DIM imeas!(1 TO nm%) 'Loop over the measurements FOR i% = 1 TO nm% 'Measure the magnet current CALL imaggeti(imeas!(i%)) 'End the loop over the measurements NEXT i% 'Compute average imag! = 0! FOR i% = 1 TO nm% imag! = imag! + imeas!(i%) NEXT i% imag! = imag! / nm% 'Compute rms deviations simag! = 0! FOR i% = 1 TO nm% simag! = simag! + (imeas!(i%) - imag!) ^ 2 NEXT i% simag! = SQR(simag! / nm%) 'Print the results to the screen PRINT PRINT "Magnet Current:" PRINT "Imag = "; imag!; " +- "; simag!; " A" 'Write these results to the log file CALL imaglogiav(logfileP$, imag!, simag!) END SUB SUB imaginit '**************************************************************************** 'This subroutine is used to initialize the magnet current system. ' 'Zachary Wolf '9/1/95 '**************************************************************************** 'Make sure all parameters for this module have been defined with acceptable values CALL imagcheckpar(ok$) IF ok$ <> "y" THEN EXIT SUB 'Power supplies 1, 2, 3 IF imagconfigP$ = "1" OR imagconfigP$ = "2" OR imagconfigP$ = "3" OR imagconfigP$ = "12S" OR imagconfigP$ = "12P" OR imagconfigP$ = "123P" THEN CALL pshp3457init CALL psdac488init CALL ips123init 'Kepco ELSEIF imagconfigP$ = "KEPCO" THEN CALL hp3457init CALL bit488init CALL ibopinit 'DAC488 ELSEIF imagconfigP$ = "IDAC" THEN CALL hp3457init CALL dac488init CALL idacinit 'DAC488HR ELSEIF imagconfigP$ = "IDACHR" THEN CALL hp3457init CALL dac488hrinit CALL idachrinit 'VAX ELSEIF imagconfigP$ = "IVAX" THEN CALL lgpson 'Manual ELSEIF imagconfigP$ = "IMAN" THEN CALL imaninit 'NONE ELSEIF imagconfigP$ = "NONE" THEN 'Do nothing 'Otherwise, unknown power supply configuration ELSE PRINT "IMAGINIT: unknown power supply configuration." EXIT SUB END IF END SUB SUB imaglogi (logfile$, imag!) '**************************************************************************** 'This subroutine writes the magnet current to the log file. ' 'Input: ' logfile$, the name of the log file ' imag!, the measured current ' 'Zachary Wolf '9/22/94 '**************************************************************************** 'Open the log file filenum% = FREEFILE OPEN logfile$ FOR APPEND AS filenum% 'Print the results PRINT #filenum%, TIME$; " Magnet Current, Imag = "; imag!; " A" 'Close the log file CLOSE filenum% END SUB SUB imaglogiav (logfile$, imag!, simag!) '**************************************************************************** 'This subroutine writes the magnet current to the log file. ' 'Input: ' logfile$, the name of the log file ' imag!, the average measured current ' simag!, the rms variation of imag ' 'Zachary Wolf '1/4/95 '**************************************************************************** 'Open the log file filenum% = FREEFILE OPEN logfile$ FOR APPEND AS filenum% 'Print the results PRINT #filenum%, TIME$; " Magnet Current Measurement:" PRINT #filenum%, " Imag = "; imag!; " +- "; simag!; " A" 'Close the log file CLOSE filenum% END SUB SUB imaglogmeas (logfile$) '**************************************************************************** 'This subroutine records a magnet current measurement to the log file. ' 'Input: ' logfile$, the name of the log file ' 'Zachary Wolf '11/25/95 '**************************************************************************** 'Open the log file filenum% = FREEFILE OPEN logfile$ FOR APPEND AS filenum% 'Print the results PRINT #filenum%, PRINT #filenum%, TIME$; " Magnet Current Measurement..." 'Close the log file CLOSE filenum% END SUB SUB imaglogramp (logfile$, inom!) '**************************************************************************** 'This subroutine records a magnet current ramp to the log file. ' 'Input: ' logfile$, the name of the log file ' inom!, the desired magnet current ' 'Zachary Wolf '1/10/95 '**************************************************************************** 'Open the log file filenum% = FREEFILE OPEN logfile$ FOR APPEND AS filenum% 'Print the results PRINT #filenum%, PRINT #filenum%, TIME$; " Magnet Current Ramping to "; inom!; " A..." 'Close the log file CLOSE filenum% END SUB SUB imagmonitor '**************************************************************************** 'This subroutine lets the user monitor the magnet current. ' 'Zachary Wolf '9/1/95 '**************************************************************************** 'Make sure all parameters have been defined with acceptable values CALL imagcheckpar(ok$) IF ok$ <> "y" THEN EXIT SUB 'Power supplies 1, 2, 3 IF imagconfigP$ = "1" OR imagconfigP$ = "2" OR imagconfigP$ = "3" OR imagconfigP$ = "12S" OR imagconfigP$ = "12P" OR imagconfigP$ = "123P" THEN CALL ips123monitor 'Kepco ELSEIF imagconfigP$ = "KEPCO" THEN CALL ibopmonitor 'DAC488 ELSEIF imagconfigP$ = "IDAC" THEN CALL idacmonitor 'DAC488HR ELSEIF imagconfigP$ = "IDACHR" THEN CALL idachrmonitor 'VAX ELSEIF imagconfigP$ = "IVAX" THEN 'no monitoring available through PC 'Manual ELSEIF imagconfigP$ = "IMAN" THEN CALL imanmonitor 'NONE ELSEIF imagconfigP$ = "NONE" THEN 'Do nothing 'Otherwise, unknown power supply configuration ELSE PRINT "IMAGMONITOR: unknown power supply configuration." imag! = 0! EXIT SUB END IF END SUB SUB imagoperate '**************************************************************************** 'This subroutine lets the operator operate the power supplies using 'a menu. ' 'Zachary Wolf '7/27/95 '**************************************************************************** 'Header PRINT PRINT "****************************" PRINT "* OPERATE THE POWER SUPPLY *" PRINT "****************************" 'List the options for the ramp gettask: PRINT PRINT "Do you wish to:" PRINT " [S]tandardize the magnet." PRINT " [R]amp the magnet current." PRINT " [C]hange the polarity." PRINT " [M]easure the magnet current." PRINT " [E]nd the program." INPUT "Please enter your choice: ", task$ task$ = UCASE$(LEFT$(task$, 1)) IF task$ <> "S" AND task$ <> "R" AND task$ <> "C" AND task$ <> "M" AND task$ <> "E" THEN PRINT "Not a valid entry." GOTO gettask END IF 'Standardize IF task$ = "S" THEN getstand: INPUT "What current do you wish to standardize to? ", istand$ INPUT "How many standardization cycles? ", nstand$ IF istand$ = "" THEN GOTO gettask IF nstand$ = "" THEN GOTO gettask istand! = VAL(istand$) nstand% = VAL(nstand$) PRINT "Confirm "; istand!; " A and "; nstand%; " cycles? [y/n]"; INPUT yn$ IF UCASE$(LEFT$(yn$, 1)) <> "Y" GOTO getstand CALL imagstandardize(nstand%, istand!) END IF 'Ramp IF task$ = "R" THEN getval: INPUT "What current do you wish to ramp to? ", ival$ IF ival$ = "" THEN GOTO gettask ival! = VAL(ival$) PRINT "Confirm "; ival!; " A? [y/n]"; INPUT yn$ IF UCASE$(LEFT$(yn$, 1)) <> "Y" GOTO getval CALL imagramp(ival!) END IF 'Change polarity IF task$ = "C" THEN switch: PRINT "Confirm polarity reversal? [y/n]"; INPUT yn$ IF UCASE$(LEFT$(yn$, 1)) <> "Y" GOTO gettask CALL imagramp(0!) PRINT PRINT "Press the DC OFF button." PRINT "Change the NORM/REV switch." PRINT "Press the DC ON button." INPUT "Press enter when ready. ", a$ END IF 'Measure the magnet current IF task$ = "M" THEN CALL imaggetiav(imag!, simag!) END IF 'End IF task$ = "E" THEN GOTO done 'Leave the DVM monitoring the transductor CALL imagmonitor 'Get the next task GOTO gettask 'Done done: END SUB SUB imagramp (inom!) '**************************************************************************** 'This subroutine supervises the ramp of the magnet current. ' 'Input: ' inom!, the desired magnet current ' 'Zachary Wolf '7/23/95 '**************************************************************************** 'Make sure all parameters have been defined with acceptable values CALL imagcheckpar(ok$) IF ok$ <> "y" THEN EXIT SUB 'Make sure a power supply is being used IF imagconfigP$ = "NONE" THEN EXIT SUB 'Make sure the maximum current is not exceeded IF ABS(inom!) > imaglimitP! THEN PRINT "IMAGRAMP: request for current above maximum limit, request denied" EXIT SUB END IF 'See if a reversing switch needs to be changed STATIC ncall% ncall% = ncall% + 1 STATIC oldsign$ IF ncall% = 1 THEN oldsign$ = "+" IF inom! >= 0 THEN sign$ = "+" ELSE sign$ = "-" END IF IF inom! = 0 AND oldsign$ = "+" THEN sign$ = "+" IF inom! = 0 AND oldsign$ = "-" THEN sign$ = "-" IF imagconfigP$ <> "KEPCO" AND sign$ <> oldsign$ THEN PRINT PRINT "The power supply needs to be reversed." INPUT "Press ENTER when ready.", a$ END IF oldsign$ = sign$ 'Message PRINT PRINT "Ramping to "; inom!; " Amps..." 'Record the ramp in the log file CALL imaglogramp(logfileP$, inom!) 'Set the DVM so the current can be monitored CALL imagmonitor 'Ramp 'Power supplies 1, 2, 3 IF imagconfigP$ = "1" OR imagconfigP$ = "2" OR imagconfigP$ = "3" OR imagconfigP$ = "12S" OR imagconfigP$ = "12P" OR imagconfigP$ = "123P" THEN CALL ips123ramp(imagramprateP!, ABS(inom!)) 'Kepco ELSEIF imagconfigP$ = "KEPCO" THEN CALL ibopramp(imagramprateP!, inom!) 'DAC488 ELSEIF imagconfigP$ = "IDAC" THEN CALL idacramp(imagramprateP!, ABS(inom!)) 'DAC488HR ELSEIF imagconfigP$ = "IDACHR" THEN CALL idachrramp(imagramprateP!, ABS(inom!)) 'VAX ELSEIF imagconfigP$ = "IVAX" THEN CALL vaximagramp(ABS(inom!)) 'Manual ELSEIF imagconfigP$ = "IMAN" THEN CALL imanramp(ABS(inom!)) 'NONE ELSEIF imagconfigP$ = "NONE" THEN 'Do nothing 'Otherwise, unknown power supply configuration ELSE PRINT "IMAGRAMP: unknown power supply configuration." imag! = 0! EXIT SUB END IF 'Leave the DVM so the current can be monitored CALL imagmonitor END SUB SUB imagsaturate (isat!) '**************************************************************************** 'This procedure controls the initial saturation of the magnet. ' 'Input: ' isat!, the saturation current ' 'Zachary Wolf '8/30/95 '**************************************************************************** 'Make sure all parameters have been defined with acceptable values CALL imagcheckpar(ok$) IF ok$ <> "y" THEN EXIT SUB 'Let the operator know what is happening PRINT PRINT "Saturating the magnet steel..." 'Ramp to the desired current CALL imagramp(isat!) 'Ramp to 0 A CALL imagramp(0!) END SUB SUB imagsetpar (logfile$, imagconfig$, imagramprate!, imagnmeasave%, imaglimit!) '**************************************************************************** 'This subroutine sets the parameters required by this module. ' 'Input: ' logfile$, log file path and name ' imagconfig$, power supply configuration ' imagramprate!, ramp rate (A/s) ' imagnmeasave%, number of current measurements for averaging ' imaglimit!, software current limit ' 'Zachary Wolf '9/21/95 '**************************************************************************** 'Set the parameters logfileP$ = logfile$ imagconfigP$ = imagconfig$ imagramprateP! = imagramprate! imagnmeasaveP% = imagnmeasave% imaglimitP! = imaglimit! END SUB SUB imagstandardize (nstand%, istand!) '**************************************************************************** 'This procedure controls the standardization of the magnet. ' 'Input: ' nstand%, the number of standardization cycles ' istand!, the maximum current for each cycle, negative means bipolar ' 'Zachary Wolf '4/23/94, 7/28/95 '**************************************************************************** 'Make sure all parameters have been defined with acceptable values CALL imagcheckpar(ok$) IF ok$ <> "y" THEN EXIT SUB 'The VAX has its own standardization IF imagconfigP$ = "IVAX" THEN CALL vaxstandardize EXIT SUB END IF 'All other systems use the following standardization: 'Let the operator know what is happening PRINT PRINT "Standardizing the magnet..." 'Loop over currents FOR i% = 1 TO nstand% 'Ramp to the desired current CALL imagramp(ABS(istand!)) 'Ramp to 0 A CALL imagramp(0!) 'For bipolar magnets IF istand! < 0 THEN 'Ramp to the desired negative current CALL imagramp(istand!) 'Ramp to 0 A CALL imagramp(0!) 'End bipolar magnets END IF 'End loop over currents NEXT i% END SUB