NTC temperature sensor going to A:D input. Topology is: (Vref or 3.3V) -> Series_resistor -> A:D_input -> NTC -> GND. Easy modification of NTC parameters w/o recompile of library
Diff: ntc.h
- Revision:
- 5:9655397ba539
- Parent:
- 4:5d0dfa665cba
- Child:
- 6:8e6bd0f9877b
--- a/ntc.h Sat Apr 08 01:23:02 2017 +0000 +++ b/ntc.h Tue Apr 11 20:30:30 2017 +0000 @@ -19,10 +19,12 @@ float ad_resolution; /*!< A:D resolution*/ int ntc_res; /*!< NTC resistance value at 25C*/ int ntc_tol; /*!< NTC initial tolerance %*/ + int ntc_beta_0050; /*!< NTC Beta, B0/50*/ int ntc_beta_2550; /*!< NTC Beta, B25/50*/ int ntc_beta_2580; /*!< NTC Beta, B25/80*/ int ntc_beta_2585; /*!< NTC Beta, B25/85*/ int ntc_beta_25100; /*!< NTC Beta, B25/100*/ + int ntc_beta_other; /*!< NTC Beta, other value vs temp*/ int ntc_beta_tol; /*!< NTC Beta tolerance %*/ int sres_res; /*!< Series resistor value*/ int sres_tol; /*!< Series resistor tolerance %*/ @@ -40,15 +42,17 @@ // muRata NCP15XH103J03RC 20000, // NTC resistance 3, // NTC initial tolerance + 0, // NTC B0/50, none 3300, // NTC B25/50 3322, // NTC B25/80 3333, // NTC B25/85 3344, // NTC B25/100 + 0, // NTC other Beta value 2, // NTC beta tolerance // 3.32k 1% 100ppm 4750, // Series resistor value - 5, // Series resistor tolerance - 300 // Series Resistor tempco ppm + 1, // Series resistor tolerance + 200 // Series Resistor tempco ppm }; /** NTC temperature A:D conversion @@ -95,10 +99,12 @@ * // muRata NCP15XH103J03RC * 10000, // NTC resistance * 5, // NTC initial tolerance + * 0, // NTC B0/50 (none) * 3380, // NTC B25/50 * 3428, // NTC B25/80 * 3434, // NTC B25/85 * 3355, // NTC B25/100 + * 0, // NTC other beta (none) * 1, // NTC beta tolerance * // 3.32k 1% 100ppm * 3320, // Series resistor value @@ -110,9 +116,9 @@ * * main() { * printf("\r\n\r\n-------------------------------------------\r\n"); - * printf("NTC Res: %5d B25/50: %4d B25/80: %4d B25/85: %4d B25/100: %4d SeriesR: %d\r\n", - * ntc.get_ntc_res(), ntc.get_ntc_beta_2550(), ntc.get_ntc_beta_2580(), ntc.get_ntc_beta_2585(), ntc.get_ntc_beta_25100(), - * ntc.get_series_res()); + * printf("NTC Res: %5d B0/50: %4d B25/50: %4d B25/80: %4d B25/85: %4d B25/100: %4d B_OTHER: %4d SeriesR: %d\r\n", + * ntc.get_ntc_res(), ntc.get_ntc_beta_0050(), ntc.get_ntc_beta_2550(), ntc.get_ntc_beta_2580(), ntc.get_ntc_beta_2585(), + * ntc.get_ntc_beta_25100(), ntc.get_ntc_beta_other(), ntc.get_series_res()); * uint16_t ad = ntc.read_ad_reg(); * printf("NTC A:D Val: %5d Volt A:D: %.6f NTC-R_now: %7.1f Temp: %+.2f\r\n", ad, * NTC_VREF / NTC_AD_RESOL * (float)ad, ntc.get_ntc_res_viaAD(ad), ntc.get_ntc_temp(NTC::B25_85, ad)); @@ -134,10 +140,12 @@ * **/ enum ntcBetaCurve { + B0_50, /*!< use B0/50 curve */ B25_50, /*!< use B25/50 curve */ B25_80, /*!< use B25/80 curve */ B25_85, /*!< use B25/85 curve */ B25_100, /*!< use B25/100 curve */ + B_OTHER, /*!< use other curve */ }; /** Configure gpio pin @@ -168,8 +176,14 @@ * @param none * @return beta */ + int get_ntc_beta_0050(); + + /** Get the NTC beta value B0/50 + * @param none + * @return beta + */ int get_ntc_beta_2550(); - + /** Get the NTC beta value B25/80 * @param none * @return beta @@ -187,6 +201,12 @@ * @return beta */ int get_ntc_beta_25100(); + + /** Get other NTC beta value + * @param none + * @return beta + */ + int get_ntc_beta_other(); /** Get the resistance value for the series resistor * @param none @@ -209,6 +229,7 @@ * @param din -> if missing or 0, read_ad_reg() value is used for calculation * @param din -> if != 0, then value of din is used for calculation * @return temperature of NTC + * @return -100 if NTC Beta selected = 0 */ float get_ntc_temp(int curve, uint16_t din = NULL);