/* ************************************************************* */ /* * CALIB.H * * Zachary Wolf * 12/13/02 */ #ifndef __CALIB_HEADER #define __CALIB_HEADER /* ************************************************************** */ /* SEMI-PERMANENT PARAMETERS */ #define CALIB_MAX_NUM_CHAR 100 #define CALIB_MAX_NUM_CALIB_PTS 500 #define CALIB_MAX_FIT_ORDER_PLUS_1 11 /* ************************************************************* */ /* STRUCTURE DEFINITIONS */ struct calib_data_struct { char probe_name[CALIB_MAX_NUM_CHAR]; /* name of the probe the calibration data is for */ int num_calib_pts; /* number of calibration points */ double meas_calib[CALIB_MAX_NUM_CALIB_PTS]; /* measured values from the probe for each calibration point */ double real_calib[CALIB_MAX_NUM_CALIB_PTS]; /* actual values from a reference for each calibration point */ }; struct calib_poly_fit_struct { char probe_name[CALIB_MAX_NUM_CHAR]; /* name of the probe the calibration data is for */ double meas_range_min; /* minimum of the range of applicability */ double meas_range_max; /* maximum of the range of applicability */ int fit_order; /* order of the polynomial fit to the calibration data */ double fit_coef[CALIB_MAX_FIT_ORDER_PLUS_1]; /* fit coefficients, actual = sum(fit_coef_n * meas_val^n) */ }; struct calib_steinhart_hart_struct { char probe_name[CALIB_MAX_NUM_CHAR]; /* name of the temperature probe the calibration data is for */ double meas_range_min; /* minimum of the resistance range of applicability */ double meas_range_max; /* maximum of the resistance range of applicability */ double a_coef; /* Steinhart-Hart A coefficient */ double b_coef; /* Steinhart-Hart B coefficient */ double c_coef; /* Steinhart-Hart C coefficient */ }; /* ************************************************************* */ /* PUBLIC FUNCTION DECLARATIONS */ void calib_get_calib_data(char calib_data_file_name[], struct calib_data_struct* calib_data); void calib_plot_calib_data(struct calib_data_struct calib_data); void calib_write_calib_data(char calib_data_file_name[], struct calib_data_struct calib_data); void calib_apply_calib_data_cubic_spline_interp(struct calib_data_struct calib_data, int num_meas, double meas_val[], double calib_out[]); void calib_plot_cubic_spline_interp(struct calib_data_struct calib_data); void calib_test_cubic_spline_interp(void); void calib_get_calib_poly_fit(char calib_poly_fit_file_name[], struct calib_poly_fit_struct* calib_poly_fit); void calib_apply_calib_poly_fit_interp(struct calib_poly_fit_struct calib_poly_fit, int num_meas, double meas_val[], double calib_out[]); void calib_plot_poly_fit_interp(struct calib_poly_fit_struct calib_poly_fit); void calib_calc_poly_fit_coef(struct calib_data_struct calib_data, struct calib_poly_fit_struct* calib_poly_fit); void calib_write_poly_fit_coef(char calib_poly_fit_file_name[], struct calib_poly_fit_struct calib_poly_fit); void calib_plot_poly_fit_residuals(struct calib_data_struct calib_data, struct calib_poly_fit_struct calib_poly_fit); void calib_test_poly_fit_interp(void); void calib_get_calib_steinhart_hart(char calib_steinhart_hart_file_name[], struct calib_steinhart_hart_struct* calib_steinhart_hart); void calib_apply_calib_steinhart_hart(struct calib_steinhart_hart_struct calib_steinhart_hart, double meas_res, double* temp); void calib_plot_steinhart_hart(struct calib_steinhart_hart_struct calib_steinhart_hart); void calib_test_steinhart_hart(void); void calib_generate_test_calib_data(int num_calib_pts, double meas_range_min, double meas_range_max, struct calib_data_struct* calib_data); /* ************************************************************** */ /* DONE */ #endif