PDA

View Full Version : Disassembly: Knock and Octane code



Greg E
03-13-2012, 02:13 PM
After a few months of staring at letters and numbers (and a few fights with the girl over obsessing with the computer screen), and thanks to Merlins EVO tuning guide (http://www.evoscan.com/ecuflash/Merlins%20EcuFlash%20EVO%207-8-9%20TUNING%20GUIDE-V1.7a.pdf), I think I finally have a good grasp on how the Flashable ECUs calculate KnockSum and use the Octane value. There are many similarities between the code logic in our cars and the EVOs, but ours is a bit more primitive.

We start off with the KnockBase which is the the ground filter for tuning out frequencies. When a signal spike from the knock sensor exceeds this Base filter, it's regarded as knock. This filter level is derived from the knock sensor RAW value (signals from the knock sensor itself) then is passed thru 2 amplifiers which are called the single and triple gain amplifiers. What these amplifiers do is they filter out background noise and amplify low level signals. The ECU has an analog to digital converter (ADC) which takes these signals and multiplies them by something called the Knock Multiplier value with the single/triple gain adders applied.

This multiplier is used to multiply the difference between the filtered knock and the long term average knock. The result is divided by the long term average knock.

Knock_Muliplier * (KnockBase - Average_LT_Knock)/Average_LT_Knock

Basically all this does is it gives the code the ability to learn the engine noises during various RPMs. The 3/S has 2 multipliers. One for low load and one for high load conditions. For some reason, they made both these multiplier values the same in the code...

The code uses RPM to switch between the single and triple gain adders.

The KnockBase is updated by taking the old value * 7 then adds the latest knock free noise level and divides all that by 8. So it takes 8 ignition events to fully update the KnockBase.

http://i.imgur.com/fdOjZ.jpg



*Ignition Retard*

The ECU has a safety feature coded where it will reduce timing advance when knock is detected. It does this by taking the current timing value and divided it by 90 then subtracts 231 from the result and stores this for later. Knocksum is then added to this value.

So, here's the formula the ECU uses to reducing ignition timing:

knocksum*90/256

In other words, every knock count takes about .32 degrees of timing away from advancement!



*Fuel Enrichment*

The ECU also has a safety feature coded where it will enrichen the fuel mixture when a knocksum > 6 is detected. It takes your current AFR value from your fuel table, divides it by 160. There also appears to be a table look up which I *think* is just a maximum enrichment based on coolant temp (all the values are the same and the AFR value translated from hex the values is 8.7). All this means is the farthest the ECU will enrichen your mixture is an AFR of 8.7.

Let me give an example:

Lets say in your High Octane fuel table, you have the value of 11.8 in the cell the ECU is currently looking up and you have a knock count of 12.

(12-6)*160/256 = 3 (rounded down)

The AFR values in the table comes from this equasion: 14.7*128/x
So in this case AFR of 11.8 in the table converts to 159.

Add 4 to that and we have 161.

Converting 161 back to AFR is 11.6. This this 11.6 is your new AFR number.

Keep in mind, a knock sum of 12 will bring down the octane number which will interpolate between your High & Low Octane Tables. These 2 functions are completely separate from the Octane function which simply interpolates between the High and Low octane tables.



*Octane*

Another area of our code which is a bit primitive to the EVO are the conditions which the ECU uses this value:

Coolant temp > 178 degF
Load > 70 (temperature and barometric compensated)
RPMs must be between 1812rpms and 7500rpms

Those of you who wish to run a higher redline might want to extend the high value! The max you can set it to is only 7900 though... This is the 1 byte limitation.

Just like the DSM and EVO, a knock count of < 3 adds to the Octane value and a knock count > 5 takes away from it. Give me some more time to figure out what the hex values mean and I can tell you how quickly and how much it adds or takes away from this value.


...my brain hurts. :Doh:

BigTyla
03-13-2012, 02:29 PM
Great info! Looks like a lot of progress is being made in the flashable ECU territory.

HilbillyHomeboy
03-13-2012, 02:34 PM
Nice work, Greg. Really appreciate all your effort. :)

Jeremy

vroom4
03-13-2012, 02:55 PM
Next up, time travel using 98 ecu.

Boostaddict
03-14-2012, 10:25 AM
Very cool. Thanks for all the effort!

NOMIEZVR4
03-14-2012, 11:31 AM
good stuff man...:)

R/T93
03-14-2012, 04:04 PM
Excellent work, Greg.

UTRacerX9
03-14-2012, 04:46 PM
These calculations are only for 98/99 ECU's, correct? Because I am pretty sure I've seen knocksum tables from the other site back in the day (that Mjannusch compiled maybe?) where a knock count up to 5-8 didn't affect timing. I also remember Jeff Lucius saying something similar, that small counts of knock were basically disregarded from the ECU.

This was back before we knew anything about 98/99 ECUs so Mitsu may have changed more than was previously thought in 98-99 cars.

Greg E
03-14-2012, 05:06 PM
These calculations are only for 98/99 ECU's, correct? Because I am pretty sure I've seen knocksum tables from the other site back in the day (that Mjannusch compiled maybe?) where a knock count up to 5-8 didn't affect timing. I also remember Jeff Lucius saying something similar, that small counts of knock were basically disregarded from the ECU.

This was back before we knew anything about 98/99 ECUs so Mitsu may have changed more than was previously thought in 98-99 cars.

I haven't seen the code so I couldnt tell you. Jeff has 90% of the 94 ROM disassembled so he's better qualified to answer that.

Greg E
04-16-2012, 04:08 PM
There's a lot of debate going on (still) about the differences between the knock sensor circuits between the various flashable ECUs. I can tell you if there are differences, it doesn't matter. Neither side of the debate disagrees that the sensor itself communicates with the ADC chip. The disagreement comes from the path the signal takes to get there and it somehow having an effect.

From a software standpoint, Mitsubishi uses the same logic for calculating knock sum on every single vehicle equipped with a knock sensor from 91 till now (that I'm aware of). Though the filtering points may change between various motors, the process is always the same. It's not like the ECU has an ear to the motor listening for a specific sound... it hears everything and filters out what you tell it to.

Tuning the knock sensor filters is no different than tuning your fuel injectors for the proper AFR. Every motor is different and you might find you will have to make some adjustments as you're logging your car.

So let's say even if there is something different about the signal path for the knock raw voltage it doesn't matter. You can adjust the code filtering for any variants. Just like you'll have to adjust these tables to suit your VR4 motor with 150k or even your freshly built forged bottom end....

Jeff V.
04-16-2012, 04:56 PM
These calculations are only for 98/99 ECU's, correct? Because I am pretty sure I've seen knocksum tables from the other site back in the day (that Mjannusch compiled maybe?) where a knock count up to 5-8 didn't affect timing. I also remember Jeff Lucius saying something similar, that small counts of knock were basically disregarded from the ECU.

The prior ECUs were a little different, but still VERY similar to how the 98-99 stuff works. Any knock count affects timing, but it isn't until you get to 6 or higher that it starts hitting the octane counter, which starts to push you down onto the low octane fuel and timing tables.

It's basically a timeline like this:

1G DSM ECU - extensive hardware filtering
Pre-OBD 3S ECU - mix of hardware and software filtering
OBD 3S ECU - extensive software filtering
Evo 7 and later ecu - almost entirely software based

Around 96-ish, Mitsu started to go to common logic across all their engine lines so that everything used the same electronics and software. Prior to 96, everything was a mish-mash and mostly platform-specific.

UTRacerX9
04-16-2012, 05:10 PM
Thank you for the clarification Jeff.

Toni
09-25-2013, 01:57 PM
Greg, can you elaborate on how the triple/single gain get added in? More importantly, how they affect the knocksum sensitivity.

Currently I have :
single 8
triple 30

stock is
single 6
triple 28


Thanks!

Greg E
09-25-2013, 02:26 PM
I've kinda avoided posting too much detail on how the system works because I don't want people blowing up their engines. It takes a trained eye to understand the difference between engine noise and real knock.

I had to raise the triple gain on your car because your engine noise levels would creep above the knock base threshold. This threshold kinda works similar to a fuel trim where there is a base factor, correction factor and anything above that calculated noise level is considered knock.

As the engine makes more power (or just ages) the noise level gets louder and louder. The code is setup to monitor this noise level. Eventually though, it comes to the point where the ECU can't compensate anymore for the noise level and thus you get false knock.

Your engine being fresh wasn't too bad in terms of noise level but I still had to raise the triple gain to get some leeway in the upper RPMs. That's why the increase was done.

Remember us logging the raw knock voltage and looking at the graph to determine if the noise spikes were real knock or just engine noise?

Toni
09-25-2013, 02:56 PM
Yup, I just wanted to make sure the numbers I have make sense now. We did that a while ago and I remember changing it at the track at the NG. Just wanted to make sure I wasn't copying over bad values from an old config or something that I accidentally changed.

Thanks!