/* ************************************************************** */ /* * Module VIBWIRE * This module contains functions for making measurements with * a vibrating wire system. It assumes a signal generator and * two lock-in amplifiers, one measuring the wire x motion and * the other measuring the wire y motion. * * Zachary Wolf * 8/29/05 */ /* ************************************************************** */ /* INCLUDES */ #include #include #include #include #include #include "vibwire.h" #include "vibwireui.h" #include "hp33220.h" #include "sr830.h" /* ************************************************************** */ /* PRIVATE FUNCTIONS */ void vibwire_message(char* msg); void vibwire_error(char* msg); void vibwire_log_device_type(enum vibwire_device_type_enum device_type); void vibwire_log_set_freq(double freq); void vibwire_log_set_ampl(double ampl); void vibwire_log_get_xdet_vxrms(double vxrms); void vibwire_log_get_xdet_vyrms(double vyrms); void vibwire_log_get_ydet_vxrms(double vxrms); void vibwire_log_get_ydet_vyrms(double vyrms); void vibwire_log_find_res_freq_coarse(double coarse_res_freq); void vibwire_log_find_res_freq_fine(double fine_res_freq); /* ************************************************************** */ /* PRIVATE GLOBAL VARIABLES */ static int hp33220_ID; static int sr830x_ID; static int sr830y_ID; static char cmd[VIBWIRE_MAX_NUM_CHAR]; static char msg[VIBWIRE_MAX_NUM_CHAR]; static double nom_fund_freq; /* ************************************************************** */ /* PRIVATE PARAMETERS */ static char log_file[100]; static struct vibwire_param_struct vibwire_param; /* ************************************************************** */ /* PUBLIC FUNCTIONS */ /* ************************************************************** */ /* * vibwire_init * This function opens the device, queries for ID, and * initializes the device to a known state. * * Zachary Wolf * 8/29/05 */ void vibwire_init(char log_file_in[], struct vibwire_param_struct vibwire_param_in) { /* Declare variables */ int i; /* Save the module parameters */ strcpy(log_file, log_file_in); vibwire_param = vibwire_param_in; /* Initialize the appropriate devices */ if (vibwire_param.device_type == VIBWIRE_HP33220_SR830XY) { hp33220_init(vibwire_param.board_addr, vibwire_param.hp33220_addr, &hp33220_ID); sr830_init(vibwire_param.board_addr, vibwire_param.sr830x_addr, &sr830x_ID); sr830_init(vibwire_param.board_addr, vibwire_param.sr830y_addr, &sr830y_ID); /* Setup function generator */ hp33220_output_sine(hp33220_ID, VIBWIRE_SIGN_AMPL, vibwire_param.nom_fund_freq*2); /* Initial setup */ /* Setup x lock-in */ sr830_set_ext_ttl_trig(sr830x_ID); /* Use sync out from function generator */ sr830_set_time_constant(sr830x_ID, 9); /* Use a 300 ms time constant */ sr830_set_sensitivity(sr830x_ID, 26); /* Use 1 V initial sensitivity */ sr830_set_reserve_mode(sr830x_ID, 1); /* Use normal reserve mode */ sr830_set_har_num(sr830x_ID, 1); /* Use first harmonic for all measurements, change generator freq */ /* Setup y lock-in */ sr830_set_ext_ttl_trig(sr830y_ID); /* Use sync out from function generator */ sr830_set_time_constant(sr830y_ID, 9); /* Use a 300 ms time constant */ sr830_set_sensitivity(sr830y_ID, 26); /* Use 1 V initial sensitivity */ sr830_set_reserve_mode(sr830y_ID, 1); /* Use normal reserve mode */ sr830_set_har_num(sr830y_ID, 1); /* Use first harmonic for all measurements, change generator freq */ } else if (vibwire_param.device_type == VIBWIRE_NONE_NONE); else vibwire_error("Unknown device type."); /* Set the nominal fundamental frequency, global */ nom_fund_freq = vibwire_param.nom_fund_freq; /* Log the device type */ vibwire_log_device_type(vibwire_param.device_type); /* Done */ return; } /* ************************************************************** */ /* * vibwire_set_freq * This function sets the function generator frequency. * * Input: * freq, desired frequency (Hz) * * Zachary Wolf * 8/29/05 */ void vibwire_set_freq(double freq) { /* Have the function generator output the desired frequency */ if (vibwire_param.device_type == VIBWIRE_HP33220_SR830XY) { hp33220_set_freq(hp33220_ID, freq); } else if (vibwire_param.device_type == VIBWIRE_NONE_NONE); else vibwire_error("Unknown device type."); /* Log the frequency */ vibwire_log_set_freq(freq); /* Done */ return; } /* ************************************************************** */ /* * vibwire_set_ampl * This function sets the function generator amplitude. * * Input: * ampl, desired amplitude (V_0p) * * Zachary Wolf * 8/29/05 */ void vibwire_set_ampl(double ampl) { /* Have the function generator output the desired amplitude */ if (vibwire_param.device_type == VIBWIRE_HP33220_SR830XY) { hp33220_set_ampl(hp33220_ID, ampl); } else if (vibwire_param.device_type == VIBWIRE_NONE_NONE); else vibwire_error("Unknown device type."); /* Log the amplitude */ vibwire_log_set_ampl(ampl); /* Done */ return; } /* ************************************************************** */ /* * vibwire_get_freq * This function gets the function generator frequency. * * Output: * freq, function generator frequency (Hz) * * Zachary Wolf * 2/09/06 */ void vibwire_get_freq(double* freq) { /* Get the function generator output frequency */ if (vibwire_param.device_type == VIBWIRE_HP33220_SR830XY) { hp33220_get_freq(hp33220_ID, freq); } else if (vibwire_param.device_type == VIBWIRE_NONE_NONE) { *freq = 0.; } else vibwire_error("Unknown device type."); /* Done */ return; } /* ************************************************************** */ /* * vibwire_get_xdet_vxrms * This function gets the in-phase voltage from the x wire motion detector. * * Output: * vxrms, in-phase rms voltage (Vrms) * * Zachary Wolf * 8/29/05 */ void vibwire_get_xdet_vxrms(double* vxrms) { /* Get the in-phase voltage */ if (vibwire_param.device_type == VIBWIRE_HP33220_SR830XY) { sr830_get_vxrms(sr830x_ID, vxrms); } else if (vibwire_param.device_type == VIBWIRE_NONE_NONE) { *vxrms = 0.; } else vibwire_error("Unknown device type."); /* Log the voltage */ vibwire_log_get_xdet_vxrms(*vxrms); /* Done */ return; } /* ************************************************************** */ /* * vibwire_get_xdet_vyrms * This function gets the out-of-phase voltage from the x wire motion detector. * * Output: * vyrms, out-of-phase rms voltage (Vrms) * * Zachary Wolf * 8/29/05 */ void vibwire_get_xdet_vyrms(double* vyrms) { /* Get the out-of-phase voltage */ if (vibwire_param.device_type == VIBWIRE_HP33220_SR830XY) { sr830_get_vyrms(sr830x_ID, vyrms); } else if (vibwire_param.device_type == VIBWIRE_NONE_NONE) { *vyrms = 0.; } else vibwire_error("Unknown device type."); /* Log the voltage */ vibwire_log_get_xdet_vyrms(*vyrms); /* Done */ return; } /* ************************************************************** */ /* * vibwire_get_ydet_vxrms * This function gets the in-phase voltage from the y wire motion detector. * * Output: * vxrms, in-phase rms voltage (Vrms) * * Zachary Wolf * 8/29/05 */ void vibwire_get_ydet_vxrms(double* vxrms) { /* Get the in-phase voltage */ if (vibwire_param.device_type == VIBWIRE_HP33220_SR830XY) { sr830_get_vxrms(sr830y_ID, vxrms); } else if (vibwire_param.device_type == VIBWIRE_NONE_NONE) { *vxrms = 0.; } else vibwire_error("Unknown device type."); /* Log the voltage */ vibwire_log_get_ydet_vxrms(*vxrms); /* Done */ return; } /* ************************************************************** */ /* * vibwire_get_ydet_vyrms * This function gets the out-of-phase voltage from the y wire motion detector. * * Output: * vyrms, out-of-phase rms voltage (Vrms) * * Zachary Wolf * 8/29/05 */ void vibwire_get_ydet_vyrms(double* vyrms) { /* Get the out-of-phase voltage */ if (vibwire_param.device_type == VIBWIRE_HP33220_SR830XY) { sr830_get_vyrms(sr830y_ID, vyrms); } else if (vibwire_param.device_type == VIBWIRE_NONE_NONE) { *vyrms = 0.; } else vibwire_error("Unknown device type."); /* Log the voltage */ vibwire_log_get_ydet_vyrms(*vyrms); /* Done */ return; } /* ************************************************************** */ /* * vibwire_xdet_automeasure * This function has the lock-in perform an automeasure operation. * * Zachary Wolf * 8/29/05 */ void vibwire_xdet_automeasure(void) { /* Automeasure */ if (vibwire_param.device_type == VIBWIRE_HP33220_SR830XY) { sr830_automeasure(sr830x_ID); } else if (vibwire_param.device_type == VIBWIRE_NONE_NONE); else vibwire_error("Unknown device type."); /* Done */ return; } /* ************************************************************** */ /* * vibwire_ydet_automeasure * This function has the lock-in perform an automeasure operation. * * Zachary Wolf * 8/29/05 */ void vibwire_ydet_automeasure(void) { /* Automeasure */ if (vibwire_param.device_type == VIBWIRE_HP33220_SR830XY) { sr830_automeasure(sr830y_ID); } else if (vibwire_param.device_type == VIBWIRE_NONE_NONE); else vibwire_error("Unknown device type."); /* Done */ return; } /* ************************************************************** */ /* * vibwire_xdet_set_low_sensitivity * This function sets the lock-in to low sensitivity so the * input is not overloaded. * * Zachary Wolf * 8/29/05 */ void vibwire_xdet_set_low_sensitivity(void) { /* Set to low sensitivity */ if (vibwire_param.device_type == VIBWIRE_HP33220_SR830XY) { sr830_set_sensitivity(sr830x_ID, 23); /* Use 100 mV sensitivity */ sr830_set_reserve_mode(sr830x_ID, 1); /* Use normal reserve mode */ } else if (vibwire_param.device_type == VIBWIRE_NONE_NONE); else vibwire_error("Unknown device type."); /* Done */ return; } /* ************************************************************** */ /* * vibwire_ydet_set_low_sensitivity * This function sets the lock-in to low sensitivity so the * input is not overloaded. * * Zachary Wolf * 8/29/05 */ void vibwire_ydet_set_low_sensitivity(void) { /* Set to low sensitivity */ if (vibwire_param.device_type == VIBWIRE_HP33220_SR830XY) { sr830_set_sensitivity(sr830y_ID, 23); /* Use 100 mV sensitivity */ sr830_set_reserve_mode(sr830y_ID, 1); /* Use normal reserve mode */ } else if (vibwire_param.device_type == VIBWIRE_NONE_NONE); else vibwire_error("Unknown device type."); /* Done */ return; } /* ************************************************************** */ /* * vibwire_xdet_lower_sensitivity * This function sets the lock-in to a lower sensitivity so the * input is not overloaded. * * Zachary Wolf * 8/29/05 */ void vibwire_xdet_lower_sensitivity(void) { /* Lower sensitivity */ if (vibwire_param.device_type == VIBWIRE_HP33220_SR830XY) { sr830_lower_sensitivity(sr830x_ID); } else if (vibwire_param.device_type == VIBWIRE_NONE_NONE); else vibwire_error("Unknown device type."); /* Done */ return; } /* ************************************************************** */ /* * vibwire_xdet_lower_sensitivity * This function sets the lock-in to a lower sensitivity so the * input is not overloaded. * * Zachary Wolf * 8/29/05 */ void vibwire_ydet_lower_sensitivity(void) { /* Lower sensitivity */ if (vibwire_param.device_type == VIBWIRE_HP33220_SR830XY) { sr830_lower_sensitivity(sr830y_ID); } else if (vibwire_param.device_type == VIBWIRE_NONE_NONE); else vibwire_error("Unknown device type."); /* Done */ return; } /* ************************************************************** */ /* * vibwire_xdet_clear_errors * This function has the lock-in clear its errors. It is used after * known error conditions, such as a reference frequency change. * * Zachary Wolf * 8/29/05 */ void vibwire_xdet_clear_errors(void) { /* Clear errors */ if (vibwire_param.device_type == VIBWIRE_HP33220_SR830XY) { sr830_clear_errors(sr830x_ID); } else if (vibwire_param.device_type == VIBWIRE_NONE_NONE); else vibwire_error("Unknown device type."); /* Done */ return; } /* ************************************************************** */ /* * vibwire_ydet_clear_errors * This function has the lock-in clear its errors. It is used after * known error conditions, such as a reference frequency change. * * Zachary Wolf * 8/29/05 */ void vibwire_ydet_clear_errors(void) { /* Clear errors */ if (vibwire_param.device_type == VIBWIRE_HP33220_SR830XY) { sr830_clear_errors(sr830y_ID); } else if (vibwire_param.device_type == VIBWIRE_NONE_NONE); else vibwire_error("Unknown device type."); /* Done */ return; } /* ************************************************************** */ /* * vibwire_find_res_freq_coarse * This function changes the frequency of the current in the wire * in evenly spaced steps. At each frequency, it measures the voltage * from the given wire motion detector. The resonant frequency is found * where the in-phase voltage component goes to zero. * * Input: * wire_vib_det, wire vibration detector, 'x' or 'y' * har_num, number of the harmonic of the wire vibration frequency * * Output: * coarse_res_freq, resonant frequency, rough estimate (Hz) * * Zachary Wolf * 8/29/05 */ void vibwire_find_res_freq_coarse(char wire_vib_det, int har_num, double* coarse_res_freq, int num_freq) { /* Declare variables */ double xdet_vxrms, xdet_vyrms; double ydet_vxrms, ydet_vyrms; double vxrms[VIBWIRE_EXTRA_COARSE_NUM_FREQ]; double vyrms[VIBWIRE_EXTRA_COARSE_NUM_FREQ]; double freq[VIBWIRE_EXTRA_COARSE_NUM_FREQ]; int i; double max; int imax; double f_fit[5], v_fit[5], z[5]; double coef[3]; double mse; double f_res_vy, vy_res; double f_res_vx; /* Check input parameters */ if (wire_vib_det != 'x' && wire_vib_det != 'y') { Fmt(msg, "%s 5) { Fmt(msg, "%s= 5"); return; } //mmm Try to set the reserve to LOW. if(wire_vib_det == 'x') sr830_set_reserve_mode(sr830x_ID, 2); else sr830_set_reserve_mode(sr830y_ID, 2); /* Set up the array of test frequencies */ for (i = 0; i < num_freq; i++) { freq[i] = nom_fund_freq * har_num + (i - (num_freq - 1) / 2.) * VIBWIRE_COARSE_STEP_SIZE; } /* Loop over the frequencies */ for (i = 0; i < num_freq; i++) { /* Set the frequency */ vibwire_set_freq(freq[i]); Delay(2.5); // mmm It would be best to base the delay on the time constant, which could be in a define /* Clear errors */ vibwire_xdet_clear_errors(); vibwire_ydet_clear_errors(); /* Select and measure the necessary voltages */ if (wire_vib_det == 'x') { vibwire_get_xdet_vxrms(&xdet_vxrms); vibwire_get_xdet_vyrms(&xdet_vyrms); vxrms[i] = xdet_vxrms; vyrms[i] = xdet_vyrms; } else { vibwire_get_ydet_vxrms(&ydet_vxrms); vibwire_get_ydet_vyrms(&ydet_vyrms); vxrms[i] = ydet_vxrms; vyrms[i] = ydet_vyrms; } /* Plot the measurement */ vibwireui_plot_vx_samp(freq[i], vxrms[i]); vibwireui_plot_vy_samp(freq[i], vyrms[i]); } /* Fit the Vy data to find a maximum */ max = -1.; for (i = 0; i < num_freq; i++) { if (fabs(vyrms[i]) > max) { max = fabs(vyrms[i]); imax = i; } } if (imax < 2) imax = 2; if (imax > num_freq - 3) imax = num_freq - 3; for (i = 0; i < 5; i++) { f_fit[i] = freq[imax + i - 2]; v_fit[i] = vyrms[imax + i - 2]; } PolyFit(f_fit, v_fit, 5, 2, z, coef, &mse); f_res_vy = -coef[1] / (2. * coef[2]); vy_res = coef[0] + coef[1] * f_res_vy + coef[2] * pow(f_res_vy, 2); /* Interpolate to find the frequency where vxrms = 0 */ f_res_vx = 0.; for (i = 0; i < num_freq - 1; i++) { if ((vxrms[i] <= 0. && vxrms[i+1] > 0.) || (vxrms[i] >= 0. && vxrms[i+1] < 0.)) { f_res_vx = freq[i] + ((freq[i+1] - freq[i]) / (vxrms[i+1] - vxrms[i])) * (- vxrms[i]); break; } } /* Check that vxrms crosses zero and the resonance frequency is above 1 Hz */ if (f_res_vx == 0. || f_res_vy < 1) { vibwire_error("Unable to find coarse resonant frequency."); return; } /* Set the frequency to the resonant frequency */ //printf("Setting the frequency to the coarse resonant frequency...\n"); vibwire_set_freq(f_res_vy); Delay(2.5); /* Setup the lock-in to perform measurements at the resonant frequency */ //vibwire_xdet_automeasure(); //vibwire_ydet_automeasure(); /* Reduce the sensitivity a little */ //vibwire_xdet_lower_sensitivity(); //vibwire_ydet_lower_sensitivity(); /* Plot a point at the resonant frequency */ vibwireui_plot_vx_res_coarse(f_res_vx, 0.); vibwireui_plot_vy_res_coarse(f_res_vy, vy_res); /* Log the result */ vibwire_log_find_res_freq_coarse(f_res_vy); /* Update the nominal fundamental frequency, global */ nom_fund_freq = f_res_vy / har_num; /* Return the coarse resonant frequency */ *coarse_res_freq = f_res_vy; /* Done */ return; } /* ************************************************************** */ /* * vibwire_find_res_freq_fine * This function changes the frequency of the current in the wire * in evenly spaced steps. At each frequency, it measures the voltage * from the given wire motion detector. The resonant frequency is found * where the in-phase voltage component goes to zero. * * Input: * wire_vib_det, wire vibration detector, 'x' or 'y' * coarse_res_freq, resonant frequency, rough estimate (Hz) * * Output: * fine_res_freq, resonant frequency (Hz) * * Zachary Wolf * 8/29/05 */ void vibwire_find_res_freq_fine(char wire_vib_det, double coarse_res_freq, double* fine_res_freq) { /* Declare variables */ double xdet_vxrms, xdet_vyrms; double ydet_vxrms, ydet_vyrms; double vxrms[VIBWIRE_FINE_NUM_FREQ]; double vyrms[VIBWIRE_FINE_NUM_FREQ]; double freq[VIBWIRE_FINE_NUM_FREQ]; int i; double max, min; int imax, imin; double z[VIBWIRE_FINE_NUM_FREQ]; double slope, intercept, mse; double f_res_vx; /* Check input parameters */ if (wire_vib_det != 'x' && wire_vib_det != 'y') { Fmt(msg, "%s 0.) f_res_vx = coarse_res_freq; /* Plot a point at the resonant frequency */ vibwireui_plot_vx_res_fine(f_res_vx, 0.); /* Set the frequency to the resonant frequency */ printf("Setting the frequency to the fine resonant frequency...\n"); vibwire_set_freq(f_res_vx); Delay(2.5); /* Log the result */ vibwire_log_find_res_freq_fine(f_res_vx); /* Return the fine resonant frequency */ *fine_res_freq = f_res_vx; /* Done */ return; } /* ************************************************************** */ /* * vibwire_output_on * This function turns on the generator output. * * Michael Levashov * 06/13/07 */ void vibwire_output_on(void) { /* Have the function generator output the desired amplitude */ if (vibwire_param.device_type == VIBWIRE_HP33220_SR830XY) { hp33220_output_on(hp33220_ID); } else if (vibwire_param.device_type == VIBWIRE_NONE_NONE); else vibwire_error("Unknown device type."); /* Done */ return; } /* ************************************************************** */ /* * vibwire_output_off * This function turns off the generator output. * * Michael Levashov * 06/13/07 */ void vibwire_output_off(void) { /* Have the function generator output the desired amplitude */ if (vibwire_param.device_type == VIBWIRE_HP33220_SR830XY) { hp33220_output_off(hp33220_ID); printf("HP33220 output off"); } else if (vibwire_param.device_type == VIBWIRE_NONE_NONE); else vibwire_error("Unknown device type."); /* Done */ return; } /* ************************************************************** */ /* * vibwire_exit * This function configures the VIBWIRE for program exit and * closes the devices. * * Zachary Wolf * 8/29/05 */ void vibwire_exit(void) { /* Exit all devices */ if (vibwire_param.device_type == VIBWIRE_HP33220_SR830XY) { hp33220_exit(hp33220_ID); sr830_exit(sr830x_ID); sr830_exit(sr830y_ID); } else if (vibwire_param.device_type == VIBWIRE_NONE_NONE); else vibwire_error("Unknown device type."); /* Done */ return; } /* ************************************************************** */ /* PRIVATE FUNCTIONS */ /* ************************************************************** */ /* * vibwire_message * This function handles messages about the VIBWIRE. * * Input: * message, string to display in standard I/O * * Zachary Wolf * 12/20/99 */ void vibwire_message(char* message) { /* Print the message */ printf("%s\n", message); /* Done */ return; } /* ************************************************************** */ /* * vibwire_error * This function handles error messages for the VIBWIRE. * * Input: * message, string to display in standard I/O * * Zachary Wolf * 12/20/99 */ void vibwire_error(char* message) { /* Declare variables */ char buf[80]; /* Notify the operator of the error */ printf("\nVIBWIRE ERROR: %s\n", message); Beep(); Delay(.5); Beep(); /* Terminate the program if the operator desires */ printf("Press ENTER to continue.\nPress any key then ENTER to terminate program.\n"); fgets(buf, 80, stdin); if (buf[0] == '\n') return; else exit(0); } /* ************************************************************** */ /* * vibwire_log_device_type * This function logs the types of devices being used. * * Input: * device_type, types of devices * * Zachary Wolf * 8/29/05 */ void vibwire_log_device_type(enum vibwire_device_type_enum device_type) { /* Declare variables */ FILE* file_ptr; char type[50]; /* Put the device type in a string */ if (device_type == VIBWIRE_HP33220_SR830XY) strcpy(type, "Signal Generator = HP33220, LIA = SR830"); else if (device_type == VIBWIRE_NONE_NONE) strcpy(type, "Signal Generator = NONE, LIA = NONE"); else vibwire_error("Unknown device type in log device function."); /* Open the log file */ file_ptr = fopen(log_file, "a"); if (file_ptr == NULL) { vibwire_message("Unable to open log file"); return; } /* Write the types of devices to the log file */ fprintf(file_ptr, "%s Wirpos Devices: %s\n", TimeStr(), type); /* Close the log file */ fclose(file_ptr); /* Done */ return; } /* ************************************************************** */ /* * vibwire_log_set_freq * This function logs the frequency from the function generator. * * Input: * freq, function generator frequency (Hz) * * Zachary Wolf * 8/29/05 */ void vibwire_log_set_freq(double freq) { /* Declare variables */ FILE* file_ptr; /* Open the log file */ file_ptr = fopen(log_file, "a"); if (file_ptr == NULL) { vibwire_message("Unable to open log file"); return; } /* Write the frequency to the log file */ fprintf(file_ptr, "%s Function generator frequency set to %f Hz\n", TimeStr(), freq); /* Close the log file */ fclose(file_ptr); /* Done */ return; } /* ************************************************************** */ /* * vibwire_log_set_ampl * This function logs the signal amplitude from the function generator. * * Input: * ampl, function generator amplitude (V_0p) * * Zachary Wolf * 8/29/05 */ void vibwire_log_set_ampl(double ampl) { /* Declare variables */ FILE* file_ptr; /* Open the log file */ file_ptr = fopen(log_file, "a"); if (file_ptr == NULL) { vibwire_message("Unable to open log file"); return; } /* Write the amplitude to the log file */ fprintf(file_ptr, "%s Function generator amplitude set to %f V_0p\n", TimeStr(), ampl); /* Close the log file */ fclose(file_ptr); /* Done */ return; } /* ************************************************************** */ /* * vibwire_log_get_xdet_vxrms * This function logs the measured in-phase signal from the wire * x motion detector. * * Input: * vxrms, in-phase rms voltage (V_rms) * * Zachary Wolf * 8/29/05 */ void vibwire_log_get_xdet_vxrms(double vxrms) { /* Declare variables */ FILE* file_ptr; /* Open the log file */ file_ptr = fopen(log_file, "a"); if (file_ptr == NULL) { vibwire_message("Unable to open log file"); return; } /* Write the voltage to the log file */ fprintf(file_ptr, "%s X detector, Vx_rms = %f V_rms\n", TimeStr(), vxrms); /* Close the log file */ fclose(file_ptr); /* Done */ return; } /* ************************************************************** */ /* * vibwire_log_get_xdet_vyrms * This function logs the measured out-of-phase signal from the wire * x motion detector. * * Input: * vyrms, out-of-phase rms voltage (V_rms) * * Zachary Wolf * 8/29/05 */ void vibwire_log_get_xdet_vyrms(double vyrms) { /* Declare variables */ FILE* file_ptr; /* Open the log file */ file_ptr = fopen(log_file, "a"); if (file_ptr == NULL) { vibwire_message("Unable to open log file"); return; } /* Write the voltage to the log file */ fprintf(file_ptr, "%s X detector, Vy_rms = %f V_rms\n", TimeStr(), vyrms); /* Close the log file */ fclose(file_ptr); /* Done */ return; } /* ************************************************************** */ /* * vibwire_log_get_ydet_vxrms * This function logs the measured in-phase signal from the wire * y motion detector. * * Input: * vxrms, in-phase rms voltage (V_rms) * * Zachary Wolf * 8/29/05 */ void vibwire_log_get_ydet_vxrms(double vxrms) { /* Declare variables */ FILE* file_ptr; /* Open the log file */ file_ptr = fopen(log_file, "a"); if (file_ptr == NULL) { vibwire_message("Unable to open log file"); return; } /* Write the voltage to the log file */ fprintf(file_ptr, "%s Y detector, Vx_rms = %f V_rms\n", TimeStr(), vxrms); /* Close the log file */ fclose(file_ptr); /* Done */ return; } /* ************************************************************** */ /* * vibwire_log_get_ydet_vyrms * This function logs the measured out-of-phase signal from the wire * y motion detector. * * Input: * vyrms, out-of-phase rms voltage (V_rms) * * Zachary Wolf * 8/29/05 */ void vibwire_log_get_ydet_vyrms(double vyrms) { /* Declare variables */ FILE* file_ptr; /* Open the log file */ file_ptr = fopen(log_file, "a"); if (file_ptr == NULL) { vibwire_message("Unable to open log file"); return; } /* Write the voltage to the log file */ fprintf(file_ptr, "%s Y detector, Vy_rms = %f V_rms\n", TimeStr(), vyrms); /* Close the log file */ fclose(file_ptr); /* Done */ return; } /* ************************************************************** */ /* * vibwire_log_find_res_freq_coarse * This function logs the measured coarse resonant frequency. * * Input: * coarse_res_freq, resonant frequency, coarse measurement (Hz) * * Zachary Wolf * 8/29/05 */ void vibwire_log_find_res_freq_coarse(double coarse_res_freq) { /* Declare variables */ FILE* file_ptr; /* Open the log file */ file_ptr = fopen(log_file, "a"); if (file_ptr == NULL) { vibwire_message("Unable to open log file"); return; } /* Write the resonant frequency to the log file */ fprintf(file_ptr, "%s Coarse resonant frequency, f = %f Hz\n", TimeStr(), coarse_res_freq); /* Close the log file */ fclose(file_ptr); /* Done */ return; } /* ************************************************************** */ /* * vibwire_log_find_res_freq_fine * This function logs the measured resonant frequency. * * Input: * fine_res_freq, resonant frequency, fine measurement (Hz) * * Zachary Wolf * 8/29/05 */ void vibwire_log_find_res_freq_fine(double fine_res_freq) { /* Declare variables */ FILE* file_ptr; /* Open the log file */ file_ptr = fopen(log_file, "a"); if (file_ptr == NULL) { vibwire_message("Unable to open log file"); return; } /* Write the resonant frequency to the log file */ fprintf(file_ptr, "%s Fine resonant frequency, f = %f Hz\n", TimeStr(), fine_res_freq); /* Close the log file */ fclose(file_ptr); /* Done */ return; }