FAQFAQ SearchSearch MemberlistMemberlist UsergroupsUsergroups RegisterRegister
ProfileProfile Log in to check your private messagesLog in to check your private messages Log inLog in

M3.3.1 motronic (413 and 506) tuning and XDF update?
Goto page Previous  1, 2, 3, 4, 5
Post new topic   Reply to topic    TunerPro User Forum Forum Index -> Bosch

Joined: 20 Jun 2017
Posts: 139

PostPosted: Wed Feb 14, 2018 12:00 pm    Post subject: Reply with quote

To back you up on that the E30 thermostat is 80 to 88 degrees and that is central/vertical on my gauge, I hit that last cell while still at the 1/4 mark on the gauge, so likely about 50-60 degrees.

I have been plugging it into a few tables today to see how if fits, looks ok but might be worth testing this out on a few other tables.

It seems to work for the D4 IAT as well but I could only find one table with D4 on.

If you wanted to test it put a resistor with a value matching one of the temperatures in place of the CLT and check what cell that puts the ECU into. I believe that table is always active even at idle so it should be easy to check.

It would imply that there is no CLT or IAT transfer function though, with no requirement to work across several different kinds of hardware and no need to spit out OBD2 PIDs there is no need for the temperature to be anything but an abstraction in the code.
A simple more=more value in the code with the only direct relation to temperature being the voltage to the A2D converter, more temperature=more voltage=higher value with no direct conversion factor.
Back to top
View user's profile Send private message


Joined: 26 Jul 2016
Posts: 78
Location: Finland

PostPosted: Wed Feb 14, 2018 12:40 pm    Post subject: Reply with quote

Hairyscreech wrote:
I believe this is simply the raw 256 bit values from the A2D converter. I get that the A2D is 10bit and would then have to convert into 8bit somewhere in the code, that would simply be the 0-1023 converted to 0-255.

The A2D works from 0-5v, with 255 values available that's 0.019531V/value.
The sensor is not liner but using the calculations I put on the "M5x temp sensors" sheet in the dropbox and working out the voltages expected at the A2D based on the voltage divider layout and using this V/value I built a table of temperature Vs D7 value.
I found that the a 0v value would be ~-40 DegC and a 5v value ~215 DegC.
While the sensor would never actually measure a full 0v or 5v due to the way it works and should never see these kind of temperatures is gave me the boundaries.

I have updated the sheet in the dropbox to show this working so if anyone wants to double check it then feel free, the more eyes checking these things the better.

Plugging the resulting numbers into the D7 based tables gives some sensible results:
The "coolant temp correction for acceleration" table has the following:
Raw value - 49 103 143 175
Temp DegC - 0 30 50 66

Running the car from cold results in a steady climb up that table and it sits in the 66+ cell once 3/4 warm. (E30 temp gauge so not electrically damped like an E36).

I am going to put the values into some of the unknown D7 tables and see what temperatures it suggests, it will help confirm if the theory is correct and maybe what those tables are. Question
10bit A/D converter can be used in 8bit by using only 8 most significant bits.
Example: register addresses 46 and 47 seems to be MAF values. So, they are 16bit, but i didn't note which is 8 most significant. But, if other one is overflowed, it increses by one that other one, and that overflowed will start from zero. If you read only that "increase one by overflow" you get 8bit maf value.
Back to top
View user's profile Send private message


Joined: 20 Jun 2017
Posts: 139

PostPosted: Thu Feb 15, 2018 12:28 am    Post subject: Reply with quote

Its interesting you post that as it looks like some of the code does that to get offsets, there are a couple of times something is added to an Exxxh or Fxxxh number and put into an 8 bit register, this obviously can only drop the extra values off the end of the register.
Seems like it is a dirty trick to prevent having to subtract numbers. (which I think is more processor intensive?)

I'm not sure the A2D converter is used like that though as the values in the tables suggest a full range scaled down to 8bit with 255 meaning 5v (about 215 DegC).
Unless I am understanding the math/mechanics of the thing?
Are you suggesting it could be 0-1020 by only using the first 8bits of the 10bit value?
Essentially dropping the first 2 bits and making the value off by 3?

Edit - I think I just got it, in the first example it would be dropping the most significant bit/bits and essentially "going around the clock" to get back from high hex values to low hex values but the A2D example is a little different:

If the value is 10 bits then 1/2 = 512 = 10 0000 0000.
Dropping the first 2 bits gives 10 0000 00| (00 dropped) and thus 8bit 128 value.
The way binary works you wont fill up the most significant bits until the highest values for a given number of bits, so discarding the least significant automatically converts to a different size without changing the numbers % value.
70% of 10 bits becomes 70% of 8 bits by just dropping the first 2 bits.

I just had a play and it actually converts 10bit numbers to 8bit very well, it is an elegant solution that saves a lot of math in the processor.
(I did say my computer science was lacking - Laughing )

I gather this will mean if I have a quick hunt for some 10 to 16 bit values and take a look to see if some are being addressed in a funny way or are being deliberately bit shifted then we might find the A2D code?
Back to top
View user's profile Send private message


Joined: 26 Jul 2016
Posts: 78
Location: Finland

PostPosted: Thu Feb 15, 2018 12:03 pm    Post subject: Reply with quote

Direct copy from 80196 user's manual A/D section:


Analog Inputs to the 80C196KB System are handled
by the A/D converter System. As shown in Figure
11-4, the converter system has an 8 channel multiplexer,
a sample-and-hold, and a 10 bit successive approximation
A/D converter. Conversions can be performed
on one of eight channels, the inputs of which share pins
with port 0. A conversion can be done in as little as 91
state times.

Conversions are started by loading the AD_COMMAND
register at location 02H with the channel number.
The conversion can be started immediately by setting
the GO bit to a one. If it is cleared the conversion
will start when the HSO unit triggers it. The A/D command
register must be written to for each conversion,
even if the HSO is used as the trigger. The result of
the conversion is read in the ADÐRESULT(High)
and AD_RESULT(Low) registers. The AD_RESULT(
High) contains the most significant eight bits of
the conversion. The AD_RESULT(Low) register contains
the remaining two bits and the A/D channel number
and A/D status. The format for the AD_COMMAND
register is shown in Figure 11-1. In Window
15, reading the AD_COMMAND register will read
the last command written. Writing to the AD_RESULT
register will write a value into the result register."


0 Channel selection (+1)
1 Channel selection (+2)
2 Channel selection (+4)
3 GO-bit (when written to "1" conversion will start asap)
4 X
5 X
6 Least significant result bit
7 Second least significant result bit

By reading 02H is used to check ADC status and last used channel. Bit 3 will clear to "0" automatically, when conversion is finished, so, when reading 02H and bit 3 is "1" it means AD conversion is running, converter is busy.
Back to top
View user's profile Send private message


Joined: 20 Jun 2017
Posts: 139

PostPosted: Fri Feb 16, 2018 5:24 am    Post subject: Reply with quote

Well noted. Very Happy

I have used that to edit the disassembly I have and it highlights the times when the program uses the A2D quite well.

Just by spotting the A2D write on 02H and then read on 03H then 02H you can find all 5 reads of the A2D in the 413 ROM.

Lets see if anything useful can come of that.

Edit - Further note, anywhere the program has a JBS (jump if bit set) for the AD command register 02H then it is waiting for the A2D read to finish.
That's done to put the program into a brief loop to give the ~42 micro seconds for the A2D to finish.

This is all becoming a little bit too much like learning things... Laughing
Back to top
View user's profile Send private message

Display posts from previous:   
View previous topic :: View next topic  
Post new topic   Reply to topic    TunerPro User Forum Forum Index -> Bosch All times are GMT - 9 Hours
Goto page Previous  1, 2, 3, 4, 5
Page 5 of 5
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2001, 2002 phpBB Group
RedSquare theme 1.0.3 © DoubleJ(Jan Jaap)