DECLARE SUB ips123geti (imag!) DECLARE SUB ips123monitor () DECLARE SUB ips123ramp (rr!, inom!) DECLARE SUB ips123exit () DECLARE SUB ips123init () 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 ibopexit () DECLARE SUB ibopgeti (imag!) DECLARE SUB ibopinit () DECLARE SUB ibopmonitor () DECLARE SUB ibopramp (rr!, inom!) '**************************************************************************** 'Module IMAG 'This module contains drivers to set and measure the magnet current. ' 'Zachary Wolf '8/30/95 '**************************************************************************** 'Common area for shared parameters 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! OR imaglimitP! > 3000! 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 ivaxexit 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 ivaxgeti(imag!) 'Manual ELSEIF imagconfigP$ = "IMAN" THEN ' CALL imangeti(imag!) '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 '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 imaggetparam '**************************************************************************** 'This subroutine prompts the operator for power supply information. ' 'Outputs put in the /imag/ common block: ' imagconfigP$, power supply configuration ' imagramprateP$, magnet ramp rate ' 'Zachary Wolf '7/25/95 '**************************************************************************** 'Header PRINT PRINT "****************************" PRINT "* POWER SUPPLY INFORMATION *" PRINT "****************************" begin: 'Get the power supply configuration PRINT psconfig: PRINT "What is the power supply configuration you are using?" PRINT "(1, 2, 3, 12P, 123P, 12S, KEPCO, VAX, MANUAL): ["; imagconfigP$; "]"; INPUT psconfig$ psconfig$ = UCASE$(psconfig$) IF psconfig$ <> "" THEN imagconfigP$ = psconfig$ IF imagconfigP$ <> "1" AND imagconfigP$ <> "2" AND imagconfigP$ <> "3" AND imagconfigP$ <> "12P" AND imagconfigP$ <> "123P" AND imagconfigP$ <> "12S" AND imagconfigP$ <> "KEPCO" AND imagconfigP$ <> "VAX" AND imagconfigP$ <> "MANUAL" THEN PRINT "Not a valid configuration!" PRINT GOTO psconfig END IF 'Get the ramp rate ramprate: PRINT "What ramp rate (A/s) do you wish to use ["; imagramprateP!; "]"; INPUT ramprate$ IF ramprate$ <> "" THEN imagramprateP! = VAL(ramprate$) IF imagramprateP! < 0! OR imagramprateP! > 200! THEN PRINT "Not a valid ramp rate!" PRINT GOTO ramprate END IF '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 imaginit '**************************************************************************** 'This subroutine is used to initialize 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 '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 ips123init 'Kepco ELSEIF imagconfigP$ = "KEPCO" THEN CALL ibopinit 'DAC488 ELSEIF imagconfigP$ = "IDAC" THEN ' CALL idacinit 'DAC488HR ELSEIF imagconfigP$ = "IDACHR" THEN ' CALL idachrinit 'VAX ELSEIF imagconfigP$ = "IVAX" THEN ' CALL ivaxinit 'Manual ELSEIF imagconfigP$ = "IMAN" THEN ' CALL imaninit 'Otherwise, unknown power supply configuration ELSE PRINT "IMAGINIT: unknown power supply configuration." imag! = 0! 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%, 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%, PRINT #filenum%, TIME$; " Magnet Current Measurement:" PRINT #filenum%, "Imag = "; imag!; " +- "; simag!; " A" '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 ' CALL ivaxmonitor 'Manual ELSEIF imagconfigP$ = "IMAN" THEN ' CALL imanmonitor '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 " [I]nitialize the power supply." 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$ <> "I" AND task$ <> "S" AND task$ <> "R" AND task$ <> "C" AND task$ <> "M" AND task$ <> "E" THEN PRINT "Not a valid entry." GOTO gettask END IF 'Initialize IF task$ = "I" THEN PRINT "Confirm initialize power supply? [y/n]"; INPUT yn$ IF UCASE$(LEFT$(yn$, 1)) <> "Y" GOTO gettask CALL imagramp(20!) 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 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 'Message PRINT PRINT "Ramping to "; inom!; " Amps..." 'Make an initial measurement of the magnet current 'The value is recorded in the log file CALL imaggeti(iinit!) '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!, inom!) 'Kepco ELSEIF imagconfigP$ = "KEPCO" THEN CALL ibopramp(imagramprateP!, inom!) 'DAC488 ELSEIF imagconfigP$ = "IDAC" THEN ' CALL idacramp(imagramprateP!, inom!) 'DAC488HR ELSEIF imagconfigP$ = "IDACHR" THEN ' CALL idachrramp(imagramprateP!, inom!) 'VAX ELSEIF imagconfigP$ = "IVAX" THEN ' CALL ivaxramp(imagramprateP!, inom!) 'Manual ELSEIF imagconfigP$ = "IMAN" THEN ' CALL imanramp(imagramprateP!, inom!) 'Otherwise, unknown power supply configuration ELSE PRINT "IMAGRAMP: unknown power supply configuration." imag! = 0! EXIT SUB END IF 'Make a final measurement of the magnet current 'The value is recorded in the log file CALL imaggeti(ifin!) '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$, name of the log file ' imagconfig$, power supply configuration ' imagramprate!, ramp rate ' imagnmeasave%, number of current measurements for averaging ' imaglimit!, absolute value of maximum current ' 'Zachary Wolf '9/21/95 '**************************************************************************** 'Put the parameters in the module's common block for future use 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 '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