Comunicating Uno & ISO9141-2

Hello, I´ve read the forums but didn´t found answers to my situation.

This is circuit, that I am using (in red is my correction)

The code is below... according my osciloscope, communications seems right (Kline is +12 and pulled to GND for 200/400ms).

But despite that i got no answer from vehicle. The vehicle is VW and uses EDC15p if someone is familiar with.

Can someone help me please? It would be much appreciated.

#include "Arduino.h"
#include "OBD9141.h"

#define RX_PIN 2
#define TX_PIN 3
#define EN_PIN 4

AltSoftSerial altSerial;

OBD9141 obd;

void setup(){
Serial.begin(9600);
delay(2000);

pinMode(EN_PIN, OUTPUT);
digitalWrite(EN_PIN, HIGH);

obd.begin(altSerial, RX_PIN, TX_PIN);

}

void loop(){
Serial.println("Looping");

bool init_success = obd.init();
Serial.print("init_success:");
Serial.println(init_success);

//init_success = true;
// Uncomment this line if you use the simulator to force the init to be
// interpreted as successful. With an actual ECU; be sure that the init is
// succesful before trying to request PID's.

if (init_success){
bool res;
while(1){
res = obd.getCurrentPID(0x11, 1);
if (res){
Serial.print("Result 0x11 (throttle): ");
Serial.println(obd.readUint8());
}

res = obd.getCurrentPID(0x0C, 2);
if (res){
Serial.print("Result 0x0C (RPM): ");
Serial.println(obd.readUint16()/4);
}

res = obd.getCurrentPID(0x0D, 1);
if (res){
Serial.print("Result 0x0D (speed): ");
Serial.println(obd.readUint8());
}
Serial.println();

delay(200);
}
delay(200);
}
delay(3000);
}

#define RX_PIN 2
#define TX_PIN 3
#define EN_PIN 4

AltSoftSerial altSerial;

...

    obd.begin(altSerial, RX_PIN, TX_PIN);

AltSoftSerial doesn't run on pins 2 and 3. And AltSoftSerial doesn't allow for changing the pins, they're fixed.

I’ve used the SoftwareSerial class with success, but if the k-line is going low you’re serial interface is working, but:

1: By iso9141 spec resistor R4 should be 510 Ohms, not 10 kOhms. This may be under-driving the k-line so the ECU don’t pick up the presence of the test node? R3 & R5 may need to be smaller value to saturate Q2... personally I’m using
R1 = 10k ohm
R2 = 47k - (Rx) - 33k
R3 = 3k6
R4 = 0k510
R5 = 1k6

q1, q2 = 2N390 NPN
(40v, 200mA)

2: What init sequence does the ECU model expect and respond to? 5-baud or a Fast-Init? Does it require use of the L-Line? (I haven’t looked at the obd9141 library in a while, but recall it tries a 5-baud then tries a FastInit)
Does the library send a BeginComms request packet for you or do you need to do that at the user level?

pylon:
AltSoftSerial doesn't run on pins 2 and 3. And AltSoftSerial doesn't allow for changing the pins, they're fixed.

Hello, thanks for reply. I think it´s working just fine. Autor of the library used the same library with arduino uno. Plus you can see the result on oscilloscope.

Nautamaran:
I’ve used the SoftwareSerial class with success, but if the k-line is going low you’re serial interface is working, but:

1: By iso9141 spec resistor R4 should be 510 Ohms, not 10 kOhms. This may be under-driving the k-line so the ECU don’t pick up the presence of the test node? R3 & R5 may need to be smaller value to saturate Q2... personally I’m using
R1 = 10k ohm
R2 = 47k - (Rx) - 33k
R3 = 3k6
R4 = 0k510
R5 = 1k6

Thanks, today ill have the same ecu so i can test on table, not running x times to car. I will test your values, maybe the 510 Resistor could be the problem. But i tried connect oscilloscope even in car and the waveform looks the same (that says me the saturation should be okay).

Nautamaran:
2: What init sequence does the ECU model expect and respond to? 5-baud or a Fast-Init? Does it require use of the L-Line? (I haven’t looked at the obd9141 library in a while, but recall it tries a 5-baud then tries a FastInit)
Does the library send a BeginComms request packet for you or do you need to do that at the user level?

I tried to examine VCDS diagnostics that works fine - on the specific protocol for this ecu uses KW1281 - 0100000001 same as seen here OBD KW 1281 Protokoll (KWP1281)

I tried even protocol for foreign ecu (should be ISO9141 compatible) in VCDS and that show exactly the same waveform, like the arduino is sending. (5 baud init which begins with a 200ms low, a 400ms high, a 400ms low, a 400ms high, a 400ms low and ends with a 200ms high.) And this protocol on diagnostics works just fine,too.

Ok, my schematic is now like this:

Still doesn´t work, but on oscilloscope i see a response from ECU, but won´t start communicating, maybe library is the problem?

Hello, thanks for reply. I think it´s working just fine. Autor of the library used the same library with arduino uno. Plus you can see the result on oscilloscope.

AltSoftSerial uses pins 8 and 9 for RX/TX and you cannot change those pin numbers. So how can you see a correct result on the scope using pins 2 and 3? So either you posted the wrong code or you don’t know how to use a scope.

pylon:
AltSoftSerial uses pins 8 and 9 for RX/TX and you cannot change those pin numbers. So how can you see a correct result on the scope using pins 2 and 3? So either you posted the wrong code or you don't know how to use a scope.

Lol, thanks a fortune. It works now.

I can assure you I can use oscilloscope, as I use it almost daily.

I guess the cause is that the init uses very slow baudrate (the bits are 200ms) and its is done by simply pulling the pin down for 200-400ms. But as switches to "high" speed communication, cant work on pins 2,3 anymore.

Thank you.

I can assure you I can use oscilloscope, as I use it almost daily.

That means you posted the wrong code!

AltSoftSerial still uses pin 8 and 9 and not 2 and 3.