Congratulations to vtecmec for winning May/June's Lude Of The Month, with his DIY Turbo BB1 build.

>>> Click Here For Profile <<<

Image

Reading data from Prelude ECUs (almost free solution inside!

To clarify - that's In Car Entertainment - not frozen water
AeroNotix
Posts: 145
Joined: Sun Oct 29, 2017 6:04 pm
My Generation: 5G
Location: Krakow, Poland. (Originally Blackpool, UK)

Reading data from Prelude ECUs (almost free solution inside!

Post by AeroNotix » Mon Dec 04, 2017 7:19 pm

Right well I am not convinced this adapter will work, but I haven't received it yet so I don't know.

HOWEVER. Progress has been made. I spent some time over at the pgmfi.org forum and found that a lot of people have done a lot of work to communicate with the older Honda ECUs.

I've found the 3 pin initialization sequence (always the most annoying part when dealing with older ECUs!), the baud rate and parts of the communication protocol thanks to the work they've done on pgmfi.org.

Hooking up an arduino (less than a tenner nowadays) to the Prelude's 3 pin connector and to my laptop's USB I can seemingly read data from the ECU.

Here's my (adapted) code for the arduino:

Code: Select all

#include <SoftwareSerialWithHalfDuplex.h>

SoftwareSerialWithHalfDuplex dlcSerial(12, 12, false, false);

void setup() {
  Serial.begin(9600);
  while (!Serial) { };
  dlcSerial.begin(9600);
}

void dlcInit() { 
  int initSequence[] = { 0x68, 0x6a, 0xf5, 0xaf, 0xbf, 0xb3, 0xb2, 0xc1, 0xdb, 0xb3, 0xe9 };
  for (int i = 0; i < sizeof(initSequence) / sizeof(initSequence[0]); i++) {
    dlcSerial.write(initSequence[i]);
  }
  delay(300);
}

int dlcCommand(byte cmd, byte num, byte loc, byte len, byte data[]) {
  // largely taken from https://github.com/kerpz/ArduinoHondaOBD
  
  // checksum FF - (cmd + num + loc + len - 0x01)
  byte crc = (0xFF - (cmd + num + loc + len - 0x01));

  unsigned long timeOut = millis() + 250;
  memset(data, 0, sizeof(data));

  dlcSerial.listen();

  dlcSerial.write(cmd);  // header/cmd read memory ??
  dlcSerial.write(num);  // num of bytes to send
  dlcSerial.write(loc);  // address
  dlcSerial.write(len);  // num of bytes to read
  dlcSerial.write(crc);  // checksum

  int i = 0;
  while (i < (len + 3) && millis() < timeOut) {
    if (dlcSerial.available()) {
      data[i] = dlcSerial.read();
      i++;
    }
  }
  if (data[0] != 0x00 && data[1] != (len + 3)) {
    return 0;
  }
  if (i < (len + 3)) {
    return 0;
  }
  return 1;
}

void serialPrintRPM(int rpm) {
  Serial.print("RPM: ");
  Serial.print(rpm);
  Serial.println("");
}

void loop() {

  byte dlcdata[20] = {0};
  int rpm = 0;

  if (dlcCommand(0x20, 0x05, 0x00, 0x02, dlcdata)) {
    // apparently the format is different between ODB1 and ODB2. For
    // now, print both.
    serialPrintRPM(dlcdata[2] * 256 + dlcdata[3]);
    serialPrintRPM((1875000 / (dlcdata[2] * 256 + dlcdata[3] + 1)) * 4);
  }
  // delay a tad so we don't get flooded with serial data (and we can
  // read it!)
  delay(3000);
}
Right now this just requests the RPM value from the ECU and the reply I get makes no sense but I will play around with it a bit more.

All in all, not bad for a couple of bits of wire and a few hours research. There's code out there that will transmit the raw K-line data over bluetooth so apps like Torque can read it, completely negating the need for any Hondash reader specific to old Hondas.
Last edited by AeroNotix on Mon Dec 04, 2017 9:19 pm, edited 1 time in total.

User avatar
wurlycorner
Ye are glad to be dead, RIGHT?
Posts: 21224
Joined: Sat May 19, 2012 3:33 pm
My Generation: 4G
Location: Chelmsford, Essex
Has thanked: 1968 times
Been thanked: 240 times

Post by wurlycorner » Mon Dec 04, 2017 7:23 pm

RattyMcClelland wrote:
wurlycorner wrote::think:
There is a guy on here a year or so ago, that made up some software/hardware to live view engine management data on honda's/preludes...
Can't remember who/where the thread is, though, now :?
:think:
RattyMcClelland wrote:Use this Hondash
;)
Cheeky sod!

Where's the thread on the forum though? He had some good looking pics and info on there as it was developed IIRC :D

AeroNotix
Posts: 145
Joined: Sun Oct 29, 2017 6:04 pm
My Generation: 5G
Location: Krakow, Poland. (Originally Blackpool, UK)

Post by AeroNotix » Mon Dec 04, 2017 7:37 pm

There's a lot of code here which is useful for communicating with older Honda ECUs here: https://github.com/kerpz/ArduinoHondaOBD/

Also, that kerpz guy implemented this such that it would relay the information over bluetooth so you can read the live data from apps like Torque. Much smoother for me (IMHO).

That said, a lot of the protocol-level things have been done and implementing your own readers for older Honda ECUs overall is quite simple as the hard work such as reverse engineering the protocol has already been done for you.

AeroNotix
Posts: 145
Joined: Sun Oct 29, 2017 6:04 pm
My Generation: 5G
Location: Krakow, Poland. (Originally Blackpool, UK)

Post by AeroNotix » Mon Dec 04, 2017 7:40 pm

Here is a link to a good thread explaining the individual command/response formats: http://forum.pgmfi.org/viewtopic.php?f=57&t=5871

A few pages in someone mentions the initialization sequence. I'll repost it here since it's useful to have around somewhere else:

Code: Select all

{ 0x68, 0x6a, 0xf5, 0xaf, 0xbf, 0xb3, 0xb2, 0xc1, 0xdb, 0xb3, 0xe9 }
I'm not even sure if that initialization sequence is required. I'm going to have a play around and see what is necessary/isn't necessary.

After that it's a case of figuring out the individual ROM offsets to get the ECU to give you specific data. That's not organized very well over at pgmfi.org so I'll try to gather something better up.

Scott560
Posts: 1329
Joined: Sat Aug 31, 2013 4:44 pm
My Generation: 5G
Location: Didcot
Has thanked: 19 times
Been thanked: 215 times

Post by Scott560 » Mon Dec 04, 2017 8:14 pm

might have to give this a bash - several arduinos kicking around. Always fancied putting a spare OLED display in my spare clock module i ripped out the old lude...
'00 UKDM 2.2VTI H22a8
'21 'e' Advance

AeroNotix
Posts: 145
Joined: Sun Oct 29, 2017 6:04 pm
My Generation: 5G
Location: Krakow, Poland. (Originally Blackpool, UK)

Post by AeroNotix » Mon Dec 04, 2017 9:16 pm

Hmm, I've been told I have an ODB2 ECU as that's what 5th gen EUDM Preludes have but looking at the RPM response parsing code here: https://github.com/kerpz/ArduinoHondaOB ... #L433-L434 and parsing as both such as:

Code: Select all

  
    // apparently the format is different between ODB1 and ODB2. For
    // now, print both.
    Serial.print("ODB2 ");
    serialPrintRPM(dlcdata[2] * 256 + dlcdata[3]);
    Serial.print("ODB1 ");
    serialPrintRPM((1875000 / (dlcdata[2] * 256 + dlcdata[3] + 1)) * 4);
The one that makes the most sense is the ODB1 mode? I should go get the ECU model number.... I've got it displaying as both right now and the ODB2 format makes it read like 5k+ and the ODB1 is almost entirely accurate.

AeroNotix
Posts: 145
Joined: Sun Oct 29, 2017 6:04 pm
My Generation: 5G
Location: Krakow, Poland. (Originally Blackpool, UK)

Post by AeroNotix » Wed Dec 06, 2017 4:25 pm

Received my 3-to-16 adapter today. Can confirm it does not work to connect the Prelude via Bluetooth to Torque Pro. The bluetooth ODB2 unit receives power and clearly is trying to do something but it never negotiates the correct protocol.

AeroNotix
Posts: 145
Joined: Sun Oct 29, 2017 6:04 pm
My Generation: 5G
Location: Krakow, Poland. (Originally Blackpool, UK)

Post by AeroNotix » Sun Dec 10, 2017 3:37 pm

Hi,

I've wrapped all the 3 pin ECU communication up into a little Arduino library: https://github.com/AeroNotix/hodb

Here's an example how to use it:

Connect the K-line to pin 12 on the arduino, connect ground to ground and 12v to Vin on the arduino. The RPM, at least in my car, is reported a little strangely so I don't know exactly what I am doing wrong, the other values that I can retrieve (VSS, ECT etc) seem to read properly.

If you blow up your Lude using this, not my fault! It all works for me!

Code: Select all

#include <hodb.h>

Honda3Pin odb_connection(12, Honda3Pin::ODB1);

void setup() {
  Serial.begin(9600);
  while (!Serial) { };
  odb_connection.Init();
  pinMode(LED_BUILTIN, OUTPUT);
}

void serialPrintRPM(int rpm) {
  Serial.print("RPM: ");
  Serial.println(rpm);
}

void loop() {
  unsigned int i = odb_connection.RPM();
  serialPrintRPM(i);
  // Just a sanity-check to know if we are still running:
  digitalWrite(LED_BUILTIN, HIGH);
  delay(1500);
  digitalWrite(LED_BUILTIN, LOW);
  delay(1500);
}

Post Reply

Return to “Electrical / Lights / ICE”