2021-08-03 19:05:01 -07:00
|
|
|
#include "pch.h"
|
2020-04-02 12:20:04 -07:00
|
|
|
|
|
|
|
extern float getTachFreq(void);
|
|
|
|
extern float getTachDuty(void);
|
|
|
|
|
2022-02-02 13:36:35 -08:00
|
|
|
TEST(Actuators, Tachometer) {
|
2020-04-02 12:20:04 -07:00
|
|
|
// This engine has a tach pin set - we need that
|
2023-05-31 22:31:28 -07:00
|
|
|
EngineTestHelper eth(engine_type_e::FRANKENSO_MAZDA_MIATA_2003);
|
2020-04-02 12:20:04 -07:00
|
|
|
|
|
|
|
// We don't actually care about ign/inj at all, just tach
|
|
|
|
engineConfiguration->isInjectionEnabled = false;
|
|
|
|
engineConfiguration->isIgnitionEnabled = false;
|
|
|
|
|
|
|
|
// Configure tach pulse count
|
|
|
|
// 5 PPR, 25% duty
|
|
|
|
engineConfiguration->tachPulsePerRev = 4;
|
|
|
|
engineConfiguration->tachPulseDuractionMs = 0.5f;
|
|
|
|
engineConfiguration->tachPulseDurationAsDutyCycle = true;
|
|
|
|
|
|
|
|
// Set predictable trigger settings
|
2023-05-31 22:56:40 -07:00
|
|
|
engineConfiguration->trigger.type = trigger_type_e::TT_TOOTHED_WHEEL;
|
2020-04-02 12:20:04 -07:00
|
|
|
engineConfiguration->trigger.customTotalToothCount = 8;
|
|
|
|
engineConfiguration->trigger.customSkippedToothCount = 0;
|
2022-04-02 23:21:37 -07:00
|
|
|
setCamOperationMode();
|
2020-04-02 12:20:04 -07:00
|
|
|
eth.applyTriggerWaveform();
|
|
|
|
|
|
|
|
// get the engine running - 6 revolutions
|
|
|
|
eth.fireTriggerEvents(48);
|
|
|
|
|
2020-12-24 18:20:24 -08:00
|
|
|
// ensure engine speed
|
2022-01-20 19:58:12 -08:00
|
|
|
ASSERT_EQ(1500, Sensor::getOrZero(SensorType::Rpm)) << "RPM";
|
2021-07-03 07:37:03 -07:00
|
|
|
ASSERT_EQ(engine->triggerCentral.triggerState.getShaftSynchronized(), true);
|
2020-12-24 18:20:24 -08:00
|
|
|
|
|
|
|
// Poke the fast callback to update the tach
|
2021-11-16 01:15:29 -08:00
|
|
|
engine->periodicFastCallback();
|
2020-12-24 18:20:24 -08:00
|
|
|
|
|
|
|
ASSERT_EQ(100, getTachFreq());
|
|
|
|
ASSERT_EQ(0.5, getTachDuty());
|
2020-04-02 12:20:04 -07:00
|
|
|
}
|