rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
instant_rpm_calculator.h
Go to the documentation of this file.
1/**
2 * instant_rpm_calculator.h
3 */
4
5#pragma once
6#include "trigger_structure.h"
7
9public:
11 float getInstantRpm() const {
12 return m_instantRpm;
13 }
14
15#if EFI_ENGINE_CONTROL && EFI_SHAFT_POSITION_INPUT
17 uint32_t current_index,
18 TriggerWaveform const & triggerShape, TriggerFormDetails *triggerFormDetails,
19 uint32_t index, efitick_t nowNt);
20#endif
21 /**
22 * Update timeOfLastEvent[] on every trigger event - even without synchronization
23 * Needed for early spin-up RPM detection.
24 */
25 void setLastEventTimeForInstantRpm(efitick_t nowNt);
26
28
36
37 /**
38 * timestamp of each trigger wheel tooth
39 */
40 uint32_t timeOfLastEvent[PWM_PHASE_MAX_COUNT];
41
43
44 // we might need up to one full trigger cycle of events - which on 60-2 means storage for ~120
45 // todo: change the implementation to reuse 'timeOfLastEvent'
46 uint32_t spinningEvents[120];
47 /**
48 * instant RPM calculated at this trigger wheel tooth
49 */
50 float instantRpmValue[PWM_PHASE_MAX_COUNT];
51 /**
52 * Stores last non-zero instant RPM value to fix early instability
53 */
55
56
57 float m_instantRpm = 0;
58private:
60 TriggerWaveform const & triggerShape, TriggerFormDetails *triggerFormDetails,
61 uint32_t index, efitick_t nowNt);
62
64};
void setLastEventTimeForInstantRpm(efitick_t nowNt)
float instantRpmValue[PWM_PHASE_MAX_COUNT]
float calculateInstantRpm(TriggerWaveform const &triggerShape, TriggerFormDetails *triggerFormDetails, uint32_t index, efitick_t nowNt)
uint32_t timeOfLastEvent[PWM_PHASE_MAX_COUNT]
void updateInstantRpm(uint32_t current_index, TriggerWaveform const &triggerShape, TriggerFormDetails *triggerFormDetails, uint32_t index, efitick_t nowNt)
Trigger shape has all the fields needed to describe and decode trigger signal.
void setArrayValues(TValue(&array)[TSize], float value)