Skip to content

Commit

Permalink
give dwell metric its own channel
Browse files Browse the repository at this point in the history
  • Loading branch information
mck1117 committed Sep 1, 2024
1 parent 5105258 commit 40dfd1e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 34 deletions.
2 changes: 2 additions & 0 deletions firmware/console/binary/output_channels.txt
Original file line number Diff line number Diff line change
Expand Up @@ -373,4 +373,6 @@ float mapFast
uint16_t mapAveragingSamples

uint8_t[12 iterate] mapPerCylinder;;"kPa", 1, 0, 0, 0, 0

uint16_t autoscale dwellAccuracyRatio;;"ratio", 0.001, 0, 0, 0, 3
end_struct
2 changes: 1 addition & 1 deletion firmware/controllers/algo/engine_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ typedef enum __attribute__ ((__packed__)) {
DBG_ION = 30,
DBG_TLE8888 = 31,
DBG_32 = 32,
DBG_DWELL_METRIC = 33,
DBG_33 = 33,
DBG_34 = 34,
DBG_35 = 35,
DBG_36 = 36,
Expand Down
36 changes: 4 additions & 32 deletions firmware/controllers/engine_cycle/spark_logic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,35 +183,14 @@ void fireSparkAndPrepareNextSchedule(IgnitionEvent *event) {
LogTriggerCoilState(nowNt, false);
#endif // EFI_TOOTH_LOGGER

#if !EFI_UNIT_TEST
if (engineConfiguration->debugMode == DBG_DWELL_METRIC) {
#if EFI_TUNER_STUDIO
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 = actualDwellMs / event->sparkDwell;

// todo: smarted solution for index to field mapping
switch (event->cylinderIndex) {
case 0:
engine->outputChannels.debugFloatField1 = ratio;
break;
case 1:
engine->outputChannels.debugFloatField2 = ratio;
break;
case 2:
engine->outputChannels.debugFloatField3 = ratio;
break;
case 3:
engine->outputChannels.debugFloatField4 = ratio;
break;
{
// ratio of desired dwell duration to actual dwell duration gives us some idea of how good is input trigger jitter
float actualDwellMs = event->actualDwellTimer.getElapsedSeconds(nowNt) * 1e3;
engine->outputChannels.dwellAccuracyRatio = actualDwellMs / event->sparkDwell;
}
#endif

}
#endif /* EFI_UNIT_TEST */
// now that we've just fired a coil let's prepare the new schedule for the next engine revolution

angle_t dwellAngleDuration = engine->ignitionState.dwellAngle;
Expand All @@ -227,19 +206,12 @@ if (engineConfiguration->debugMode == DBG_DWELL_METRIC) {

efitick_t nextDwellStart = nowNt + engine->engineState.multispark.delay;
efitick_t nextFiring = nextDwellStart + engine->engineState.multispark.dwell;
#if SPARK_EXTREME_LOGGING
efiPrintf("schedule multispark");
#endif /* SPARK_EXTREME_LOGGING */

// We can schedule both of these right away, since we're going for "asap" not "particular angle"
engine->scheduler.schedule("dwell", &event->dwellStartTimer, nextDwellStart, { &turnSparkPinHigh, event });
engine->scheduler.schedule("firing", &event->sparkEvent.scheduling, nextFiring, { fireSparkAndPrepareNextSchedule, event });
} else {
if (engineConfiguration->enableTrailingSparks) {
#if SPARK_EXTREME_LOGGING
efiPrintf("scheduleByAngle TrailingSparks");
#endif /* SPARK_EXTREME_LOGGING */

// Trailing sparks are enabled - schedule an event for the corresponding trailing coil
scheduleByAngle(
&event->trailingSparkFire, nowNt, engine->engineState.trailingSparkAngle,
Expand Down
2 changes: 1 addition & 1 deletion firmware/integration/rusefi_config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ float baseFuel;Base mass of the per-cylinder fuel injected during cranking. This
int16_t rpm;This sets the RPM limit below which the ECU will use cranking fuel and ignition logic, typically this is around 350-450rpm.;"RPM", 1, 0, 0, 3000, 0
end_struct

#define debug_mode_e_enum "INVALID", "TPS acceleration enrichment", "INVALID", "Stepper Idle Control", "Engine Load accl enrich", "Trigger Counters", "Soft Spark Cut", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "SD card", "sr5", "Knock", "INVALID", "Electronic Throttle", "Executor", "Bench Test / TS commands", "INVALID", "Analog inputs #1", "INVALID", "INVALID", "Status", "INVALID", "INVALID", "INVALID", "Metrics", "INVALID", "Ion Sense", "TLE8888", "Analog inputs #2", "Dwell Metric", "INVALID", "INVALID", "Boost Control", "INVALID", "INVALID", "ETB Autotune", "Composite Log", "INVALID", "INVALID", "INVALID", "Dyno_View", "Logic_Analyzer", "INVALID", "TCU", "Lua"
#define debug_mode_e_enum "INVALID", "TPS acceleration enrichment", "INVALID", "Stepper Idle Control", "Engine Load accl enrich", "Trigger Counters", "Soft Spark Cut", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "SD card", "sr5", "Knock", "INVALID", "Electronic Throttle", "Executor", "Bench Test / TS commands", "INVALID", "Analog inputs #1", "INVALID", "INVALID", "Status", "INVALID", "INVALID", "INVALID", "Metrics", "INVALID", "Ion Sense", "TLE8888", "Analog inputs #2", "INVALID", "INVALID", "INVALID", "Boost Control", "INVALID", "INVALID", "ETB Autotune", "Composite Log", "INVALID", "INVALID", "INVALID", "Dyno_View", "Logic_Analyzer", "INVALID", "TCU", "Lua"
custom debug_mode_e 1 bits, U08, @OFFSET@, [0:5], @@debug_mode_e_enum@@

#define vvt_mode_e_enum "Inactive", "Single Tooth", "Toyota 3 Tooth", "Miata NB2", "INVALID", "Bosch Quick Start", "4/1", "ST 170", "Ford Barra 3+1", "Nissan VQ", "Honda K Intake", "Nissan MR18", "Mitsu 3A92", "VTwin by MAP", "Mitsu 6G75", "Mazda Skyactiv", "Honda K Exhaust", "Mitsubishi 4G92/93/94", "Mitsubishi 4G63", "Mazda L"
Expand Down

0 comments on commit 40dfd1e

Please sign in to comment.