DECLARE SUB LS450FlyDataRun () DECLARE SUB LS450GetFlyData (outfile%) DECLARE SUB FlyVoltage () DECLARE SUB Initialize () DECLARE SUB initparam () DECLARE SUB LS450DataRun () DECLARE SUB LS450FlySetup () DECLARE SUB LS450GetData (outfile%) DECLARE SUB MeasureImag () DECLARE SUB Paraminit () DECLARE SUB PSmenu () DECLARE SUB RampPS () DECLARE SUB SR770FlyDataRun () DECLARE SUB SR770FlySetup (flycur!) DECLARE SUB SR770GetFlyData () DECLARE SUB Standardize () DECLARE SUB gpibinit (ieeein%, ieeeout%) DECLARE SUB bit488setpar (gpibin%, gpibout%, bit488addr$) DECLARE SUB dac488setpar (gpibin%, gpibout%, dac488addr$) DECLARE SUB dac488hrsetpar (gpibin%, gpibout%, dac488hraddr$) DECLARE SUB psdac488setpar (gpibin%, gpibout%, psdac488addr$) DECLARE SUB pshp3457setpar (gpibin%, gpibout%, pshp3457addr$) DECLARE SUB hp3457init () DECLARE SUB hp3457setpar (gpibin%, gpibout%, hp3457addr$) DECLARE SUB hp3457setupv (c%) DECLARE SUB ChangePolarity () DECLARE SUB imaggetiav (imag!, simag!) DECLARE SUB imaginit () DECLARE SUB imagmonitor () DECLARE SUB imagramp (inom!) DECLARE SUB imagsetpar (logfile$, imagconfig$, imagramprate!, imagnmeasave%, imaglimit!) DECLARE SUB imagstandardize (nstand%, istand!) DECLARE SUB ibopsetpar (imaghpchan%, vtransperimag!, imagtstable%) DECLARE SUB idacsetpar (imagdacchan%, imagpervdac!, imagtstable%, imaghpchan%, vtransperimag!) DECLARE SUB idachrsetpar (imagdacchan%, imagpervdac!, imagtstable%, imaghpchan%, vtransperimag!) DECLARE SUB ips123setpar (logfile$, imagconfig$, imagtstable%) DECLARE SUB imansetpar (imaghpchan%, vtransperimag!) DECLARE SUB fileinitlog (logfile$) DECLARE SUB sr770 () DECLARE SUB SR770GetData () DECLARE SUB sr770getxdata (trace%, spectrum!()) DECLARE SUB sr770getydata (trace%, spectrum!()) DECLARE SUB sr770pausecont () DECLARE SUB sr770setpar (gpbin%, gpbout%, sr770addr$) DECLARE SUB LS450 () DECLARE SUB ls450fastmode (sel%) DECLARE SUB ls450getb (b!) DECLARE SUB ls450init () DECLARE SUB ls450setpar (gpibinf%, gpiboutf%, ls450addr$) DECLARE SUB ls450setupb () '**************************************************************************** 'Program RAMP 'This program ramps the power supply. ' 'Zachary Wolf '12/4/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$, ivalP$ COMMON SHARED /flyinfo/ flyvolt!, trndcv!, ramprate!, bfield!(), r%, task$ '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 RAMP" PRINT "This program lets the user operate the power supply." 'Initialize the hardware and software CALL Paraminit 'Initialize parameters CALL initparam 'Operate the power supply CALL PSmenu 'Prepare to exit the program 'CALL imagexit 'Message PRINT "The program is finished." END SUB FlyVoltage 'Get the On-the-Fly current value from the user PRINT WHILE yn$ <> "Y" PRINT "Enter the 'On-the-Fly' current value (amps): "; INPUT flyvalP$ IF flyvalP$ = "" THEN EXIT SUB flyval! = VAL(flyvalP$) PRINT "Confirm "; flyval!; " A? [y/n]"; INPUT yn$ yn$ = UCASE$(LEFT$(yn$, 1)) WEND 'Get the DAC output voltage which corresponds to the Fly Current flyvolt! = flyval! / imagpervdacP! PRINT "Read the Voltage of Current [V or C]: "; INPUT sel$ sel$ = UCASE$(sel$) 'Start with supply at 0 amps CALL imagramp(0!) 'Setup for the On-the-Fly read IF (sel$ = "C") THEN hp3457setupv (0) ' Transductor Voltage IF (sel$ = "V") THEN hp3457setupv (1) ' Magnet Voltage 'Ramp the supply to 50 amps (Up ramp measurement) CALL imagramp(50!) IF (sel$ = "C") THEN PRINT "Magnet Fly Current: "; trndcv! / vtransperimagP!; " Amps" IF (sel$ = "V") THEN PRINT "Magnet Fly Voltage: "; trndcv!; " Volts" 'Finish with supply at 0 amps CALL imagramp(0!) flyvolt! = 6 END SUB SUB Initialize getinit: INPUT "Do you want to initialize the power supplies? "; init$ IF init$ = "" THEN EXIT SUB PRINT "Confirm "; init$; " [y/n]"; INPUT yn$ IF UCASE$(LEFT$(yn$, 1)) <> "Y" GOTO getinit CALL imaginit END SUB SUB initparam 'Set the SR770 parameters CALL sr770setpar(gpibinP%, gpiboutP%, sr770addrP$) CALL ls450setpar(gpibinP%, gpiboutP%, ls450addrP$) flyvolt! = 6! SHELL ("del sa.*") projectP$ = "PEPII HER" magtypeP$ = "Dipole" magnameP$ = "Bump Dipole" teststandP$ = "MM #2" operatorP$ = "PDR" runP% = 0 END SUB SUB ls450calcb (b!) 'Get the multiplier PRINT #gpiboutP%, "OUTPUT " + ls450addrP$ + "; FIELDM?" PRINT #gpiboutP%, "ENTER " + ls450addrP$ INPUT #gpibinP%, mult$ IF mult$ = "u" THEN b! = b! / 1000000! ELSEIF mult$ = "m" THEN b! = b! / 1000! ELSEIF mult$ = "k" THEN b! = b! * 1000! ELSEIF mult$ = "" THEN b! = b! ELSE PRINT "Unknown field multiplier: "; mult$ b! = 0! EXIT SUB END IF END SUB SUB LS450FlyDataRun mincur% = 10 maxcur% = 100 stepcur% = 10 CALL ls450init SHELL ("del ls450.dat") outfile% = FREEFILE fileout$ = "ls450.dat" OPEN fileout$ FOR OUTPUT AS outfile% task$ = "R" PRINT #outfile%, "Flat top data run:" PRINT #outfile%, "Current (A), B0(T)" FOR i% = mincur% TO maxcur% STEP stepcur% PRINT Current! = i% / 10! CALL imagramp(Current!) CALL imaggetiav(imag!, simag!) CALL ls450getb(bfield!) PRINT "Field Strength B0: "; bfield!; " Tesla" PRINT #outfile%, imag!; bfield! NEXT downstep% = -1 * stepcur% FOR i% = maxcur% TO mincur% STEP downstep% PRINT Current! = i% / 10! CALL imagramp(Current!) CALL imaggetiav(imag!, simag!) CALL ls450getb(bfield!) PRINT "Field Strength B0: "; bfield!; " Tesla" PRINT #outfile%, imag!; bfield! NEXT PRINT #outfile%, "" PRINT #outfile%, "On-the-Fly data run: " PRINT #outfile%, "Ramp Rate (A/sec): "; imagramprateP! PRINT #outfile%, "Current (A), Bini (T), Bfin (T), Bave (T)" 'Setup the LS450 to take field reading CALL LS450FlySetup task$ = "R" 'Ramp to 0A taking read at Fly-Current along the way imagramp (0!) ' Ramp to minimum On the Fly current value 'imagramp (1!) task$ = "B" PRINT FOR i% = mincur% TO maxcur% STEP stepcur% PRINT : PRINT USING "Measure On-the-Fly at ## amps:"; i%; 'Set the on the fly dac voltage flycur! = i% / 10! flyvolt! = flycur! / imagpervdacP! 'Ramp to 50A taking read at Fly-Current along the way r% = 1 imagramp (10!) 'Calculate the current, Apply the conversion factor CALL LS450GetFlyData(outfile%) 'Ramp to 0A taking read at Fly-Current along the way r% = 1 imagramp (0!) 'Calculate the current, Apply the conversion factor CALL LS450GetFlyData(outfile%) NEXT ls450fastmode (0) CLOSE outfile% END SUB SUB LS450FlySetup DIM bfield!(2) 'Setup fly voltage flyvolt! = 0 'Setup the hp3457 to take a voltage read hp3457setupv (imaghpchanP%) 'Setup the LS450 for fast data read ls450setupb ls450fastmode (1) END SUB SUB LS450GetFlyData (outfile%) imagfly! = trndcv! / vtransperimagP! Bi! = bfield!(1) / 1000 Bf! = bfield!(2) / 1000 PRINT #outfile%, USING "###.#### ##.##### ##.##### ##.#####"; imagfly!; Bi!; Bf!; (Bi + Bf!) / 2! PRINT : PRINT USING "Measuring: ##.### A Bi=####.## G Bf=####.## G"; imagfly!; 10000 * Bi!; 10000 * Bf! END SUB SUB MeasureImag CALL imaggetiav(imag!, simag!) END SUB SUB Paraminit '**************************************************************************** 'This subroutine does all the initialization for the program. 'Most parameters come from param.inc. ' 'Zachary Wolf '9/20/95 '**************************************************************************** 'Hardware init 'Initialize the GPIB CALL gpibinit(gpibinP%, gpiboutP%) 'Set the parameters for the HP3457 CALL hp3457setpar(gpibinP%, gpiboutP%, hp3457addrP$) CALL hp3457init '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$) 'Software init 'Open all files CALL fileinitlog(logfileP$) '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 PSmenu '**************************************************************************** 'This subroutine lets the operator operate the power supplies using 'a menu. ' 'Zachary Wolf '7/27/95 '**************************************************************************** 'Header 'List the options for the ramp gettask: CLS PRINT "RAMP: Program used to control the power supply" PRINT PRINT "Do you wish to:" PRINT PRINT "[I] Initialize the power supply." PRINT "[S] Standardize the magnet." PRINT "[R] Ramp the magnet current." PRINT "[C] Change the polarity." PRINT "[M] Measure the magnet current." PRINT "[V] Measure magnet voltage, current, and ramp rate On-the-Fly" PRINT "[F] On-the-Fly measurement of the SR770 at I amps." PRINT "[D] Get the Data from the SR770 Spectrum Analyzer." PRINT "[B] Measure B0 vs Current (flat top and On-the-Fly)." 'PRINT "[A] Operate the SR770 Spectrum Analyzer." 'PRINT "[G] Operate the LS450 Gaussmeter. " PRINT "[E] Exit the program." PRINT INPUT "Please enter your choice: ", task$ task$ = UCASE$(LEFT$(task$, 1)) IF task$ <> "B" AND task$ <> "G" AND task$ <> "I" AND task$ <> "S" AND task$ <> "R" AND task$ <> "C" AND task$ <> "M" AND task$ <> "D" AND task$ <> "V" AND task$ <> "F" AND task$ <> "E" THEN PRINT "Not a valid entry." GOTO gettask END IF 'Call the appropriate subroutine IF task$ = "I" THEN CALL Initialize ' Initialize the power supply IF task$ = "S" THEN CALL Standardize ' Standardize the magnet IF task$ = "R" THEN CALL RampPS ' Ramp the power supply IF task$ = "C" THEN CALL ChangePolarity ' Change polarity IF task$ = "M" THEN CALL MeasureImag ' Measure the magnet current IF task$ = "A" THEN CALL sr770 ' Operate the Spectrum Analyzer IF task$ = "D" THEN CALL SR770GetData ' Get the trace data from the SR770 IF task$ = "G" THEN CALL LS450 ' Operate the LS450 Gaussmeter IF task$ = "F" THEN CALL SR770FlyDataRun ' Make an on the FLY type fft read IF task$ = "V" THEN CALL FlyVoltage ' Measure the On-the-Fly magnet voltage IF task$ = "B" THEN CALL LS450FlyDataRun ' Measure B0 vs current IF task$ = "E" THEN EXIT SUB 'Leave the DVM monitoring the transductor CALL imagmonitor 'Continue after user enters PRINT : PRINT "Enter to continue with PS menu selection: "; INPUT tmpstr$ 'Get the next task GOTO gettask END SUB SUB RampPS getval: CALL imaggetiav(imag!, simag!) PRINT INPUT "What current do you wish to ramp to? ", ivalP$ IF ivalP$ = "" THEN EXIT SUB ival! = VAL(ivalP$) PRINT "Confirm "; ival!; " A? [y/n]"; INPUT yn$ IF UCASE$(LEFT$(yn$, 1)) <> "Y" GOTO getval CALL imagramp(ival!) CALL imaggetiav(imag!, simag!) END SUB SUB SR770FlyDataRun 'Get the On-the-Fly current value from the user PRINT WHILE yn$ <> "Y" PRINT "Enter the 'On-the-Fly' current value (amps): "; INPUT flyvalP$ IF flyvalP$ = "" THEN EXIT SUB flyval! = VAL(flyvalP$) PRINT "Confirm "; flyval!; " A? [y/n]"; INPUT yn$ yn$ = UCASE$(LEFT$(yn$, 1)) WEND 'Start with supply at 0 amps CALL imagramp(0!) 'Setup for the On-the-Fly read CALL SR770FlySetup(flyval!) 'Ramp the supply to 50 amps (Up ramp measurement) CALL imagramp(50!) 'Get the data from the On-the-Fly measurement CALL SR770GetFlyData 'Ramp the supply at 0 amps (Down ramp measurement) CALL imagramp(0!) 'Get the data from the On-the-Fly measurement CALL SR770GetFlyData flyvolt! = 6! END SUB SUB SR770FlySetup (flycur!) 'Set the SR770 parameters CALL sr770setpar(gpibinP%, gpiboutP%, sr770addrP$) 'Setup the hp3457 to take a voltage read hp3457setupv (imaghpchanP%) 'Get the DAC output voltage which corresponds to the Fly Current flyvolt! = flycur! / imagpervdacP! END SUB SUB SR770GetFlyData DIM ydata!(0 TO 399), xdata!(0 TO 399) 'Set the SR770 parameters CALL sr770setpar(gpibinP%, gpiboutP%, sr770addrP$) 'Get the X and Y data from the Spectrum Annalyzer CALL sr770getydata(-1, ydata!()) CALL sr770getxdata(-1, xdata!()) 'Continue the Spectrum Analyzer (active) sr770pausecont 'Calculate the current, Apply the conversion factor imagfly! = trndcv! / vtransperimagP! 'Output the data to a file runP% = runP% + 1 ramptype$ = "Up Ramp" IF (runP% MOD 2) = 0 THEN ramptype$ = "Down Ramp" run$ = LTRIM$(STR$(runP%)) outfile% = FREEFILE fileout$ = "sa.ru" + run$ OPEN fileout$ FOR OUTPUT AS outfile% PRINT #outfile%, "/et g '" + magnameP$ + " Imag: "; imagfly!; " A: " + " Ramp Rate: "; ramprate!; " A/s " + ramptype$ + "'" PRINT #outfile%, "/et y 'Voltage Amplitude (volts)' " PRINT #outfile%, "/et x 'Frequency (Hz)'" PRINT #outfile%, "/sm OFF" PRINT #outfile%, "/sc ON" PRINT #outfile%, "/sd OFF " PRINT #outfile%, "/ol y on" FOR i% = 0 TO 399 PRINT #outfile%, xdata!(i%); ydata!(i%) NEXT CLOSE outfile% 'Inform user of output PRINT : PRINT "The following file has been created: "; fileout$ END SUB SUB Standardize getstand: RampArea$ = "Standardize" INPUT "What current do you wish to standardize to? ", istand$ INPUT "How many standardization cycles? ", nstand$ IF istand$ = "" THEN EXIT SUB IF nstand$ = "" THEN EXIT SUB 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!) RampArea$ = " " END SUB