//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();
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.
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.