DECLARE SUB spplotfft (ns%, fftm!(), fftp!()) DECLARE SUB spplothar (nh%, harm!(), harp!()) DECLARE SUB spplotsamp (ns%, samp!()) DECLARE SUB vcoillogv (logfile$) DECLARE SUB hp3457cnvtrig (c%, n%, v!()) DECLARE SUB hp3457cf (c%, freq!) DECLARE SUB hp3457extsig (sig%) DECLARE SUB vcoilcheckpar (ok$) DECLARE SUB vcoilgetf (f!) DECLARE SUB vcoilgetv (coilid%, n%, v!()) DECLARE SUB vcoilgetvfft (coilid%, n%, fftm!(), fftp!()) DECLARE SUB vcoilgetvhar (coilid%, nh%, harm!(), harp!()) DECLARE SUB vcoillogf (logfile$, freq!) DECLARE SUB spcalcfft (ns%, samp!(), fftm!(), fftp!()) DECLARE SUB spcalchar (ns%, fftm!(), fftp!(), nfun%, nh%, harm!(), harp!()) '**************************************************************************** 'Module VCOIL.BAS ' 'Zachary Wolf '1/4/95 '**************************************************************************** 'Common block for this module's parameters COMMON SHARED /vcoil/ logfileP$, coilnsampperrevP%, coilnrevpermeasP%, coilfreqhpchanP%, strcoilhpchanP%, harcoilhpchanP%, strcoilidP%, harcoilidP% SUB vcoilcheckpar (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" 'Logfile IF logfileP$ = "" THEN PRINT "VCOIL: Log file not defined" EXIT SUB END IF 'coilnsampperrevP% IF coilnsampperrevP% <= 0 OR coilnsampperrevP% > 2000 THEN PRINT "VCOIL: nsampperrev has improper value" EXIT SUB END IF 'coilnrevpermeasP% IF coilnrevpermeasP% <= 0 OR coilnrevpermeasP% > 200 THEN PRINT "VCOIL: nrevpermeas has improper value" EXIT SUB END IF 'coilfreqhpchanP% IF coilfreqhpchanP% < 0 OR coilfreqhpchanP% > 9 THEN PRINT "VCOIL: freqhpchan has improper value" EXIT SUB END IF 'strcoilhpchanP% IF strcoilhpchanP% < 0 OR strcoilhpchanP% > 9 THEN PRINT "VCOIL: strcoilhpchan has improper value" EXIT SUB END IF 'harcoilhpchanP% IF harcoilhpchanP% < 0 OR harcoilhpchanP% > 9 THEN PRINT "VCOIL: harcoilhpchan has improper value" EXIT SUB END IF 'coil id IF strcoilidP% <= 0 OR harcoilidP% <= 0 THEN PRINT "VCOIL: coil ID has improper value" EXIT SUB END IF 'If we made it this far, all parameters have values ok$ = "y" END SUB SUB vcoilgetf (f!) '**************************************************************************** 'This subroutine is used to get the rotation frequency of a measurement coil. ' 'Output: ' f!, the measured frequency ' 'Zachary Wolf '10/6/94, 11/15/94 '**************************************************************************** 'Simplify the notation ns% = coilnsampperrevP% '# encoder pulses per revolution cf% = coilfreqhpchanP% 'HP3457 channel for the coil frequency 'Make sure there are trigger pulses for the frequency measurement CALL hp3457extsig(0) 'Perform the frequency measurement CALL hp3457cf(cf%, f!) 'Take out ns% pulses per revolution f! = f! / ns% 'Log the coil rotation frequency CALL vcoillogf(logfileP$, f!) END SUB SUB vcoilgetv (coilid%, n%, v!()) '**************************************************************************** 'This subroutine gets triggered voltages from the coil. ' 'Input: ' coilid%, coil ID number ' n%, the number of voltage samples to measure ' 'Output: ' v!(0 to n%-1), the voltage at each sample point ' 'Zachary Wolf '11/20/95 '**************************************************************************** 'Determine the HP3457 channel number IF coilid% = strcoilidP% THEN c% = strcoilhpchanP% ELSEIF coilid% = harcoilidP% THEN c% = harcoilhpchanP% ELSE PRINT "VCOILGETV: unknown coil number" EXIT SUB END IF 'Make the measurement CALL hp3457cnvtrig(c%, n%, v!()) 'Record that a measurement was made CALL vcoillogv(logfileP$) END SUB SUB vcoilgetv1 (coilid%, v1!) '**************************************************************************** 'This subroutine gets the coil voltage at the first harmonic. ' 'Input: ' coilid%, coil ID number ' 'Output: ' v1!, coil voltage at the first harmonic ' 'Zachary Wolf '11/21/95 '**************************************************************************** 'Dimension arrays nh% = 1 DIM harm!(1 TO nh%) DIM harp!(1 TO nh%) 'Get the voltages at the harmonics CALL vcoilgetvhar(coilid%, nh%, harm!(), harp!()) 'Return v1 v1! = harm!(1) END SUB SUB vcoilgetv2 (coilid%, v2!) '**************************************************************************** 'This subroutine gets the coil voltage at the second harmonic. ' 'Input: ' coilid%, coil ID number ' 'Output: ' v2!, coil voltage at the second harmonic ' 'Zachary Wolf '11/21/95 '**************************************************************************** 'Dimension arrays nh% = 2 DIM harm!(1 TO nh%) DIM harp!(1 TO nh%) 'Get the voltages at the harmonics CALL vcoilgetvhar(coilid%, nh%, harm!(), harp!()) 'Return v2 v2! = harm!(2) END SUB SUB vcoilgetv3 (coilid%, v3!) '**************************************************************************** 'This subroutine gets the coil voltage at the third harmonic. ' 'Input: ' coilid%, coil ID number ' 'Output: ' v3!, coil voltage at the third harmonic ' 'Zachary Wolf '11/21/95 '**************************************************************************** 'Dimension arrays nh% = 3 DIM harm!(1 TO nh%) DIM harp!(1 TO nh%) 'Get the voltages at the harmonics CALL vcoilgetvhar(coilid%, nh%, harm!(), harp!()) 'Return v3 v3! = harm!(3) END SUB SUB vcoilgetvfft (coilid%, n%, fftm!(), fftp!()) '**************************************************************************** 'This subroutine performs an integrated voltage measurement and returns the 'FFT of the samples. ' 'Input: ' coilid%, coil ID number ' n%, the number of samples to take, power of 2 ' 'Output: ' fftm!(0 to n%/2), the FFT magnitudes ' fftp!(0 to n%/2), the FFT phases ' 'Zachary Wolf '9/13/95 '**************************************************************************** 'Initialize data arrays DIM v!(0 TO n% - 1) 'Sample the voltage from the coil CALL vcoilgetv(coilid%, n%, v!()) 'Calculate the FFT of the voltage sample CALL spcalcfft(n%, v!(), fftm!(), fftp!()) END SUB SUB vcoilgetvhar (coilid%, nh%, harm!(), harp!()) '**************************************************************************** 'This subroutine performs a voltage measurement and returns the 'signals at the harmonics of the rotation frequency. ' 'Input: ' coilid%, coil ID number ' nh%, the number of harmonics to return ' 'Output: ' harm!(1 to nh%), voltage magnitude at each harmonic ' harp!(1 to nh%), voltage phase in degrees at each harmonic ' 'Zachary Wolf '9/13/95 '**************************************************************************** 'Make sure all required parameters have been defined CALL vcoilcheckpar(ok$) IF ok$ <> "y" THEN PRINT "VCOILGETVHAR: Problem with the parameter definitions" FOR i% = 1 TO nh% harm!(i%) = 0! harp!(i%) = 0! NEXT i% EXIT SUB END IF 'Simplify the notation ns% = coilnsampperrevP% nr% = coilnrevpermeasP% 'Compute the required number of samples n% = ns% * nr% 'Initialize data arrays DIM fftm!(0 TO n% / 2) DIM fftp!(0 TO n% / 2) 'Sample the voltage from the coil and return the FFT of the samples CALL vcoilgetvfft(coilid%, n%, fftm!(), fftp!()) 'Calculate the signal harmonics of the rotation frequency CALL spcalchar(n%, fftm!(), fftp!(), nr%, nh%, harm!(), harp!()) END SUB SUB vcoillogf (logfile$, freq!) '**************************************************************************** 'This subroutine writes the coil rotation frequency to the log file. ' 'Input: ' logfile$, the name of the log file ' freq!, the measured coil rotation frequency ' 'Zachary Wolf '10/3/94 '**************************************************************************** 'Open the log file filenum% = FREEFILE OPEN logfile$ FOR APPEND AS filenum% 'Print the results PRINT #filenum%, TIME$; " Coil Rotation Frequency, Fcoil = "; freq!; " Hz" 'Close the log file CLOSE filenum% END SUB SUB vcoillogv (logfile$) '**************************************************************************** 'This subroutine records a coil voltage 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%, TIME$; " Coil Voltage Measurement Made" 'Close the log file CLOSE filenum% END SUB SUB vcoilplotf '**************************************************************************** 'This subroutine gets coil rotation frequency samples and puts them in 'a file for plotting. ' 'Zachary Wolf '5/4/95 '**************************************************************************** 'Message PRINT PRINT "Beginning the coil rotation frequency measurement cycle..." 'Get the measurement time PRINT INPUT "How long do you wish to record the coil rotation frequency? (min) ", tmin! tsec! = tmin! * 60 'Calculate the number of measurements which will be made tbtwnmeassec% = 5 nmeas% = 1 + tsec! / tbtwnmeassec% 'Initialize the data arrays DIM t!(1 TO nmeas%) DIM f!(1 TO nmeas%) 'Record the starting time t0! = TIMER 'Record the frequency at regular intervals up to tsec FOR i% = 1 TO nmeas% 'Record the time of the measurement tm! = TIMER t!(i%) = tm! - t0! 'Measure the frequency CALL vcoilgetf(f!(i%)) 'Write the measurements to the screen PRINT PRINT "Time: "; TIME$; ", Fcoil = "; f!(i%); " Hz" 'Wait between measurements WHILE TIMER - tm! < tbtwnmeassec% WEND 'End of measurement loop NEXT i% 'Initialize a plot file filenum% = FREEFILE OPEN "fcoilplt.dat" FOR OUTPUT AS filenum% 'Write the samples to the plot file FOR i% = 1 TO nmeas% PRINT #filenum%, USING "######.##"; t!(i%); PRINT #filenum%, USING " ###.######"; f!(i%) NEXT i% 'Close the log file CLOSE filenum% END SUB SUB vcoilplotsamp '**************************************************************************** 'This subroutine gets coil voltage samples and puts them in 'a file for plotting. ' 'Zachary Wolf '9/26/97 '**************************************************************************** 'Message PRINT PRINT "Sampling the coil voltage..." 'Plot the coil voltage samples n% = coilnsampperrevP% * coilnrevpermeasP% DIM v!(0 TO n% - 1) CALL vcoilgetv(harcoilidP%, n%, v!()) CALL spplotsamp(n%, v!()) 'Plot the FFT of the coil voltage samples DIM fftm!(0 TO n% / 2) DIM fftp!(0 TO n% / 2) CALL vcoilgetvfft(harcoilidP%, n%, fftm!(), fftp!()) CALL spplotfft(n%, fftm!(), fftp!()) 'Plot the voltage harmonics nh% = 16 DIM harm!(1 TO nh%) DIM harp!(1 TO nh%) CALL vcoilgetvhar(harcoilidP%, nh%, harm!(), harp!()) CALL spplothar(nh%, harm!(), harp!()) 'Message PRINT "The measurement is complete." END SUB SUB vcoilsetpar (logfile$, coilnsampperrev%, coilnrevpermeas%, coilfreqhpchan%, strcoilhpchan%, harcoilhpchan%, strcoilid%, harcoilid%) '**************************************************************************** 'This subroutine sets all required parameters for this module. ' 'Input: ' logfile$, path and name of the log file ' coilnsampperrev%, # voltage samples per revolutions ' coilnrevpermeas%, # revolutions per measurement ' coilfreqhpchan%, HP3457 channel for frequency measurements ' strcoilhpchan%, HP3457 channel for the strength measurement coil ' harcoilhpchan%, HP3457 channel for the harmonics measurement coil ' strcoilid%, strength coil ID number ' harcoilid%, harmonics coil ID number ' 'Zachary Wolf '11/5/95 '**************************************************************************** 'Put all parameters in a common area for later use logfileP$ = logfile$ coilnsampperrevP% = coilnsampperrev% coilnrevpermeasP% = coilnrevpermeas% coilfreqhpchanP% = coilfreqhpchan% strcoilhpchanP% = strcoilhpchan% harcoilhpchanP% = harcoilhpchan% strcoilidP% = strcoilid% harcoilidP% = harcoilid% END SUB