DECLARE SUB hp3457cntv (c%, n%, t!, v!()) DECLARE SUB vcoilint (n%, t!, v!(), vtp!, vtn!) DECLARE SUB vcoilntvsim (n%, t!, v!()) DECLARE SUB IntegrateVector (y!(), samper!, xl%, xh%, ans!) DECLARE FUNCTION fftmagnitude (re!(), im!(), n%, i%) DECLARE FUNCTION fftphase (re!(), im!(), n%, i%) DECLARE FUNCTION fftfrequency (n%, f!, i%) SUB vcoilcntvt (c%, n%, t!, nave%, vtp!(), vtn!(), vt!, sigvt!) '**************************************************************************** 'This subroutine finds the average integrated voltage and standard 'deviation as a coil is rotated through 180 degrees. ' 'Input: ' c%, the DVM channel number to sample ' n%, the number of voltage samples ' t!, the time interval between voltage samples ' nave%, the number of full rotations of the coil to average over ' 'Output: ' vtp!(1 to nave%), the nave% values of the voltage integrated over a positive half cycle ' vtn!(1 to nave%), the nave% values of the voltage integrated over a negative half cycle ' vt!, the average integrated voltage ' sigvt!, the error estimate on vt! ' 'Zachary Wolf '5/14/94 '**************************************************************************** 'Initialize the voltage sample array DIM v!(0 TO n% - 1) 'Find the integrated voltage from the coil nave times FOR j% = 1 TO nave% 'Sample the voltage from the coil CALL hp3457cntv(c%, n%, t!, v!()) 'Generate data for testing 'CALL vcoilntvsim(n%, t!, v!()) 'Compute the time integral of the positive and negative half voltage cycles CALL vcoilint(n%, t!, v!(), vtp!(j%), vtn!(j%)) 'End averaging loop NEXT j% 'Find the mean of the integrated voltage values sum! = 0 FOR j% = 1 TO nave% sum! = sum! + vtp!(j%) sum! = sum! - vtn!(j%) NEXT j% vt! = sum! / (2 * nave%) 'Find the standard deviation of the integrated voltage values sum! = 0 FOR j% = 1 TO nave% sum! = sum! + (vtp!(j%) - vt!) ^ 2 sum! = sum! + (-vtn!(j%) - vt!) ^ 2 NEXT j% sigvt! = sum! / (2 * nave%) sigvt! = SQR(sigvt!) END SUB SUB vcoilint (n%, t!, v!(), vtp!, vtn!) '**************************************************************************** 'This subroutine integrates the voltage from a rotating coil. 'It returns the voltage integral of a positive 'half cycle and of a negative half cycle. It uses the Quinn-Curtis 'software tools to do the integrals. The routine basically finds the 'flux change as the coil is flipped. ' 'Input: ' n%, number of voltage samples ' t!, time between each voltage sample ' v!(0 to n%-1), voltage samples ' 'Outputs: ' vtp!, integral of the voltage over a positive half cycle ' vtn!, integral of the voltage over a negative half cycle ' 'Zachary Wolf '4/10/94 '**************************************************************************** 'Find the first zero crossing FOR i% = 0 TO n% - 4 IF (v!(i%) > 0 AND v!(i% + 1) < 0) OR (v!(i%) < 0 AND v!(i% + 1) > 0) THEN zero1% = i% EXIT FOR END IF NEXT i% 'Find the voltage integral contributions near the first zero crossing 'using linear interpolation y0! = v!(zero1%) y1! = v!(zero1% + 1) i0! = .5 * y0! * (-y0! * t!) / (y1! - y0!) i1! = .5 * y1! * (t! - (-y0! * t!) / (y1! - y0!)) 'Find the second zero crossing FOR i% = zero1% + 3 TO n% - 4 IF (v!(i%) > 0 AND v!(i% + 1) < 0) OR (v!(i%) < 0 AND v!(i% + 1) > 0) THEN zero2% = i% EXIT FOR END IF NEXT i% 'Find the voltage integral contributions near the second zero crossing 'using linear interpolation y0! = v!(zero2%) y1! = v!(zero2% + 1) I3! = .5 * y0! * (-y0! * t!) / (y1! - y0!) I4! = .5 * y1! * (t! - (-y0! * t!) / (y1! - y0!)) 'Integrate from the first zero crossing to the second using Simpson's rule CALL IntegrateVector(v!(), t!, zero1% + 1, zero2%, i2!) 'Find the third zero crossing FOR i% = zero2% + 3 TO n% - 4 IF (v!(i%) > 0 AND v!(i% + 1) < 0) OR (v!(i%) < 0 AND v!(i% + 1) > 0) THEN zero3% = i% EXIT FOR END IF NEXT i% 'Find the voltage integral contributions near the third zero crossing 'using linear interpolation y0! = v!(zero3%) y1! = v!(zero3% + 1) I6! = .5 * y0! * (-y0! * t!) / (y1! - y0!) I7! = .5 * y1! * (t! - (-y0! * t!) / (y1! - y0!)) 'Integrate from the second zero crossing to the third using Simpson's rule CALL IntegrateVector(v!(), t!, zero2% + 1, zero3%, I5!) 'Sum to get the total integrals Int1! = i1! + i2! + I3! Int2! = I4! + I5! + I6! 'Output integrals IF Int1! > 0 AND Int2! < 0 THEN vtp! = Int1! vtn! = Int2! ELSE vtp! = Int2! vtn! = Int1! END IF END SUB SUB vcoilntvsim (n%, t!, v!()) '**************************************************************************** 'This subroutine generates n% samples of a sine wave at intervals t!. 'The sine wave has amplitude A and a period of L seconds. 'The + and - voltage integrals are AL/pi. A and L are parameters internal 'to this routine. ' 'Input: ' n%, the number of samples desired ' t!, the time between samples ' 'Output: ' v!(0 to n%-1), generated samples ' 'Zachary Wolf '4/11/94 '**************************************************************************** 'Define the parameters CONST pi! = 3.141593 CONST a! = 1! CONST L! = 1.9 'The integral over a half period is 1.9/pi. CONST phi! = 2! * pi! / 20! 'Generate the samples FOR i% = 0 TO n% - 1 v!(i%) = a! * SIN((2! * pi! / L!) * i% * t! + phi!) ' v!(i%) = v!(i%) + .05 * (RND - .5) NEXT i% 'Message PRINT "VCOILNTVSIM test data, A = "; a!; ", L = "; L!; ", IVDT+ = "; a! * L! / pi! END SUB