One of the most critical things in terms of driver feedback is making the error warnings as clear as possible. In a critical engine protection situation the last thing you want is the driver not being sure what he needs to do.
Because of this the EML light should have 2 stages:
1. Solid on light - meaning there is an issue and reducing speed/demand/aggression is advised but there is no need to immediately stop driving.
2. Flashing light - Lift off immediately and check error.
Current status - Knock sensors work, we have reliable logging of signals, we have some level of noise threshold working, we have know windowing working, we have auto calculation of the second harmonic?
1. Retard timing to reduce rate of pressure rise, requires:
Value for max total retard allowed, value for retard per knock event, strategy to re-advance one or two degrees per no-knock cycle.
Should probably be done as soon as knock is detected above the noise threshold.
2. Enrich mixture. Works by cooling the cylinder and reducing the chance of being lean.
Should be done in the event that initial spark intervention is not enough to stop knock by the retard limit.
Should also be the first action if AFR is below target when knock is detected. Suggest this setting an enrichment of 0.1 lambda.
This should probably activate and stay on for x number of engine cycles.
Requires:
3. MAP pressure reduction.
2 ways to do this, either close ETB or open wastegate (or both).
Should be designed to be user configurable as to the level of intervention and which method to take.
Requires: max allowed pressure reduction by ETB, toggle option for etb, toggle option for wastegate, maybe a max pwm duty cycle increase for wastegate.
Should remain on until driver lifts throttle to prevent surging. Should be the next action after the enrichment if knock still present.
I.e. above user defined EGT spark max retard is reduced to user defined level and meth is activated as soon as knock is detected.
Requires: flag "has water meth", user defined EGT limit, maybe water meth pin assignment, user defined water meth pwm? Trigger water meth from gpio table?
5. Extreme case cut fuel and ignition for x cycles to reduce the in cylinder temperatures before re-enabling as a last ditch to keep auto ignition down.
As we schedule events individually we could cut the cylinder that was detected to be high, this would require killing the injector for just that cylinder or for the batch.
### Low fuel pressure or max injector duty cycle
Main thing to avoid here is leanout, fuel pressure compensation is going to deal with a lot of the problem as the pressure drop but at some point it will reach the max injector duty cycle.
Possible ways to mitigate this are to limit RPM, limit boost and/or limit pedal to achieve the previous.
### ETB deviation error
Implies a loss or lack of accurate control of the ETB, this should probably be considered a serious error resulting in a flashing EML.
As these are "fatal" we should likely treat them as such and perform a controlled shutdown.
In this case it would be to deactivate injection and ignition and close ETB.
This MUST only be the case for truly fatal errors where the consequences of keeping the engine running are worse than leaving someone with a total loss of power (even if it is done in a controlled fashion), again this is a case where a flashing EML is needed.