rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes
TachometerModule Class Reference

#include <tachometer.h>

Inheritance diagram for TachometerModule:
Inheritance graph
[legend]
Collaboration diagram for TachometerModule:
Collaboration graph
[legend]

Public Member Functions

void init ()
 
void onFastCallback () override
 
- Public Member Functions inherited from EngineModule
virtual void initNoConfiguration ()
 
virtual void setDefaultConfiguration ()
 
virtual void onConfigurationChange (engine_configuration_s const *)
 
virtual void onSlowCallback ()
 
virtual void onEngineStop ()
 
virtual void onIgnitionStateChanged (bool)
 
virtual bool needsDelayedShutoff ()
 
virtual void onEnginePhase (float, efitick_t, angle_t, angle_t)
 

Private Attributes

bool tachHasInit
 

Detailed Description

Definition at line 11 of file tachometer.h.

Member Function Documentation

◆ init()

void TachometerModule::init ( )

Definition at line 67 of file tachometer.cpp.

67 {
68 tachHasInit = false;
69
71 return;
72 }
73
75 "Tachometer",
78 NAN, 0.1f);
79
80 tachHasInit = true;
81}
SingleTimerExecutor scheduler
Definition engine.h:271
RegisteredOutputPin tachOut
Definition efi_gpio.h:120
EnginePins enginePins
Definition efi_gpio.cpp:24
static EngineAccessor engine
Definition engine.h:413
static constexpr engine_configuration_s * engineConfiguration
bool isBrainPinValid(brain_pin_e brainPin)
void startSimplePwm(SimplePwm *state, const char *msg, Scheduler *executor, OutputPin *output, float frequency, float dutyCycle, pwm_gen_callback *callback)
static SimplePwm tachControl("tach")
Here is the call graph for this function:

◆ onFastCallback()

void TachometerModule::onFastCallback ( )
overridevirtual

Reimplemented from EngineModule.

Definition at line 30 of file tachometer.cpp.

30 {
31 // Only do anything if tach enabled
32 if (!tachHasInit) {
33 return;
34 }
35
36 // How many tach pulse periods do we have?
37 float periods = engineConfiguration->tachPulsePerRev;
38
39 if (periods == 0 || periods > 10) {
40 firmwareError(ObdCode::CUSTOM_ERR_6709, "Invalid tachometer pulse per rev: %.2f", periods);
41 tachHasInit = false; // disable until nex fw init to avoid spamming the output
42 return;
43 }
44
45 // What is the angle per tach output period?
46 float cycleTimeMs = 60000.0f / Sensor::getOrZero(SensorType::Rpm);
47 float periodTimeMs = cycleTimeMs / periods;
48 tachFreq = 1000.0f / periodTimeMs;
49
51 // Simple case - duty explicitly set
53 } else {
54 // Constant high-time mode - compute the correct duty cycle
56 }
57
58 // In case Freq is under 1Hz, we stop pwm to avoid warnings!
59 if (tachFreq < 1) {
60 tachFreq = NAN;
61 }
62
65}
void setFrequency(float frequency)
static float getOrZero(SensorType type)
Definition sensor.h:83
void setSimplePwmDutyCycle(float dutyCycle) override
void firmwareError(ObdCode code, const char *fmt,...)
@ CUSTOM_ERR_6709
static float tachFreq
static float duty
Here is the call graph for this function:

Field Documentation

◆ tachHasInit

bool TachometerModule::tachHasInit
private

Definition at line 16 of file tachometer.h.

Referenced by init(), and onFastCallback().


The documentation for this class was generated from the following files: