132 #if defined(TS_EPCOS_B57861S0103F045_POSITION_IN_RESISTOR_DIVIDER_IS_R_1) && \
133 (TS_EPCOS_B57861S0103F045_POSITION_IN_RESISTOR_DIVIDER_IS_R_1 == true)
134 #define TS_EPCOS_B57861S0103F045_ADC_VOLTAGE_V_MAX_V \
136 (TS_EPCOS_B57861S0103F045_RESISTOR_DIVIDER_SUPPLY_VOLTAGE_V * \
137 ts_b57861s0103f045Lut[ts_b57861s0103f045LutSize - 1].resistance_Ohm) / \
138 (ts_b57861s0103f045Lut[ts_b57861s0103f045LutSize - 1].resistance_Ohm + \
139 TS_EPCOS_B57861S0103F045_RESISTOR_DIVIDER_RESISTANCE_R_1_R_2_Ohm))
140 #define TS_EPCOS_B57861S0103F045_ADC_VOLTAGE_V_MIN_V \
142 (TS_EPCOS_B57861S0103F045_RESISTOR_DIVIDER_SUPPLY_VOLTAGE_V * ts_b57861s0103f045Lut[0].resistance_Ohm) / \
143 (ts_b57861s0103f045Lut[0].resistance_Ohm + TS_EPCOS_B57861S0103F045_RESISTOR_DIVIDER_RESISTANCE_R_1_R_2_Ohm))
145 #define TS_EPCOS_B57861S0103F045_ADC_VOLTAGE_V_MIN_V \
146 ((float_t)((TS_EPCOS_B57861S0103F045_RESISTOR_DIVIDER_SUPPLY_VOLTAGE_V * ts_b57861s0103f045Lut[ts_b57861s0103f045LutSize-1].resistance_Ohm) / (ts_b57861s0103f045Lut[ts_b57861s0103f045LutSize-1].resistance_Ohm+TS_EPCOS_B57861S0103F045_RESISTOR_DIVIDER_RESISTANCE_R_1_R_2_Ohm)))
147 #define TS_EPCOS_B57861S0103F045_ADC_VOLTAGE_V_MAX_V \
148 ((float_t)((TS_EPCOS_B57861S0103F045_RESISTOR_DIVIDER_SUPPLY_VOLTAGE_V * ts_b57861s0103f045Lut[0].resistance_Ohm) / (ts_b57861s0103f045Lut[0].resistance_Ohm+TS_EPCOS_B57861S0103F045_RESISTOR_DIVIDER_RESISTANCE_R_1_R_2_Ohm)))
159 int16_t temperature_ddegC = 0;
160 float_t resistance_Ohm = 0.0f;
161 float_t adcVoltage_V = adcVoltage_mV / 1000.0f;
166 temperature_ddegC = INT16_MIN;
169 temperature_ddegC = INT16_MAX;
172 #if defined(TS_EPCOS_B57861S0103F045_POSITION_IN_RESISTOR_DIVIDER_IS_R_1) && \
173 (TS_EPCOS_B57861S0103F045_POSITION_IN_RESISTOR_DIVIDER_IS_R_1 == true)
184 uint16_t between_high = 0;
185 uint16_t between_low = 0;
188 between_low = i + 1u;
194 if (!(((between_high == 0u) && (between_low == 0u)) ||
206 return temperature_ddegC;
210 float_t temperature_degC = 0.0f;
211 float_t vadc_V = adcVoltage_mV / 1000.0f;
212 float_t vadc2 = vadc_V * vadc_V;
213 float_t vadc3 = vadc2 * vadc_V;
214 float_t vadc4 = vadc3 * vadc_V;
215 float_t vadc5 = vadc4 * vadc_V;
218 temperature_degC = (-6.2765f * vadc5) + (49.0397f * vadc4) - (151.3602f * vadc3) + (233.2521f * vadc2) -
219 (213.4588f * vadc_V) + 130.5822f;
221 return (int16_t)(temperature_degC * 10.0f);
225 #ifdef UNITY_UNIT_TEST
int16_t TS_Epc01GetTemperatureFromPolynomial(uint16_t adcVoltage_mV)
returns temperature based on measured ADC voltage
static uint16_t ts_b57861s0103f045LutSize
int16_t TS_Epc01GetTemperatureFromLut(uint16_t adcVoltage_mV)
returns temperature based on measured ADC voltage
#define TS_EPCOS_B57861S0103F045_ADC_VOLTAGE_V_MAX_V
Defines for calculating the ADC voltage on the ends of the operating range.
static const TS_TEMPERATURE_SENSOR_LUT_s ts_b57861s0103f045Lut[]
#define TS_EPCOS_B57861S0103F045_ADC_VOLTAGE_V_MIN_V
Defines for calculating the ADC voltage on the ends of the operating range.
Resistive divider used for measuring temperature.
#define TS_EPCOS_B57861S0103F045_RESISTOR_DIVIDER_SUPPLY_VOLTAGE_V
#define TS_EPCOS_B57861S0103F045_RESISTOR_DIVIDER_RESISTANCE_R_1_R_2_Ohm
float_t MATH_LinearInterpolation(const float_t x1, const float_t y1, const float_t x2, const float_t y2, const float_t x_interpolate)
Linear inter-/extrapolates a third point according to two given points.
math library for often used math functions