Go Down

Topic: ISO 9141-2 - Problem with timing? (I think) (Read 108 times) previous topic - next topic

VaZZoN

Hi!
I have a problem with connecting and transmitting data through ISO 9141-2 (K-Line).
Initating connection is simple but I have problem even with that.
There is code I am using: link.
That's not my code. I have copied it from there and modified to my use. Scheme is also on this site, except that I am using BC 337 transistors. Everything is soldered except of power to arduino and rx and tx lines, they are fixed by screw connectors.
First problem is with init_5baud() function (34 line). Sometimes it crashes on checking if sync byte is 0x55. Sometimes it get error sync timeout.
Second problem is with disp() function (1017 line). Engine coolant temp doesn't work at all. I get strange numbers like 430545039. RPM works, but in some iterations it shows 750RPM no matter what is actual RPM. Same with VSS, it happens on the same iteration but value is 17. IAT works but randomly it shows an odd, random value like engine coolant temp.
One of my thoughts is that timing is wrong. Something with delay values. I have read that delay between two bytes in request should be 5ms and delay between two requests should be 55ms and it is.
Any help?
Thanks in advance!

PaulS

Quote
That's not my code. I have copied it from there and modified to my use.
So, we don't know what code you are using. But, you expect us to tell you what is wrong with it. An unrealistic expectation, if you ask me.
The art of getting good answers lies in asking good questions.

VaZZoN

I've misspelled it.
What I meant was that I am not author of this code. I've only modified that code and code in pastebin is the code I am using.
Now by testing that with serial monitor I can see that sometimes on byte 0 of responseBuffer there is 0xC0 or 0xD0 or 0xC1 and responseBuffer is shifted to right by one. So for example temp is present not on 5th byte but on 6th (counting from 0).
Also I don't know why I can't connect with ecu again. Nothing is shorted on PCB, everything is connected, circuit has continuity.

VaZZoN

I've fixed problem with initiation. It was simple hardware problem - faulty transistor. Replaced with a new one and it works.
Also I've fixed a problem with responseBuffer but not in a way that I would want to fix it.
I am just checking
Code: [Select]
if(responseBuffer[0][0] != 0x48) If that's true, I am just shifting bytes of data to a previous one byte. For example:
Code: [Select]
responseBuffer[0][5] = responseBuffer[0][6];.
I want to get good solution of that problem, not how I did it. If someone has any ideas what could be wrong, it will be great.

Go Up