letsteyr wrote:- AFR:
for subarus, AFR = 14.7/ (1+ value)*.0078125
why 0.0078125 ? what are the orginal values (unit) we got in afr tables? It's an enrechiment comparing to 14.7? (0 for 14.7)?
The 0.078125 is because the value is stored as a single byte, 8bit integer. So the values for X are 0, 1, 2... 254, 255. 127 would be 1.0 Lambda, or no enrichment. A value of 191 would be an enrichment factory of 1.5, or 9.8 AFR. Basically, the conversion equation you see in the def is converting the integer value stored by the ECU back into what we guess (or imply, or know from other disassembly of how the value is actually used later) the actual unit of measure is meant to be. Realistically, everything in the ECU is actually in lambda, not AFR. "14.7" is pretty much nowhere in the ECU at all, but "0.0078125" certainly is.
Same goes for the logger. When the logger asks the ECU for the O2 sensor reading and it sends back the integer value 127 (or 0x7F in hex), your logger will show you 14.7 due to this conversion equation. These conversion equations vary.
- advance:
for subarus we got advance = ([value]*.3515625)-20
why 20 and 0.3515625? what's the original unit of mesure? What do we physically get?
Same deal here. It is the conversion factory for how the ignition timing is converted to be stored into a single byte, 8bit integer value. So with valid values for [value] from 0 to 255, you can set from -20 to +69 (BTDC) with a precision of 0.3515625. Ignition timing is always degrees before top dead center (*BTDC).
I know that internally, some of the ECUs actually only allow -20 to +60. But, at least that equation would technically allow +69 even if it is clipped to +60 later in the code. In the DBW ECU, the map is read, it is clipped from -20 to +60, compensations are applied, then it is clipped from -20 to +60 AGAIN, more compensations are applied, it gets clipped again... Don't ask me why, but really, you won't need to go further than 0 to +50 anyway.
- RPM:
what's the link beeteween the number of teeth of the flywheel and the rpm we get? With what unit does the ecu work?
The ECU uses RPM for almost everything. It is easily the most common parameter used throughout the ECU. It must derive this from the crank position sensor somehow. I have never spent too much time looking into this, but there has to be some input pin on the ECU getting the signal and counting teeth and dividing by time. You'd have to look at your crank position sensor and wheel to determine this. I know on Subaru's it is an odd sort of spacing for the teeth on the crank position wheel. I'd guess the teeth literally trigger a hardware interrupt in the ECU, or possibly there are other electronics on the mainboard to handle this. Again, just guesses, as I don't have any real reason to spend time researching exactly how it is handled.
I can say it seems the ECU gets a value in the unit of meaure of RPM and uses that throughout the code. Your Bosch may be different, but at least the HC16 and SH-2 do this.