|
NTC Thermistor Driver
API reference
|
Namespaces | |
| namespace | Constants |
| namespace | DefaultConfig |
| Default NTC configuration constants. | |
Classes | |
| struct | ntc_lookup_entry_t |
| Lookup table entry structure. More... | |
| struct | ntc_lookup_table_t |
| Lookup table structure. More... | |
Functions | |
| bool | ConvertResistanceToTemperatureBeta (float resistance_ohms, float resistance_at_25c, float beta_value, float *temperature_celsius) noexcept |
| Convert resistance to temperature using beta parameter. | |
| bool | ConvertTemperatureToResistanceBeta (float temperature_celsius, float resistance_at_25c, float beta_value, float *resistance_ohms) noexcept |
| Convert temperature to resistance using beta parameter. | |
| bool | ConvertResistanceToTemperatureSteinhartHart (float resistance_ohms, float coeff_a, float coeff_b, float coeff_c, float *temperature_celsius) noexcept |
| Convert resistance to temperature using Steinhart-Hart equation. | |
| bool | ConvertTemperatureToResistanceSteinhartHart (float temperature_celsius, float coeff_a, float coeff_b, float coeff_c, float *resistance_ohms) noexcept |
| Convert temperature to resistance using Steinhart-Hart equation. | |
| bool | ConvertResistanceToTemperatureDefault (float resistance_ohms, float *temperature_celsius) noexcept |
| Convert resistance to temperature using default Steinhart-Hart coefficients. | |
| bool | ConvertTemperatureToResistanceDefault (float temperature_celsius, float *resistance_ohms) noexcept |
| Convert temperature to resistance using default Steinhart-Hart coefficients. | |
| bool | CalculateThermistorResistance (float voltage_thermistor, float reference_voltage, float series_resistance, float *resistance_ohms) noexcept |
| Calculate thermistor resistance from voltage divider. | |
| bool | CalculateThermistorVoltage (float resistance_ohms, float reference_voltage, float series_resistance, float *voltage_thermistor) noexcept |
| Calculate voltage across thermistor from resistance. | |
| bool | CalculateVoltageDividerRatio (float resistance_ohms, float series_resistance, float *ratio) noexcept |
| Calculate voltage divider ratio. | |
| bool | ValidateResistance (float resistance_ohms, float min_resistance, float max_resistance) noexcept |
| Validate resistance value. | |
| bool | ValidateTemperature (float temperature_celsius, float min_temperature, float max_temperature) noexcept |
| Validate temperature value. | |
| bool | ValidateVoltage (float voltage_volts, float min_voltage, float max_voltage) noexcept |
| Validate voltage value. | |
| bool | ValidateBetaValue (float beta_value) noexcept |
| Validate beta value. | |
| bool | ValidateSteinhartHartCoefficients (float coeff_a, float coeff_b, float coeff_c) noexcept |
| Validate Steinhart-Hart coefficients. | |
| bool | CalculateBetaValue (float temp1_celsius, float resistance1_ohms, float temp2_celsius, float resistance2_ohms, float *beta_value) noexcept |
| Calculate beta value from two temperature-resistance pairs. | |
| bool | CalculateSteinhartHartCoefficients (float temp1_celsius, float resistance1_ohms, float temp2_celsius, float resistance2_ohms, float temp3_celsius, float resistance3_ohms, float *coeff_a, float *coeff_b, float *coeff_c) noexcept |
| Calculate Steinhart-Hart coefficients from three temperature-resistance pairs. | |
| bool | CalculateTemperatureAccuracy (float resistance_ohms, float resistance_at_25c, float beta_value, float resistance_tolerance, float beta_tolerance, float *accuracy_celsius) noexcept |
| Worst-case temperature error from the R25 and B tolerances. | |
| bool | CalculateTemperatureAccuracy (float resistance_ohms, float resistance_tolerance, float beta_tolerance, float *accuracy_celsius) noexcept |
| Temperature error estimate for the default part (R25 = 10 kOhm, B = 3435 K) | |
| bool | CalculateOptimalSeriesResistance (float thermistor_resistance_at_25c, float beta_value, float min_temperature, float max_temperature, float *optimal_resistance) noexcept |
| Calculate optimal series resistance for voltage divider. | |
| bool | CalculateOptimalSeriesResistance (float thermistor_resistance_at_25c, float min_temperature, float max_temperature, float *optimal_resistance) noexcept |
| Optimal series resistance assuming B = 3435 K. | |
| const ntc_lookup_table_t * | GetNtcLookupTable (int ntc_type) noexcept |
| Get lookup table for NTC type. | |
| bool | FindTemperatureFromLookupTable (const ntc_lookup_table_t *table, float resistance_ohms, float *temperature_celsius) noexcept |
| Find temperature using lookup table. | |
| bool | FindResistanceFromLookupTable (const ntc_lookup_table_t *table, float temperature_celsius, float *resistance_ohms) noexcept |
| Find resistance using lookup table. | |
| bool | InterpolateLookupEntries (const ntc_lookup_entry_t &entry1, const ntc_lookup_entry_t &entry2, float resistance_ohms, float *temperature_celsius) noexcept |
| Interpolate between two lookup table entries. | |
| bool | BinarySearchLookupTable (const ntc_lookup_table_t *table, float resistance_ohms, size_t *lower_index, size_t *upper_index) noexcept |
| Binary search in lookup table. | |
| bool | ValidateLookupTable (const ntc_lookup_table_t *table) noexcept |
| Validate lookup table. | |
| void | GetLookupTableStats (const ntc_lookup_table_t *table, float *min_resistance, float *max_resistance, float *min_temperature, float *max_temperature, size_t *entry_count) noexcept |
| Get lookup table statistics. | |
| const ntc_lookup_table_t * | GetNtcG163Jft103Ft1sLookupTable () noexcept |
| Get NTCG163JFT103FT1S lookup table. | |
| const ntc_lookup_table_t * | GetNtcG164Jf103Ft1sLookupTable () noexcept |
| Get NTCG164JF103FT1S lookup table. | |
| const ntc_lookup_table_t * | GetNtcG163Jf103Ft1sLookupTable () noexcept |
| Get NTCG163JF103FT1S lookup table. | |
|
noexcept |
Binary search in lookup table.
| table | Lookup table |
| resistance_ohms | Target resistance |
| lower_index | Pointer to store lower index |
| upper_index | Pointer to store upper index |
|
noexcept |
Calculate beta value from two temperature-resistance pairs.
| temp1_celsius | First temperature (°C) |
| resistance1_ohms | First resistance (ohms) |
| temp2_celsius | Second temperature (°C) |
| resistance2_ohms | Second resistance (ohms) |
| beta_value | Pointer to store calculated beta value |
|
noexcept |
Calculate optimal series resistance for voltage divider.
The geometric mean of R at the two ends of the range, from the Beta equation with the given R25 and B.
| thermistor_resistance_at_25c | Thermistor resistance at 25°C (ohms) |
| beta_value | B (K), e.g. ntc_config_t::beta_value |
| min_temperature | Minimum temperature (°C) |
| max_temperature | Maximum temperature (°C) |
| optimal_resistance | Pointer to store optimal series resistance (ohms) |
|
noexcept |
Optimal series resistance assuming B = 3435 K.
Calculate optimal series resistance for voltage divider.
| thermistor_resistance_at_25c | Thermistor resistance at 25°C (ohms) |
| min_temperature | Minimum temperature (°C) |
| max_temperature | Maximum temperature (°C) |
| optimal_resistance | Pointer to store optimal series resistance (ohms) |
|
noexcept |
Calculate Steinhart-Hart coefficients from three temperature-resistance pairs.
Solves 1/T = A + B*ln(R) + C*ln(R)^3 through the three points (in double precision), so the returned equation passes through all three. Pick points across the range you need, e.g. -40, 25 and 125 C from the datasheet table.
| temp1_celsius | First temperature (°C) |
| resistance1_ohms | First resistance (ohms) |
| temp2_celsius | Second temperature (°C) |
| resistance2_ohms | Second resistance (ohms) |
| temp3_celsius | Third temperature (°C) |
| resistance3_ohms | Third resistance (ohms) |
| coeff_a | Pointer to store coefficient A |
| coeff_b | Pointer to store coefficient B |
| coeff_c | Pointer to store coefficient C |
|
noexcept |
Worst-case temperature error from the R25 and B tolerances.
Converts R to T with the Beta equation, then adds the two worst-case errors: R25 tolerance, T^2/B * tol_R, and B tolerance, |T * (1 - T/T25)| * tol_B. For the NTCG163JF103FT1S (R25 +/- 1 %, B25/85 +/- 1 %) this reproduces the spec sheet's Table 3 Min/Max band: 0.26 C at 25 C, 1.1 C at 85 C.
| resistance_ohms | Thermistor resistance (ohms) |
| resistance_at_25c | R25 (ohms), e.g. ntc_config_t::resistance_at_25c |
| beta_value | B (K), e.g. ntc_config_t::beta_value |
| resistance_tolerance | R25 tolerance (fraction, 0.01 for 1 %) |
| beta_tolerance | B tolerance (fraction) |
| accuracy_celsius | Pointer to store the error bound (°C) |
|
noexcept |
Temperature error estimate for the default part (R25 = 10 kOhm, B = 3435 K)
Calculate temperature accuracy estimate.
| resistance_ohms | Thermistor resistance (ohms) |
| resistance_tolerance | Resistance tolerance (fraction) |
| beta_tolerance | Beta tolerance (fraction) |
| accuracy_celsius | Pointer to store accuracy estimate (°C) |
|
noexcept |
Calculate thermistor resistance from voltage divider.
| voltage_thermistor | Voltage across thermistor (V) |
| reference_voltage | Reference voltage (V) |
| series_resistance | Series resistance (ohms) |
| resistance_ohms | Pointer to store thermistor resistance (ohms) |
|
noexcept |
Calculate voltage across thermistor from resistance.
| resistance_ohms | Thermistor resistance (ohms) |
| reference_voltage | Reference voltage (V) |
| series_resistance | Series resistance (ohms) |
| voltage_thermistor | Pointer to store voltage across thermistor (V) |
|
noexcept |
Calculate voltage divider ratio.
| resistance_ohms | Thermistor resistance (ohms) |
| series_resistance | Series resistance (ohms) |
| ratio | Pointer to store voltage ratio |
|
noexcept |
Convert resistance to temperature using beta parameter.
Uses the beta parameter equation to calculate temperature from resistance. This is a simplified model that assumes a linear relationship in the temperature-resistance curve around the reference temperature.
| resistance_ohms | Thermistor resistance (ohms) |
| resistance_at_25c | Resistance at 25°C (ohms) |
| beta_value | Beta value (K), typically 3000-4000K for NTC thermistors |
| temperature_celsius | Pointer to store temperature (°C) |
|
noexcept |
Convert resistance to temperature using default Steinhart-Hart coefficients.
The defaults (STEINHART_HART_A_/B_/C_) are fitted to the TDK NTCG163JF103FT1S; use ConvertResistanceToTemperatureSteinhartHart() with your own coefficients for any other part.
| resistance_ohms | Thermistor resistance (ohms) |
| temperature_celsius | Pointer to store temperature (°C) |
|
noexcept |
Convert resistance to temperature using Steinhart-Hart equation.
Uses the Steinhart-Hart equation for high-accuracy temperature calculation. This method provides better accuracy across a wider temperature range compared to the beta parameter method.
The Steinhart-Hart equation: 1/T = A + B*ln(R) + C*ln(R)³
| resistance_ohms | Thermistor resistance (ohms) |
| coeff_a | Steinhart-Hart coefficient A (about 0.9e-3 for a 10 kOhm part) |
| coeff_b | Steinhart-Hart coefficient B (about 2.5e-4) |
| coeff_c | Steinhart-Hart coefficient C (about 1e-7 to 2e-7) |
| temperature_celsius | Pointer to store temperature (°C) |
|
noexcept |
Convert temperature to resistance using beta parameter.
| temperature_celsius | Temperature (°C) |
| resistance_at_25c | Resistance at 25°C (ohms) |
| beta_value | Beta value (K) |
| resistance_ohms | Pointer to store resistance (ohms) |
|
noexcept |
Convert temperature to resistance using default Steinhart-Hart coefficients.
| temperature_celsius | Temperature (°C) |
| resistance_ohms | Pointer to store resistance (ohms) |
|
noexcept |
Convert temperature to resistance using Steinhart-Hart equation.
Solves C*x^3 + B*x + (A - 1/T) = 0 for x = ln(R) exactly (the C term included), so it is the inverse of ConvertResistanceToTemperatureSteinhartHart().
| temperature_celsius | Temperature (°C) |
| coeff_a | Steinhart-Hart coefficient A |
| coeff_b | Steinhart-Hart coefficient B |
| coeff_c | Steinhart-Hart coefficient C |
| resistance_ohms | Pointer to store resistance (ohms) |
|
noexcept |
Find resistance using lookup table.
| table | Lookup table |
| temperature_celsius | Temperature value |
| resistance_ohms | Pointer to store resistance |
|
noexcept |
Find temperature using lookup table.
| table | Lookup table |
| resistance_ohms | Resistance value |
| temperature_celsius | Pointer to store temperature |
|
noexcept |
Get lookup table statistics.
| table | Lookup table |
| min_resistance | Pointer to store minimum resistance |
| max_resistance | Pointer to store maximum resistance |
| min_temperature | Pointer to store minimum temperature |
| max_temperature | Pointer to store maximum temperature |
| entry_count | Pointer to store entry count |
|
noexcept |
Get NTCG163JF103FT1S lookup table.
|
noexcept |
Get NTCG163JFT103FT1S lookup table.
|
noexcept |
Get NTCG164JF103FT1S lookup table.
|
noexcept |
Get lookup table for NTC type.
Retrieves the pre-calculated lookup table for a specific NTC thermistor type. Lookup tables are optimized for fast temperature conversion with minimal computational overhead.
| ntc_type | NTC thermistor type (e.g., NtcType::NtcG163Jf103Ft1S) |
|
noexcept |
Interpolate between two lookup table entries.
| entry1 | First entry |
| entry2 | Second entry |
| resistance_ohms | Target resistance |
| temperature_celsius | Pointer to store interpolated temperature |
|
noexcept |
Validate beta value.
| beta_value | Beta value to validate |
|
noexcept |
Validate lookup table.
| table | Lookup table to validate |
|
noexcept |
Validate resistance value.
| resistance_ohms | Resistance value to validate |
| min_resistance | Minimum valid resistance |
| max_resistance | Maximum valid resistance |
|
noexcept |
Validate Steinhart-Hart coefficients.
Accepts finite coefficients with |A| <= 1e-2, 1e-4 <= B <= 1e-3 and |C| <= 1e-6, which covers NTC fits from about 1 kOhm to 1 MOhm (this part's C is 1.9e-7).
| coeff_a | Coefficient A |
| coeff_b | Coefficient B |
| coeff_c | Coefficient C |
|
noexcept |
Validate temperature value.
| temperature_celsius | Temperature value to validate |
| min_temperature | Minimum valid temperature |
| max_temperature | Maximum valid temperature |
|
noexcept |
Validate voltage value.
| voltage_volts | Voltage value to validate |
| min_voltage | Minimum valid voltage |
| max_voltage | Maximum valid voltage |