N K
/
analoghalls6
motor spins
Fork of analoghalls5 by
Embed:
(wiki syntax)
Show/hide line numbers
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 }
Generated on Fri Jul 15 2022 12:15:05 by 1.7.2