fome-fw/unit_tests/tests/test_sensors.cpp

55 lines
1.4 KiB
C++
Raw Normal View History

2015-07-10 06:01:56 -07:00
/**
* @file test_sensors.cpp
*
* @date Dec 7, 2013
2020-01-13 18:57:43 -08:00
* @author Andrey Belomutskiy, (c) 2012-2020
2015-07-10 06:01:56 -07:00
*/
2018-09-16 19:39:46 -07:00
#include "global.h"
2015-07-10 06:01:56 -07:00
#include "thermistors.h"
#include "allsensors.h"
#include "engine_test_helper.h"
2019-01-08 19:10:54 -08:00
TEST(sensors, mapDecoding) {
2019-01-19 17:42:29 -08:00
WITH_ENGINE_TEST_HELPER(FORD_INLINE_6_1995);
2015-07-10 06:01:56 -07:00
air_pressure_sensor_config_s s;
s.type = MT_DENSO183;
2017-05-15 20:28:49 -07:00
assertEqualsM("denso 0 volts", -6.64, decodePressure(0, &s PASS_ENGINE_PARAMETER_SUFFIX));
2019-01-14 15:20:20 -08:00
ASSERT_FLOAT_EQ(31.244, decodePressure(1, &s PASS_ENGINE_PARAMETER_SUFFIX));
2015-07-10 06:01:56 -07:00
s.type = MT_MPX4250;
2019-01-14 15:38:20 -08:00
ASSERT_EQ( 8, decodePressure(0, &s PASS_ENGINE_PARAMETER_SUFFIX)) << "MPX_4250 0 volts";
2019-01-14 15:20:20 -08:00
ASSERT_FLOAT_EQ(58.4, decodePressure(1, &s PASS_ENGINE_PARAMETER_SUFFIX));
2015-07-10 06:01:56 -07:00
}
TEST(sensors, Thermistor1) {
ThermistorMath tm;
thermistor_conf_s tc = {32, 75, 120, 9500, 2100, 1000, 0};
tm.setConfig(&tc);
float t = tm.getKelvinTemperatureByResistance(2100);
ASSERT_FLOAT_EQ(75 + KELV, t);
2015-07-10 06:01:56 -07:00
ASSERT_NEAR(-0.003, tm.s_h_a, EPS4D);
ASSERT_NEAR(0.001, tm.s_h_b, EPS4D);
ASSERT_NEAR(0.0, tm.s_h_c, EPS5D);
}
TEST(sensors, ThermistorNeon)
{
2015-07-10 06:01:56 -07:00
ThermistorMath tm;
// 2003 Neon sensor
thermistor_conf_s tc = {0, 30, 100, 32500, 7550, 700, 0};
tm.setConfig(&tc);
float t = tm.getKelvinTemperatureByResistance(38000);
ASSERT_NEAR(-2.7983, t - KELV, EPS4D);
assertEqualsM("A", 0.0009, tm.s_h_a);
assertEqualsM("B", 0.0003, tm.s_h_b);
ASSERT_NEAR(0.0, tm.s_h_c, EPS4D);
2015-07-10 06:01:56 -07:00
}