This commit is contained in:
rusEfi 2017-12-13 21:08:34 -05:00
parent 6382a26b2c
commit 2a520e1196
3 changed files with 17 additions and 6 deletions

View File

@ -807,7 +807,7 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_
case DBG_22: case DBG_22:
int prevIndex; int prevIndex;
{ {
float instantRpm = engine->triggerCentral.triggerState.calculateInstantRpm(&prevIndex, getTimeNowNt() PASS_ENGINE_PARAMETER_SUFFIX); float instantRpm = engine->triggerCentral.triggerState.instantRpm;
tsOutputChannels->debugFloatField1 = instantRpm; tsOutputChannels->debugFloatField1 = instantRpm;
tsOutputChannels->debugFloatField2 = instantRpm / engine->rpmCalculator.rpmValue; tsOutputChannels->debugFloatField2 = instantRpm / engine->rpmCalculator.rpmValue;
} }

View File

@ -114,6 +114,8 @@ private:
*/ */
class TriggerStateWithRunningStatistics : public TriggerState { class TriggerStateWithRunningStatistics : public TriggerState {
public: public:
TriggerStateWithRunningStatistics();
float instantRpm;
/** /**
* timestamp of each trigger wheel tooth * timestamp of each trigger wheel tooth
*/ */

View File

@ -211,12 +211,17 @@ void TriggerState::runtimeStatistics(efitime_t nowNt DECLARE_ENGINE_PARAMETER_SU
// empty base implementation // empty base implementation
} }
TriggerStateWithRunningStatistics::TriggerStateWithRunningStatistics() {
instantRpm = 0;
}
float TriggerStateWithRunningStatistics::calculateInstantRpm(int *prevIndex, efitime_t nowNt DECLARE_ENGINE_PARAMETER_SUFFIX) { float TriggerStateWithRunningStatistics::calculateInstantRpm(int *prevIndex, efitime_t nowNt DECLARE_ENGINE_PARAMETER_SUFFIX) {
int current_index = currentCycle.current_index; // local copy so that noone changes the value on us
/** /**
* Here we calculate RPM based on last 90 degrees * Here we calculate RPM based on last 90 degrees
*/ */
angle_t currentAngle = TRIGGER_SHAPE(eventAngles[currentCycle.current_index]); angle_t currentAngle = TRIGGER_SHAPE(eventAngles[current_index]);
// todo: make this '90' depend on cylinder count? // todo: make this '90' depend on cylinder count or trigger shape?
angle_t previousAngle = currentAngle - 90; angle_t previousAngle = currentAngle - 90;
fixAngle(previousAngle, "prevAngle"); fixAngle(previousAngle, "prevAngle");
// todo: prevIndex should be pre-calculated // todo: prevIndex should be pre-calculated
@ -230,16 +235,20 @@ float TriggerStateWithRunningStatistics::calculateInstantRpm(int *prevIndex, efi
fixAngle(angleDiff, "angleDiff"); fixAngle(angleDiff, "angleDiff");
float instantRpm = (60000000.0 / 360 * US_TO_NT_MULTIPLIER) * angleDiff / time; float instantRpm = (60000000.0 / 360 * US_TO_NT_MULTIPLIER) * angleDiff / time;
instantRpmValue[currentCycle.current_index] = instantRpm; instantRpmValue[current_index] = instantRpm;
timeOfLastEvent[currentCycle.current_index] = nowNt; timeOfLastEvent[current_index] = nowNt;
return instantRpm; return instantRpm;
} }
void TriggerStateWithRunningStatistics::runtimeStatistics(efitime_t nowNt DECLARE_ENGINE_PARAMETER_SUFFIX) { void TriggerStateWithRunningStatistics::runtimeStatistics(efitime_t nowNt DECLARE_ENGINE_PARAMETER_SUFFIX) {
if (engineConfiguration->debugMode == DBG_22) {
int prevIndex;
instantRpm = calculateInstantRpm(&prevIndex, nowNt PASS_ENGINE_PARAMETER_SUFFIX);
}
if (ENGINE(sensorChartMode) == SC_RPM_ACCEL || ENGINE(sensorChartMode) == SC_DETAILED_RPM) { if (ENGINE(sensorChartMode) == SC_RPM_ACCEL || ENGINE(sensorChartMode) == SC_DETAILED_RPM) {
int prevIndex; int prevIndex;
float instantRpm = calculateInstantRpm(&prevIndex, nowNt PASS_ENGINE_PARAMETER_SUFFIX); instantRpm = calculateInstantRpm(&prevIndex, nowNt PASS_ENGINE_PARAMETER_SUFFIX);
#if EFI_SENSOR_CHART || defined(__DOXYGEN__) #if EFI_SENSOR_CHART || defined(__DOXYGEN__)
angle_t currentAngle = TRIGGER_SHAPE(eventAngles[currentCycle.current_index]); angle_t currentAngle = TRIGGER_SHAPE(eventAngles[currentCycle.current_index]);