Compare commits

..

No commits in common. "08378967c48f5993862a19bbd7772cb72681b0bc" and "c0e7eb4a2cc2ed65221719182c80a561211012ca" have entirely different histories.

6 changed files with 17 additions and 21 deletions

View File

@ -70,9 +70,10 @@ public:
*/
angle_t sparkAngle = NAN;
floatms_t sparkDwell = 0;
// this timer allows us to measure actual dwell time
Timer actualDwellTimer;
/**
* this timestamp allows us to measure actual dwell time
*/
uint32_t actualStartOfDwellNt = 0;
float dwellAngle = 0;

View File

@ -1,2 +1,2 @@
#pragma once
#define VCS_DATE 20240426
#define VCS_DATE 20240425

View File

@ -208,12 +208,11 @@ void fireSparkAndPrepareNextSchedule(IgnitionEvent *event) {
#if !EFI_UNIT_TEST
if (engineConfiguration->debugMode == DBG_DWELL_METRIC) {
#if EFI_TUNER_STUDIO
float actualDwellMs = event->actualDwellTimer.getElapsedSeconds(nowNt) * 1e3;
uint32_t actualDwellDurationNt = getTimeNowLowerNt() - event->actualStartOfDwellNt;
/**
* ratio of desired dwell duration to actual dwell duration gives us some idea of how good is input trigger jitter
*/
float ratio = actualDwellMs / event->sparkDwell;
float ratio = NT2US(actualDwellDurationNt) / 1000.0 / event->sparkDwell;
// todo: smarted solution for index to field mapping
switch (event->cylinderIndex) {
@ -318,9 +317,9 @@ static bool startDwellByTurningSparkPinHigh(IgnitionEvent *event, IgnitionOutput
}
void turnSparkPinHighStartCharging(IgnitionEvent *event) {
efitick_t nowNt = getTimeNowNt();
event->actualStartOfDwellNt = getTimeNowLowerNt();
event->actualDwellTimer.reset(nowNt);
efitick_t nowNt = getTimeNowNt();
bool skippedDwellDueToTriggerNoised = false;
for (int i = 0; i< MAX_OUTPUTS_FOR_IGNITION;i++) {

View File

@ -51,15 +51,10 @@ float InstantRpmCalculator::calculateInstantRpm(
TriggerWaveform const & triggerShape, TriggerFormDetails *triggerFormDetails,
uint32_t current_index, efitick_t nowNt) {
// It's OK to truncate from 64b to 32b, ARM with single precision FPU uses an expensive
// software function to convert 64b int -> float, while 32b int -> float is very cheap hardware conversion
// The difference is guaranteed to be short (it's 90 degrees of engine rotation!), so it won't overflow.
uint32_t nowNt32 = nowNt;
assertIsInBoundsWithResult(current_index, timeOfLastEvent, "calc timeOfLastEvent", 0);
// Record the time of this event so we can calculate RPM from it later
timeOfLastEvent[current_index] = nowNt32;
timeOfLastEvent[current_index] = nowNt;
// Determine where we currently are in the revolution
angle_t currentAngle = triggerFormDetails->eventAngles[current_index];
@ -72,14 +67,17 @@ float InstantRpmCalculator::calculateInstantRpm(
// now let's get precise angle for that event
angle_t prevIndexAngle = triggerFormDetails->eventAngles[prevIndex];
auto time90ago = timeOfLastEvent[prevIndex];
efitick_t time90ago = timeOfLastEvent[prevIndex];
// No previous timestamp, instant RPM isn't ready yet
if (time90ago == 0) {
return prevInstantRpmValue;
}
uint32_t time = nowNt32 - time90ago;
// It's OK to truncate from 64b to 32b, ARM with single precision FPU uses an expensive
// software function to convert 64b int -> float, while 32b int -> float is very cheap hardware conversion
// The difference is guaranteed to be short (it's 90 degrees of engine rotation!), so it won't overflow.
uint32_t time = nowNt - time90ago;
angle_t angleDiff = currentAngle - prevIndexAngle;
// Wrap the angle in to the correct range (ie, could be -630 when we want +90)
@ -115,8 +113,7 @@ void InstantRpmCalculator::setLastEventTimeForInstantRpm(efitick_t nowNt) {
return;
}
uint32_t nowNt32 = nowNt;
spinningEvents[spinningEventIndex] = nowNt32;
spinningEvents[spinningEventIndex] = nowNt;
// If we are using only rising edges, we never write in to the odd-index slots that
// would be used by falling edges

View File

@ -307,7 +307,6 @@ void initSmartGpio() {
void tle8888startup() {
#if EFI_PROD_CODE && (BOARD_TLE8888_COUNT > 0)
// TODO: use a timer instead
static efitick_t tle8888CrankingResetTime = 0;
if (engineConfiguration->useTLE8888_cranking_hack && engine->rpmCalculator.isCranking()) {

View File

@ -208,7 +208,7 @@
<constant name="acrPin">"NONE"</constant>
<constant digits="1" name="driveWheelRevPerKm" units="revs/km">1000.0</constant>
<constant digits="2" name="canSleepPeriodMs" units="ms">50.0</constant>
<constant digits="0" name="byFirmwareVersion" units="index">2.0240426E7</constant>
<constant digits="0" name="byFirmwareVersion" units="index">2.0240425E7</constant>
<constant name="tps1_1AdcChannel">"Disabled"</constant>
<constant name="vbattAdcChannel">"Disabled"</constant>
<constant name="fuelLevelSensor">"Disabled"</constant>