Compare commits

...

7 Commits

Author SHA1 Message Date
Matthew Kennedy 08378967c4 don't accidentally put it back in a 64 bit num 2024-04-25 21:35:41 -04:00
Matthew Kennedy 3127a1dcd2 instant rpm clearer truncation to 32 bits time 2024-04-25 21:35:41 -04:00
GitHub gen-default-tune Action 61dc1116b9 Auto-generated default tune 2024-04-26 01:12:28 +00:00
Matthew Kennedy e4db668aa7 use timer instead of home spun time math 2024-04-25 20:50:48 -04:00
Matthew Kennedy 046ad7436f use timer instead of home spun time math 2024-04-25 20:50:48 -04:00
GitHub set-date Action 0f522f1947 Update date 2024-04-26 00:42:25 +00:00
rusEFI LLC 7cdb78d6fa only: TODO: use a timer instead 2024-04-25 20:32:40 -04:00
6 changed files with 21 additions and 17 deletions

View File

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

View File

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

View File

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

View File

@ -51,10 +51,15 @@ 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] = nowNt;
timeOfLastEvent[current_index] = nowNt32;
// Determine where we currently are in the revolution
angle_t currentAngle = triggerFormDetails->eventAngles[current_index];
@ -67,17 +72,14 @@ float InstantRpmCalculator::calculateInstantRpm(
// now let's get precise angle for that event
angle_t prevIndexAngle = triggerFormDetails->eventAngles[prevIndex];
efitick_t time90ago = timeOfLastEvent[prevIndex];
auto time90ago = timeOfLastEvent[prevIndex];
// No previous timestamp, instant RPM isn't ready yet
if (time90ago == 0) {
return prevInstantRpmValue;
}
// 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;
uint32_t time = nowNt32 - time90ago;
angle_t angleDiff = currentAngle - prevIndexAngle;
// Wrap the angle in to the correct range (ie, could be -630 when we want +90)
@ -113,7 +115,8 @@ void InstantRpmCalculator::setLastEventTimeForInstantRpm(efitick_t nowNt) {
return;
}
spinningEvents[spinningEventIndex] = nowNt;
uint32_t nowNt32 = nowNt;
spinningEvents[spinningEventIndex] = nowNt32;
// 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,6 +307,7 @@ 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.0240425E7</constant>
<constant digits="0" name="byFirmwareVersion" units="index">2.0240426E7</constant>
<constant name="tps1_1AdcChannel">"Disabled"</constant>
<constant name="vbattAdcChannel">"Disabled"</constant>
<constant name="fuelLevelSensor">"Disabled"</constant>