Speeduino
Loading...
Searching...
No Matches
crank_angle_calculator.h
Go to the documentation of this file.
1
14#pragma once
15#include "src/utils/nominmax.h"
16#include <tuple>
17#include "config_pages.h"
18
29{
30 uint32_t _toothLastToothTime = 0;
31
32#if !defined(UNIT_TEST)
33protected:
34#endif
37
38 int16_t calculate(uint32_t currMicros) const;
39};
40
44{
45 uint32_t _toothLastToothTime = 0;
47 uint16_t _toothAngle = 0;
49
50#if !defined(UNIT_TEST)
51protected:
52#endif
54 explicit tooth_interval_calculator_t(uint32_t toothLastToothTime, uint32_t toothLastMinusOneToothTime, uint16_t toothAngle, bool toothAngleCorrect);
55
56 int16_t calculate(uint32_t currMicros) const;
57};
58
63{
64 uint16_t _toothCurrentCount = 0;
65
66#if !defined(UNIT_TEST)
67protected:
68#endif
71
77 int16_t calculate(const int16_t toothAngles[]) const;
78};
79
84{
85 uint16_t _toothCurrentCount = 0;
86 uint16_t _toothAngle = 0;
87
88#if !defined(UNIT_TEST)
89protected:
90#endif
92 explicit compute_initial_calculator_t(uint16_t toothCurrentCount, uint16_t toothAngle);
93
94 int16_t calculate(void) const;
95};
96
99{
100 bool _revZeroOrOne = false;
101
102#if !defined(UNIT_TEST)
103protected:
104#endif
106 explicit sequential_correction_calculator_t(bool revZeroOrOne);
107
108 int16_t calculate(const config4 &page4) const;
109};
110
112
120 {
121 int16_t calculateCrankAngle(int16_t initialCrankAngle, uint32_t currMicros, const config4 &page4) const;
122};
123
125{
127 explicit lookup_crank_angle_calculator_t(const std::tuple<uint32_t, bool, uint16_t> &data);
128
136 int16_t calculateCrankAngle(uint32_t currMicros, const int16_t toothAngles[], const config4 &page4) const;
137};
138
140{
142 explicit trigger_angle_crank_angle_calculator_t(const std::tuple<uint32_t, bool, uint16_t, uint16_t> &data);
143
150 int16_t calculateCrankAngle(uint32_t currMicros, const config4 &page4) const;
151};
152
154{
156 explicit lookup_crank_angle_calculator_tooth_interval_t(const std::tuple<uint32_t, uint32_t, bool, uint16_t, uint16_t, bool> &data);
157
165 int16_t calculateCrankAngle(uint32_t currMicros, const int16_t toothAngles[], const config4 &page4) const;
166};
167
169{
171 explicit compute_crank_angle_calculator_tooth_interval_t(const std::tuple<uint32_t, uint32_t, bool, uint16_t, uint16_t, bool> &data);
172
179 int16_t calculateCrankAngle(uint32_t currMicros, const config4 &page4) const;
180};
181
182
The tune page structs and related defines.
TESTABLE_STATIC volatile uint32_t toothLastMinusOneToothTime
Definition decoders.cpp:66
TESTABLE_STATIC int16_t toothAngles[24]
Definition decoders.cpp:90
TESTABLE_STATIC volatile uint32_t toothLastToothTime
Definition decoders.cpp:63
TESTABLE_STATIC uint16_t toothCurrentCount
Definition decoders.cpp:60
const config4 & page4
Definition engineProtection.cpp:172
Workaround when min() & max() are defined as macros, which generates compile errors in most C++ stand...
Definition crank_angle_calculator.h:169
int16_t calculateCrankAngle(uint32_t currMicros, const config4 &page4) const
Calculate the crank angle.
Definition crank_angle_calculator.cpp:155
A crank angle calculator that computes the initial crank angle from a tooth angle.
Definition crank_angle_calculator.h:84
uint16_t _toothCurrentCount
1-based tooth number
Definition crank_angle_calculator.h:85
int16_t calculate(void) const
Definition crank_angle_calculator.cpp:64
uint16_t _toothAngle
Tooth angle (1-359°)
Definition crank_angle_calculator.h:86
Definition config_pages.h:353
A crank angle calculator that computes a temporal adjustment based on when the tooth was last detecte...
Definition crank_angle_calculator.h:29
uint32_t _toothLastToothTime
Time in µS that the current tooth was last detected.
Definition crank_angle_calculator.h:30
int16_t calculate(uint32_t currMicros) const
Definition crank_angle_calculator.cpp:13
Definition crank_angle_calculator.h:125
int16_t calculateCrankAngle(uint32_t currMicros, const int16_t toothAngles[], const config4 &page4) const
Calculate the crank angle.
Definition crank_angle_calculator.cpp:109
Definition crank_angle_calculator.h:154
int16_t calculateCrankAngle(uint32_t currMicros, const int16_t toothAngles[], const config4 &page4) const
Calculate the crank angle.
Definition crank_angle_calculator.cpp:139
A crank angle calculator that looks up the initial crank angle from an array.
Definition crank_angle_calculator.h:63
uint16_t _toothCurrentCount
1-based tooth number
Definition crank_angle_calculator.h:64
int16_t calculate(const int16_t toothAngles[]) const
Calculate the crank angle.
Definition crank_angle_calculator.cpp:46
A crank angle calculator that computes a revolution adjustment.
Definition crank_angle_calculator.h:99
bool _revZeroOrOne
When calculating over 720°, tells the calculator if we are in the 1st revolution (false) or the 2nd (...
Definition crank_angle_calculator.h:100
int16_t calculate(const config4 &page4) const
Definition crank_angle_calculator.cpp:81
Definition crank_angle_calculator.h:120
int16_t calculateCrankAngle(int16_t initialCrankAngle, uint32_t currMicros, const config4 &page4) const
Definition crank_angle_calculator.cpp:94
A crank angle calculator that computes a temporal adjustment based on the gap between the 2 most rece...
Definition crank_angle_calculator.h:44
uint16_t _toothAngle
Tooth angle (1-359°)
Definition crank_angle_calculator.h:47
uint32_t _toothLastToothTime
Time in µS that the current tooth was last detected.
Definition crank_angle_calculator.h:45
int16_t calculate(uint32_t currMicros) const
Definition crank_angle_calculator.cpp:27
uint32_t _toothLastMinusOneToothTime
Time in µS that the tooth before the last tooth was detected.
Definition crank_angle_calculator.h:46
bool _toothAngleCorrect
Is _toothAngle valid.
Definition crank_angle_calculator.h:48
Definition crank_angle_calculator.h:140
int16_t calculateCrankAngle(uint32_t currMicros, const config4 &page4) const
Calculate the crank angle.
Definition crank_angle_calculator.cpp:124