DECLARE SUB mc4moveabs (x!) DECLARE SUB mc4moverel (dx!) DECLARE SUB hp3458getntv (n%, v!()) DECLARE SUB hp3458startntv (n%, t!) DECLARE SUB vtwcheckpar (ok$) DECLARE SUB vtwgetvt (x0!, dx!, vt!) DECLARE SUB vtwgetvtav (x0!, dx!, vt!, svt!) DECLARE SUB vtwlogmoveabs (logfile$, x!) DECLARE SUB vtwlogmoverel (logfile$, dx!) DECLARE SUB vtwlogplotv (logfile$, ns%, t!(), v!()) DECLARE SUB vtwlogvt (logfile$, x0!, dx!, vt!) DECLARE SUB vtwlogvtav (logfile$, x0!, dx!, nm%, vt!, svt!) DECLARE SUB vtwlogvtvsx (logfile$, nx%, x0!(), dx!, vt!(), svt!()) DECLARE SUB vtwmoveabs (x!) DECLARE SUB vtwmoverel (dx!) DECLARE SUB vtwtrapint (ns%, y!(), dx!, iydx!) DECLARE SUB imaggeti (imag!) '**************************************************************************** 'Module VTWIRE 'This module contains routines to perform stretched wire measurements. 'It controls the motion of the wire using the Klinger stages 'and the voltage sampling using an HP3458. ' 'Zachary Wolf '5/31/94 '**************************************************************************** 'Common area for shared parameters COMMON SHARED /vtwire/ logfileP$, velcmsP!, tsamplebefsP!, tsampleaftsP!, nsampleP%, nmeasaveP% SUB vtwcheckpar (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 "WIRE: logfile not defined" EXIT SUB END IF 'velcmsP! IF velcmsP! <= 0! OR velcmsP! > 1! THEN PRINT "WIRE: velcms has improper value" EXIT SUB END IF 'tsamplebefsP! IF tsamplebefsP! <= 0 OR tsamplebefsP! > 20 THEN PRINT "WIRE: tsamplebefs has improper value" EXIT SUB END IF 'tsampleaftsP! IF tsampleaftsP! <= 0 OR tsampleaftsP! > 20 THEN PRINT "WIRE: tsampleafts has improper value" EXIT SUB END IF 'nsampleP% IF nsampleP% <= 0 OR nsampleP% > 5000 THEN PRINT "WIRE: nsample has improper value" EXIT SUB END IF 'nmeasaveP% IF nmeasaveP% <= 0 OR nmeasaveP% > 50 THEN PRINT "WIRE: nmeasave has improper value" EXIT SUB END IF 'If we made it this far, all parameters have values ok$ = "y" END SUB SUB vtwgetvt (x0!, dx!, vt!) '**************************************************************************** 'This subroutine moves the wire and finds the integrated voltage from 'the wire. ' 'Input: ' x0!, nominal center position about which the wire moves ' dx!, nominal distance the wire moves, sign gives direction ' 'Output: ' vt!, integrated voltage from the wire ' 'Zachary Wolf '1/14/95 '**************************************************************************** 'Make sure all parameters have been initialized CALL vtwcheckpar(ok$) IF ok$ <> "y" THEN vt! = 0! PRINT "WIRE: the parameters in WIRE have a problem" EXIT SUB END IF 'Simplify the notation ns% = nsampleP% vel! = velcmsP! tsampbef! = tsamplebefsP! tsampaft! = tsampleaftsP! 'Initialize data arrays DIM v!(0 TO ns% - 1) 'voltage samples from the wire 'Compute how long the DVM should sample and the time between samples tsamp! = tsampbef! + (ABS(dx!) / vel!) + tsampaft! dt! = tsamp! / ns% 'Move to the starting point CALL vtwmoveabs(x0! - (dx! / 2)) 'Start the DVM sampling the wire voltage 'PRINT "ns% = "; ns%; ", dt! = ", dt! CALL hp3458startntv(ns%, dt!) 'Sample before the wire motion t0! = TIMER WHILE TIMER - t0! < tsampbef! WEND 'Move the wire to the final position CALL vtwmoverel(dx!) 'Sample after the wire motion allowing the wire to settle t0! = TIMER WHILE TIMER - t0! < tsampaft! WEND 'Get the voltage samples CALL hp3458getntv(ns%, v!()) 'Compute the integrated voltage CALL vtwtrapint(ns%, v!(), dt!, vt!) 'Log the result CALL vtwlogvt(logfileP$, x0!, dx!, vt!) END SUB SUB vtwgetvtav (x0!, dx!, vt!, svt!) '**************************************************************************** 'This subroutine moves the wire and finds the integrated voltage from 'the wire. ' 'Input: ' x0!, nominal center position about which the wire moves ' dx!, nominal distance the wire moves ' 'Output: ' vt!, integrated voltage from the wire ' svt!, standard deviation of vt ' 'Zachary Wolf '1/14/95 '**************************************************************************** 'Simplify the notation nm% = nmeasaveP% 'Initialize data arrays DIM vtmeas!(1 TO nm%) 'voltage integral = flux crossed 'Loop over measurements for averaging FOR j% = 1 TO nm% 'Get the integrated voltage for a + move CALL vtwgetvt(x0!, dx!, vtp!) 'Get the integrated voltage for a - move CALL vtwgetvt(x0!, -dx!, vtm!) 'Compute the average integrated voltage for this measurement vtmeas!(j%) = (vtp! - vtm!) / 2! 'End averaging loop NEXT j% 'Compute the average of the measurements vt! = 0! FOR j% = 1 TO nm% vt! = vt! + vtmeas!(j%) NEXT j% vt! = vt! / nm% 'Compute the standard deviation of the measurements svt! = 0! FOR j% = 1 TO nm% svt! = svt! + (vtmeas!(j%) - vt!) ^ 2 NEXT j% svt! = SQR(svt! / nm%) 'Message PRINT PRINT "Integrated Voltage From The Wire:" PRINT "X0 = "; x0!; " cm, Delta X = "; dx!; " cm" PRINT "Integrated Voltage = "; vt!; " +- "; svt!; " VS (= Tm^2)" 'Write the result to the log file CALL vtwlogvtav(logfileP$, x0!, dx!, nm%, vt!, svt!) END SUB SUB vtwgetvtvsx (nx%, x0!(), dx!, vtvsx!(), svtvsx!()) '**************************************************************************** 'This subroutine measures the integrated voltage as a function of position 'across the magnet aperture. ' 'Input: ' nx%, the number of x positions ' x0!(1 to nx%), the center position of each wire motion ' dx!, the distance the wire moves ' 'Output: ' vtvsx!(1 to nx%), the integrated voltage at each x positions ' svtvsx!(1 to nx%), the standard deviation of each vt measurement ' 'Zachary Wolf '1/14/95 '**************************************************************************** 'Loop over x positions FOR i% = 1 TO nx% 'Measure the magnet current 'The value is recorded in the log file CALL imaggeti(imag!) 'Message PRINT PRINT "Measuring at X0 = "; x0!(i%); " cm..." 'Get the voltage integral at this position CALL vtwgetvtav(x0!(i%), dx!, vt!, svt!) 'Save the results vtvsx!(i%) = vt! svtvsx!(i%) = svt! 'End loop over x positions NEXT i% 'Write the results to the log file CALL vtwlogvtvsx(logfileP$, nx%, x0!(), dx!, vtvsx!(), svtvsx!()) END SUB SUB vtwlogmoveabs (logfile$, x!) '**************************************************************************** 'This subroutine logs wire movements to the log file. ' 'Input: ' logfile$, the name of the log file ' x!, the position the wire is moved to ' 'Zachary Wolf '11/23/94 '**************************************************************************** 'Open the log file filenum% = FREEFILE OPEN logfile$ FOR APPEND AS filenum% 'Print the results PRINT #filenum%, PRINT #filenum%, TIME$; " Wire moved to X = "; x!; " cm" 'Close the log file CLOSE filenum% END SUB SUB vtwlogmoverel (logfile$, dx!) '**************************************************************************** 'This subroutine logs wire movements to the log file. ' 'Input: ' logfile$, the name of the log file ' dx!, the distance the wire is moved ' 'Zachary Wolf '1/22/95 '**************************************************************************** 'Open the log file filenum% = FREEFILE OPEN logfile$ FOR APPEND AS filenum% 'Print the results PRINT #filenum%, PRINT #filenum%, TIME$; " Wire moved by DX = "; dx!; " cm" 'Close the log file CLOSE filenum% END SUB SUB vtwlogplotv (logfile$, ns%, t!(), v!()) '**************************************************************************** 'This subroutine writes voltage samples to the log file. ' 'Inputs: ' logfile$, the name of the log file ' ns%, the number of voltage samples ' t!(0 to ns%-1), the time of each voltage sample ' v!(0 to ns%-1), the voltage samples ' 'Zachary Wolf '1/7/95 '**************************************************************************** 'Open the log file filenum% = FREEFILE OPEN logfile$ FOR APPEND AS filenum% 'Write the samples to the log file FOR k% = 0 TO ns% - 1 PRINT #filenum%, USING "#####"; k%; PRINT #filenum%, USING " ###.########"; t!(k%); PRINT #filenum%, USING " ###.########"; v!(k%) NEXT k% 'Close the log file CLOSE filenum% END SUB SUB vtwlogvt (logfile$, x0!, dx!, vt!) '**************************************************************************** 'This subroutine writes integrated voltage measurements to the log file. ' 'Input: ' logfile$, the name of the log file ' x0!, the position about which the wire motion is centered ' dx!, the distance the wire is moved ' vt!, the measured integrated voltage ' 'Zachary Wolf '11/23/94 '**************************************************************************** 'Open the log file filenum% = FREEFILE OPEN logfile$ FOR APPEND AS filenum% 'Print the results PRINT #filenum%, PRINT #filenum%, TIME$; " X0 = "; x0!; " cm, dx = "; dx!; " cm, VT = "; vt!; " VS" 'Close the log file CLOSE filenum% END SUB SUB vtwlogvtav (logfile$, x0!, dx!, nm%, vt!, svt!) '**************************************************************************** 'This subroutine write a summary of a stretched wire measurement to the 'log file. ' 'Input: ' logfile$, the name of the log file ' x0!, the center of the wire motion ' dx!, the distance the wire was moved ' nm%, the number of measurements for the average ' vt!, the integrated voltage from the wire ' svt!, the standard deviation of vt ' 'Zachary Wolf '11/25/94 '**************************************************************************** 'Open the log file filenum% = FREEFILE OPEN logfile$ FOR APPEND AS filenum% 'Print the results PRINT #filenum%, PRINT #filenum%, TIME$; " Integrated Voltage Measurement:" PRINT #filenum%, "Center Of Wire Motion, X0 = "; x0!; " cm" PRINT #filenum%, "Distance Wire Moved, Delta X = "; dx!; " cm" PRINT #filenum%, "# Measurements For Average, Nmeas = "; nm% PRINT #filenum%, "Integrated Voltage, VT = "; vt!; " +- "; svt!; " VS (= Tm^2)" 'Close the log file CLOSE filenum% END SUB SUB vtwlogvtvsx (logfile$, nx%, x0!(), dx!, vt!(), svt!()) '**************************************************************************** 'This subroutine writes a summary of the VT vs X measurements. ' 'Input: ' logfile$, the name of the log file ' nx%, the number of x-positions ' x0!(1 to nx%), the x-position of the center of each wire motion ' dx!, the distance the wire is moved for each measurement ' vt!(1 to nx%), the voltage integral for the wire motion ' svt!(1 to ni%), the standard deviation of VT ' 'Zachary Wolf '11/25/94 '**************************************************************************** 'Open the log file filenum% = FREEFILE OPEN logfile$ FOR APPEND AS filenum% 'Write a header PRINT #filenum%, PRINT #filenum%, PRINT #filenum%, "STRETCHED WIRE MEASUREMENT SUMMARY" PRINT #filenum%, PRINT #filenum%, "Distance wire moved, Delta X = "; dx!; " cm" PRINT #filenum%, "X0 = center position of the wire motion" PRINT #filenum%, "VT = integrated voltage" PRINT #filenum%, PRINT #filenum%, " X0 VT sigVT " PRINT #filenum%, " (cm) (VS) (VS) " PRINT #filenum%, " -------- ----------+----------" 'Write the results of the measurements FOR i% = 1 TO nx% PRINT #filenum%, USING " ##.#####"; x0!(i%); PRINT #filenum%, USING " ##.#######"; vt!(i%); PRINT #filenum%, USING " ##.#######"; svt!(i%) NEXT i% 'Close the log file CLOSE filenum% END SUB SUB vtwmoveabs (x!) '**************************************************************************** 'This subroutine controls the wire motion. ' 'Input: ' x!, the x position to move to ' 'Zachary Wolf '1/14/95 '**************************************************************************** 'Move the wire CALL mc4moveabs(x!) 'Log the move CALL vtwlogmoveabs(logfileP$, x!) END SUB SUB vtwmoverel (dx!) '**************************************************************************** 'This subroutine controls the wire motion by an amount relative to the 'present position. ' 'Input: ' dx!, the distance to move in cm, the sign gives the direction ' 'Zachary Wolf '1/22/95 '**************************************************************************** 'Move the wire CALL mc4moverel(dx!) 'Log the move CALL vtwlogmoverel(logfileP$, dx!) END SUB SUB vtwplotv (x0!, dx!) '**************************************************************************** 'This subroutine moves the wire and finds the integrated voltage from 'the wire. ' 'Input: ' x0!, nominal center position about which the wire moves ' dx!, nominal distance the wire moves, sign gives direction ' 'Zachary Wolf '1/14/95 '**************************************************************************** 'Simplify the notation ns% = nsampleP% 'Initialize data arrays DIM v!(0 TO ns% - 1) 'voltage samples from the wire DIM t!(0 TO ns% - 1) 'time of each voltage sample 'Compute how long the DVM should sample and the time between samples tsamp! = tsamplebefsP! + ABS(dx!) / velcmsP! + tsampleaftsP! dt! = tsamp! / ns% 'Message PRINT "Measuring the wire voltage..." 'Move to the starting point CALL vtwmoveabs(x0! - (dx! / 2)) 'Start the DVM sampling the wire voltage CALL hp3458startntv(ns%, dt!) 'Sample before the wire motion t0! = TIMER WHILE TIMER - t0! < tsamplebefsP! WEND 'Move the wire to the final position CALL vtwmoverel(dx!) 'Sample after the wire motion allowing the wire to settle t0! = TIMER WHILE TIMER - t0! < tsampleaftsP! WEND 'Get the voltage samples CALL hp3458getntv(ns%, v!()) 'Compute the time of each sample FOR i% = 0 TO ns% - 1 t!(i%) = i% * dt! NEXT i% 'Initialize a plot file pltfilewire$ = "vwireplt.dat" filenum% = FREEFILE OPEN pltfilewire$ FOR OUTPUT AS filenum% CLOSE filenum% 'Plot the results CALL vtwlogplotv(pltfilewire$, ns%, t!(), v!()) END SUB SUB vtwsetpar (logfile$, velcms!, tsamplebefs!, tsampleafts!, nsample%, nmeasave%) '**************************************************************************** 'This subroutine sets the parameters required by this module. ' 'Input: ' logfile$, name of the log file ' velcms!, wire velocity in cm per s ' tsamplebefs!, sampling time before the wire motion in sec ' tsampleafts!, sampling time after the wire motion in sec ' nsample%, number of wire voltage samples to take ' nmeasave%, number of measurements to make for averaging ' 'Zachary Wolf '9/21/95 '**************************************************************************** 'Store the parameters in the module common block for future use logfileP$ = logfile$ velcmsP! = velcms! tsamplebefsP! = tsamplebefs! tsampleaftsP! = tsampleafts! nsampleP% = nsample% nmeasaveP% = nmeasave% END SUB SUB vtwtrapint (ns%, y!(), dx!, iydx!) '**************************************************************************** 'This subroutine uses the trapezoidal rule to perform a numerical 'integration. ' 'Input: ' ns%, the number of steps for the integration ' y!(0 to ns%-1), the y values ' dx!, the spacing between y values ' 'Output: ' iydx!, the value of the integral ' 'Zachary Wolf '7/7/94, 12/27/94 '**************************************************************************** 'Initialize iydx! = 0 'Sum the areas of the trapezoids to get the integral FOR i% = 1 TO ns% - 1 iydx! = iydx! + .5 * (y!(i%) + y!(i% - 1)) * dx! NEXT i% END SUB