debug fields for #568

This commit is contained in:
rusefi 2018-02-07 00:21:41 +03:00
parent f92c7e0993
commit 6f466c97fd
7 changed files with 43 additions and 23 deletions

View File

@ -75,6 +75,10 @@ extern bool main_loop_started;
#include "CJ125.h" #include "CJ125.h"
#endif /* EFI_PROD_CODE */ #endif /* EFI_PROD_CODE */
#if EFI_MAP_AVERAGING
#include "map_averaging.h"
#endif
#if EFI_FSIO || defined(__DOXYGEN__) #if EFI_FSIO || defined(__DOXYGEN__)
#include "fsio_impl.h" #include "fsio_impl.h"
#endif /* EFI_FSIO */ #endif /* EFI_FSIO */
@ -808,6 +812,11 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_
cjPostState(tsOutputChannels); cjPostState(tsOutputChannels);
break; break;
#endif /* EFI_CJ125 */ #endif /* EFI_CJ125 */
#if EFI_MAP_AVERAGING
case DBG_MAP:
postMapState(tsOutputChannels);
break;
#endif /* EFI_MAP_AVERAGING */
#if EFI_CAN_SUPPORT || defined(__DOXYGEN__) #if EFI_CAN_SUPPORT || defined(__DOXYGEN__)
case DBG_CAN: case DBG_CAN:
postCanState(tsOutputChannels); postCanState(tsOutputChannels);

View File

@ -713,8 +713,8 @@ case DBG_CJ125:
return "DBG_CJ125"; return "DBG_CJ125";
case DBG_CAN: case DBG_CAN:
return "DBG_CAN"; return "DBG_CAN";
case DBG_27: case DBG_MAP:
return "DBG_27"; return "DBG_MAP";
case DBG_28: case DBG_28:
return "DBG_28"; return "DBG_28";
case DBG_29: case DBG_29:

View File

@ -763,7 +763,7 @@ typedef enum {
DBG_STATUS = 24, DBG_STATUS = 24,
DBG_CJ125 = 25, DBG_CJ125 = 25,
DBG_CAN = 26, DBG_CAN = 26,
DBG_27 = 27, DBG_MAP = 27,
DBG_28 = 28, DBG_28 = 28,
DBG_29 = 29, DBG_29 = 29,

View File

@ -55,7 +55,7 @@
#define MAP_ACCEL_TAPER 8 #define MAP_ACCEL_TAPER 8
#define BARO_CORR_SIZE 4 #define BARO_CORR_SIZE 4
#define MAF_DECODING_COUNT 256 #define MAF_DECODING_COUNT 256
#define debug_mode_e_enum "Alternator_PID", "TPS accel enrich", "Warmup PID", "IDLE", "EL accl enrich", "Trigger Counters", "FSIO_ADC", "AUX_PID_1", "VVT PID", "Cranking", "Timing", "Closed-loop fuel corr PID", "VSS", "SD card", "sr5", "Knock", "Trigger Sync", "Electronic Throttle", "Executor", "Bench Test", "Aux Valves", "ADC", "INSTANT_RPM", "FSIO_EXPRESSION", "Status", "CJ125", "CAN", "mode27", "mode28", "mode29" #define debug_mode_e_enum "Alternator_PID", "TPS accel enrich", "Warmup PID", "IDLE", "EL accl enrich", "Trigger Counters", "FSIO_ADC", "AUX_PID_1", "VVT PID", "Cranking", "Timing", "Closed-loop fuel corr PID", "VSS", "SD card", "sr5", "Knock", "Trigger Sync", "Electronic Throttle", "Executor", "Bench Test", "Aux Valves", "ADC", "INSTANT_RPM", "FSIO_EXPRESSION", "Status", "CJ125", "CAN", "MAP", "mode28", "mode29"
#define vvt_mode_e_enum "First half", "Second half", "2GZ", "Miata NB2", "mode4", "mode5", "mode6", "mode7" #define vvt_mode_e_enum "First half", "Second half", "2GZ", "Miata NB2", "mode4", "mode5", "mode6", "mode7"
#define mass_storage_e_enum "Auto", "Always", "Never" #define mass_storage_e_enum "Auto", "Always", "Never"
#define brain_input_pin_e_enum "INVALID", "PA1", "PA2", "PA3", "INVALID", "PA5", "PA6", "PA7", "PA8", "PA9", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "PA15", "INVALID", "INVALID", "INVALID", "PB3", "PB4", "PB5", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "PC6", "PC7", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "PE5", "PE6", "INVALID", "INVALID", "PE9", "INVALID", "PE11", "INVALID", "INVALID", "INVALID", "INVALID", "NONE", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID" #define brain_input_pin_e_enum "INVALID", "PA1", "PA2", "PA3", "INVALID", "PA5", "PA6", "PA7", "PA8", "PA9", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "PA15", "INVALID", "INVALID", "INVALID", "PB3", "PB4", "PB5", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "PC6", "PC7", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "PE5", "PE6", "INVALID", "INVALID", "PE9", "INVALID", "PE11", "INVALID", "INVALID", "INVALID", "INVALID", "NONE", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID"

View File

@ -69,7 +69,7 @@ static int counters[2];
/** /**
* Running MAP accumulator - sum of all measurements within averaging window * Running MAP accumulator - sum of all measurements within averaging window
*/ */
static volatile float mapAccumulator = 0; static volatile float mapAdcAccumulator = 0;
/** /**
* Running counter of measurements to consider for averaging * Running counter of measurements to consider for averaging
*/ */
@ -110,7 +110,7 @@ static void startAveraging(void *arg) {
bool wasLocked = lockAnyContext(); bool wasLocked = lockAnyContext();
; ;
// with locking we would have a consistent state // with locking we would have a consistent state
mapAccumulator = 0; mapAdcAccumulator = 0;
mapMeasurementsCounter = 0; mapMeasurementsCounter = 0;
isAveraging = true; isAveraging = true;
if (!wasLocked) if (!wasLocked)
@ -163,7 +163,7 @@ void mapAveragingAdcCallback(adcsample_t adcValue) {
; ;
// with locking we would have a consistent state // with locking we would have a consistent state
mapAccumulator += adcValue; mapAdcAccumulator += adcValue;
mapMeasurementsCounter++; mapMeasurementsCounter++;
if (!alreadyLocked) if (!alreadyLocked)
unlockAnyContext(); unlockAnyContext();
@ -177,8 +177,7 @@ static void endAveraging(void *arg) {
isAveraging = false; isAveraging = false;
// with locking we would have a consistent state // with locking we would have a consistent state
#if EFI_PROD_CODE || defined(__DOXYGEN__) #if EFI_PROD_CODE || defined(__DOXYGEN__)
v_averagedMapValue = adcToVoltsDivided( v_averagedMapValue = adcToVoltsDivided(mapAdcAccumulator / mapMeasurementsCounter);
mapAccumulator / mapMeasurementsCounter);
// todo: move out of locked context? // todo: move out of locked context?
averagedMapRunningBuffer[averagedMapBufIdx] = getMapByVoltage(v_averagedMapValue); averagedMapRunningBuffer[averagedMapBufIdx] = getMapByVoltage(v_averagedMapValue);
// increment circular running buffer index // increment circular running buffer index
@ -208,6 +207,12 @@ static void applyMapMinBufferLength() {
} }
} }
void postMapState(TunerStudioOutputChannels *tsOutputChannels) {
tsOutputChannels->debugFloatField1 = v_averagedMapValue;
tsOutputChannels->debugFloatField2 = engine->engineState.mapAveragingDuration;
tsOutputChannels->debugIntField1 = mapMeasurementsCounter;
}
void refreshMapAveragingPreCalc(DECLARE_ENGINE_PARAMETER_SIGNATURE) { void refreshMapAveragingPreCalc(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
int rpm = engine->rpmCalculator.rpmValue; int rpm = engine->rpmCalculator.rpmValue;
if (isValidRpm(rpm)) { if (isValidRpm(rpm)) {
@ -267,20 +272,25 @@ static void mapAveragingTriggerCallback(trigger_event_e ckpEventType,
} }
angle_t samplingEnd = samplingStart + samplingDuration; angle_t samplingEnd = samplingStart + samplingDuration;
if (!cisnan(samplingEnd)) {
fixAngle(samplingEnd, "samplingEnd");
// only if value is already prepared
int structIndex = getRevolutionCounter() % 2;
// todo: schedule this based on closest trigger event, same as ignition works
scheduleByAngle(rpm, &startTimer[i][structIndex], samplingStart,
startAveraging, NULL, &engine->rpmCalculator);
scheduleByAngle(rpm, &endTimer[i][structIndex], samplingEnd,
endAveraging, NULL, &engine->rpmCalculator);
engine->m.mapAveragingCbTime = GET_TIMESTAMP()
- engine->m.beforeMapAveragingCb;
}
}
if (cisnan(samplingEnd)) {
// todo: when would this happen?
warning(CUSTOM_ERR_6549, "no map angles");
return;
}
fixAngle(samplingEnd, "samplingEnd");
// only if value is already prepared
int structIndex = getRevolutionCounter() % 2;
// todo: schedule this based on closest trigger event, same as ignition works
scheduleByAngle(rpm, &startTimer[i][structIndex], samplingStart,
startAveraging, NULL, &engine->rpmCalculator);
scheduleByAngle(rpm, &endTimer[i][structIndex], samplingEnd,
endAveraging, NULL, &engine->rpmCalculator);
engine->m.mapAveragingCbTime = GET_TIMESTAMP()
- engine->m.beforeMapAveragingCb;
}
} }
static void showMapStats(void) { static void showMapStats(void) {

View File

@ -18,6 +18,7 @@ void mapAveragingAdcCallback(adcsample_t newValue);
void initMapAveraging(Logging *sharedLogger, Engine *engine); void initMapAveraging(Logging *sharedLogger, Engine *engine);
void refreshMapAveragingPreCalc(DECLARE_ENGINE_PARAMETER_SIGNATURE); void refreshMapAveragingPreCalc(DECLARE_ENGINE_PARAMETER_SIGNATURE);
void postMapState(TunerStudioOutputChannels *tsOutputChannels);
#endif /* EFI_MAP_AVERAGING */ #endif /* EFI_MAP_AVERAGING */

View File

@ -148,7 +148,7 @@ float baseFuel;+Fuel squirt duration while cranking\nA number of curves adjust t
int16_t rpm;+Cranking mode threshold. Special cranking logic controls fuel and spark while RPM is below this threshold\nset cranking_rpm X;"RPM", 1, 0, 0, 3000, 0 int16_t rpm;+Cranking mode threshold. Special cranking logic controls fuel and spark while RPM is below this threshold\nset cranking_rpm X;"RPM", 1, 0, 0, 3000, 0
end_struct end_struct
#define debug_mode_e_enum "Alternator_PID", "TPS accel enrich", "Warmup PID", "IDLE", "EL accl enrich", "Trigger Counters", "FSIO_ADC", "AUX_PID_1", "VVT PID", "Cranking", "Timing", "Closed-loop fuel corr PID", "VSS", "SD card", "sr5", "Knock", "Trigger Sync", "Electronic Throttle", "Executor", "Bench Test", "Aux Valves", "ADC", "INSTANT_RPM", "FSIO_EXPRESSION", "Status", "CJ125", "CAN", "mode27", "mode28", "mode29" #define debug_mode_e_enum "Alternator_PID", "TPS accel enrich", "Warmup PID", "IDLE", "EL accl enrich", "Trigger Counters", "FSIO_ADC", "AUX_PID_1", "VVT PID", "Cranking", "Timing", "Closed-loop fuel corr PID", "VSS", "SD card", "sr5", "Knock", "Trigger Sync", "Electronic Throttle", "Executor", "Bench Test", "Aux Valves", "ADC", "INSTANT_RPM", "FSIO_EXPRESSION", "Status", "CJ125", "CAN", "MAP", "mode28", "mode29"
custom debug_mode_e 4 bits, U32, @OFFSET@, [0:4], @@debug_mode_e_enum@@ custom debug_mode_e 4 bits, U32, @OFFSET@, [0:4], @@debug_mode_e_enum@@
#define vvt_mode_e_enum "First half", "Second half", "2GZ", "Miata NB2", "mode4", "mode5", "mode6", "mode7" #define vvt_mode_e_enum "First half", "Second half", "2GZ", "Miata NB2", "mode4", "mode5", "mode6", "mode7"