summaryrefslogtreecommitdiff
path: root/driver/temp_sensor/thermistor.c
diff options
context:
space:
mode:
authorVijay Hiremath <vijay.p.hiremath@intel.com>2019-04-02 21:58:22 -0700
committerchrome-bot <chrome-bot@chromium.org>2019-04-26 00:17:33 -0700
commit2362b119299e2122832656aa0a1affda74654ce6 (patch)
tree286725ba65299777114b03bf076fb4d04017c542 /driver/temp_sensor/thermistor.c
parent5c931074f53de0bcac655d60e5867b3eb0959864 (diff)
downloadchrome-ec-2362b119299e2122832656aa0a1affda74654ce6.tar.gz
thermistor: Add STEINHART-HART lookup table for NCP15WB473F03RC
The lookup table is based off of a resistor divider circuit on 3.0V with a 22.6K resistor in series with a thermistor with nominal value of 47K (at 25C) and a B (25/100) value of 4050. Calculation: 1. Get the thermistor resistance for a given temperature from the datasheet. 2. Calculate the ADC input voltage. Vout = (Vdd * Rt) / (Rt + Rs) Where: Vdd - Source voltage (Constant) Vout - ADC value read on STEINHART-HART voltage divider circuit Rt - Resistance of thermistor at given temperature Rs - Series resistance value (constant) 3. Form a STEINHART-HART lookup table for 0 to 100 deg C 4. Add a scaling factor so that the STEINHART-HART lookup table data is 1-byte per pair. BUG=b:131060744 BRANCH=none TEST=Manually tested on ICLRVP, able to read correct temperature Change-Id: Ib0e7b1ab6d6d4c5bcb14ff4ab0e830881e9864e6 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/1577741 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'driver/temp_sensor/thermistor.c')
-rw-r--r--driver/temp_sensor/thermistor.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/driver/temp_sensor/thermistor.c b/driver/temp_sensor/thermistor.c
index 15295a00ea..25ff819321 100644
--- a/driver/temp_sensor/thermistor.c
+++ b/driver/temp_sensor/thermistor.c
@@ -65,7 +65,8 @@ int thermistor_linear_interpolate(uint16_t mv,
#if defined(CONFIG_STEINHART_HART_3V3_51K1_47K_4050B) || \
defined(CONFIG_STEINHART_HART_3V3_13K7_47K_4050B) || \
- defined(CONFIG_STEINHART_HART_6V0_51K1_47K_4050B)
+ defined(CONFIG_STEINHART_HART_6V0_51K1_47K_4050B) || \
+ defined(CONFIG_STEINHART_HART_3V0_22K6_47K_4050B)
static int thermistor_get_temperature(int idx_adc, int *temp_ptr,
const struct thermistor_info *info)
{
@@ -196,3 +197,39 @@ int get_temp_6v0_51k1_47k_4050b(int idx_adc, int *temp_ptr)
&thermistor_info_6v0_51_47);
}
#endif /* CONFIG_STEINHART_HART_6V0_51K1_47K_4050B */
+
+#ifdef CONFIG_STEINHART_HART_3V0_22K6_47K_4050B
+/*
+ * Data derived from Steinhart-Hart equation in a resistor divider circuit with
+ * Vdd=3000mV, R = 22.6Kohm, and thermistor (B = 4050, T0 = 298.15 K, nominal
+ * resistance (R0) = 47Kohm).
+ */
+#define THERMISTOR_SCALING_FACTOR_22_47 11
+static const struct thermistor_data_pair thermistor_data_22_47[] = {
+ { 2625 / THERMISTOR_SCALING_FACTOR_22_47, 0 },
+ { 2425 / THERMISTOR_SCALING_FACTOR_22_47, 10 },
+ { 2170 / THERMISTOR_SCALING_FACTOR_22_47, 20 },
+ { 1875 / THERMISTOR_SCALING_FACTOR_22_47, 30 },
+ { 1563 / THERMISTOR_SCALING_FACTOR_22_47, 40 },
+ { 1263 / THERMISTOR_SCALING_FACTOR_22_47, 50 },
+ { 995 / THERMISTOR_SCALING_FACTOR_22_47, 60 },
+ { 770 / THERMISTOR_SCALING_FACTOR_22_47, 70 },
+ { 589 / THERMISTOR_SCALING_FACTOR_22_47, 80 },
+ { 514 / THERMISTOR_SCALING_FACTOR_22_47, 85 },
+ { 448 / THERMISTOR_SCALING_FACTOR_22_47, 90 },
+ { 391 / THERMISTOR_SCALING_FACTOR_22_47, 95 },
+ { 341 / THERMISTOR_SCALING_FACTOR_22_47, 100 },
+};
+
+static const struct thermistor_info thermistor_info_22_47 = {
+ .scaling_factor = THERMISTOR_SCALING_FACTOR_22_47,
+ .num_pairs = ARRAY_SIZE(thermistor_data_22_47),
+ .data = thermistor_data_22_47,
+};
+
+int get_temp_3v0_22k6_47k_4050b(int idx_adc, int *temp_ptr)
+{
+ return thermistor_get_temperature(idx_adc, temp_ptr,
+ &thermistor_info_22_47);
+}
+#endif /* CONFIG_STEINHART_HART_3V0_22K6_47K_4050B */