Prius IPM controller

Dependencies:   mbed

Fork of analoghalls5_5 by N K

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers tempsensors.cpp Source File

tempsensors.cpp

00001 #include "includes.h"
00002 #include "sensors.h"
00003 
00004 NtcTempSensor::NtcTempSensor(PinName pin, float r_25, float ntc_b, float r_divider) {
00005     _in = new AnalogIn(pin);
00006     _ntc_b = ntc_b;
00007     _ntc_a = r_25 / exp(_ntc_b / 298.0f);
00008     _r_divider = r_divider;
00009 }
00010 
00011 float NtcTempSensor::GetTemp() {
00012     float v = (float) *_in * 3.3f;
00013     float r_n = v * _r_divider / (1.0f + v);
00014     return _ntc_b / log (r_n / _ntc_a);
00015 }