Go Down

Topic: Bike interface OBD (Read 50095 times) previous topic - next topic

robtillaart

use digitalWrite(1, HIGH/LOW);
and use delay to time the pulses.
Be sure your serial buffer is empty when starting
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

o5i_

I have a lot of trouble get this done..
Somone want to help me?
I tried to read the data while it is connected to the pc but it won`t work... But i earn only a lot of bugs...
same whit init... Dont know whats wrong... Im shure there are people who did this successfull...
But whitout skills no way...

cyclegadget

I have some parts and information that could be helpful. I'm not at home right now.  What country or area are you from? I will try to post more later on.
Good links: Eagle tutorial= http://www.youtube.com/playlist?list=PLDE1858BD83D19C70
General Arduion tutorials = http://tronixstuff.wordpress.com
http://www.gammon.com.au/forum/bbshowpost.php?bbtopic_id=123

o5i_

Hi, im from north italy.. If you can help me would be great  :)

cyclegadget

o5i,

  The first thing you will need is the hardware to connect your 5 volt arduino to your 12 volt motorcycle communication line. I have a circuit board that uses a LM393 as a level shifter. I had a bunch of circuit boards made and I was selling an interface that goes from computer USB to the bikes computer.....I have a few boards left over. They work with 07 GSXRs and newer as far as I know. Personally, I have an 08 GSXR and it works well on it. If you want to go the computer route, let me know. Otherwise, I will help you with your Arduino project.

I have put a lot of work on getting an Atmel 1284 chip to talk to the motorcycle computer and I have had some success but, the project is not completed. I will share some of my hard work with you to get you started.

Here is the initiation part of the code that works well for me. I am providing you with a snippet to get you started. After the initiation part of the code, you are going to need read incoming data. Add you coding ideas, put in effort, and I will help more.

You will need to define your TX and RX pins based on the board you are using. In my case, my board is the Bobuino with a 1284 chip.

Code: [Select]

//variables
byte message[6] = {
  0x81,0x12,0xF1,0x81,0x05};
int mode = 0;
/////////////////DATA START///////////////
void datastart(){
  mode = 0;                 //reset mode to 0 for first step of logging
  digitalWrite (TX, HIGH);  // makes K-line high 3
  digitalWrite(ledPin,HIGH);
  delay(2000);             // wait for K-line to be clear 3
  digitalWrite (TX, LOW);  // makes K-line low  3
  delay(25);
  digitalWrite (TX, HIGH); // makes K-line high  3
  delay(25);               //last delay before first message
  Serial1.begin(10400);  // baud rate of the OBD
  //send package 0x81,0x12,0xF1,0x81,0x05
  for (int i = 0; i < 5; i++){
    Serial1.write(message[i]);
    byte inByte = Serial1.read();
    delay(1);                 //inter byte delay for to match k-line spec. changed from 15ms to 1, tune as needed
  }
}



 
Good links: Eagle tutorial= http://www.youtube.com/playlist?list=PLDE1858BD83D19C70
General Arduion tutorials = http://tronixstuff.wordpress.com
http://www.gammon.com.au/forum/bbshowpost.php?bbtopic_id=123

o5i_

Thanks, i try if it works... I have a code that send something but the ecu didnt reply... I tried to log the data when ecueditor is running but it looses some data...
I have an BC547 level shifter like this one http://fish.x64.me/doc/INTERFACE_RUFER.pdf
But i want to use one like yours whit LM393 on it because it is smaller.
I think it is going forward...
You know if it is possible to connect the digital out pins directly to the pins of the  ecu like "mode (map switch)" "reset" "fwe" "dealer mode" and of course the programing pins? In case of that it can be used als programing interface too...


cyclegadget


You know if it is possible to connect the digital out pins directly to the pins of the  ecu like "mode (map switch)" "reset" "fwe" "dealer mode" and of course the programing pins? In case of that it can be used als programing interface too...




I think that the answer is "yes" because you can connect directly to the 5 volt FTDI cable to the ECU on the "reset" "fwe" pins .  I have only logged with the Arduino, and I have never made any attempts to program using the Arduino. I would exercise caution when connecting to the map switch and dealer mode by using resistors to limit current.
Good links: Eagle tutorial= http://www.youtube.com/playlist?list=PLDE1858BD83D19C70
General Arduion tutorials = http://tronixstuff.wordpress.com
http://www.gammon.com.au/forum/bbshowpost.php?bbtopic_id=123

o5i_

I have a problem, i tried the code and put an other serial on it to see waht the ecu responds but the ecu only replies the same as i have send...
I think there is something wong, maybee the pin 18/19 on mega are not the serial ones or i need to use the serial0? Last time i tried whit same result...
Code: [Select]

#define TX 18
#define RX 19
#define ledPin 10
#define console Serial
#define cbaud 14400
#define sds Serial1
#define sdsbaud 10400

//variables
byte message[] = {
  0x81,0x12,0xF1,0x81,0x05};
int mode = 0;

void setup() {
}

void loop() {
  datastart();
}


/////////////////DATA START///////////////
void datastart(){
  mode = 0;                 //reset mode to 0 for first step of logging
  digitalWrite (TX, HIGH);  // makes K-line high 3
  digitalWrite(ledPin,HIGH);
  delay(2000);             // wait for K-line to be clear 3
  digitalWrite (TX, LOW);  // makes K-line low  3
  delay(25);
  digitalWrite (TX, HIGH); // makes K-line high  3
  delay(25);               //last delay before first message
  console.begin(cbaud);    // test ---------------------------------------------------------------------------------------
  sds.begin(sdsbaud);  // baud rate of the OBD
  //send package 0x81,0x12,0xF1,0x81,0x05
  for (int i = 0; i < 5; i++){
    Serial1.write(message[i]);
    byte inByte = sds.read();
    console.println(inByte,HEX);  //test -----------------------------------------------------------------------------------
    delay(1);                 //inter byte delay for to match k-line spec. changed from 15ms to 1, tune as needed
  }
}

robtillaart

Quote
maybee the pin 18/19 on mega are not the serial ones


- http://arduino.cc/en/Main/ArduinoBoardMega2560 -

check for pinMapping
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

o5i_

#24
May 14, 2014, 08:46 pm Last Edit: May 14, 2014, 09:21 pm by o5i_ Reason: 1
Dont know whats wrong here... I think it should work? Why the ecu responds whit the same string?
I have tried to send whit the arduino and recieve whit the ftdi but it shows nothing usefull... Maybee there is something wrong whit the arduino? Its a mega 2560..

robtillaart


Code: (???) [Select]

void datastart()
{
  mode = 0;
  digitalWrite (TX, HIGH);  // <<<<<<<<<<<<<
  digitalWrite(ledPin, HIGH);
  delay(2000);
  digitalWrite (TX, LOW);
  delay(25);
  digitalWrite (TX, HIGH);
  delay(25);
  console.begin(cbaud);    // <<<<<<<<<<
  sds.begin(sdsbaud);   //  <<<<<<

  for (int i = 0; i < 5; i++)
  {
    Serial1.write(message[i]);  // <<< byte array ?
    while (sds.Available() == 0); // blocking wait for byte to arrive
    byte inByte = sds.read();
    console.println(inByte, HEX);
  }
  console.println();
}

Some questions
is TX the transmitpin of Serial1, console or from sds or something else ?
why are those two baudrates initialized in the middle of this function ?

I have added auto tuning for the byte reception, assuming SDS implements an Available() function.
and assuming there will arrive 5 bytes.

Dont know if this helps,

you could try to write some minimal sketches that just test single functions hjust to verify.
- 3 sketches for the 3 serial ports
- etc
diagnostics step by step
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

o5i_

Hi, i have read some things, according whit somebody who knows how it works the arduino maybee have problems to get the right timing. The protocol has a tolerance of +-1ms....  Is there a way to test?
The replys probably are echos, the data is transmitted throug one wire...

cyclegadget

Quote
The replys probably are echos, the data is transmitted throug one wire...


You are correct, you will get echo. My answer for this was to read the bytes available until they equal the amount sent. In the first part of the code, I sent this:
Code: [Select]
byte message[6] = {0x81,0x12,0xF1,0x81,0x05};

To get around the echo problem, I read 5 bytes, if the fifth by equals 0x05, then the next byte is coming from the ECU.

Quote
The protocol has a tolerance of +-1ms....  Is there a way to test?


I started with "extra" time between bytes sent and I gradually reduced the delay between bytes and I watched for loss of communication. I used a potentiometer in my sketch to make my timing adjustable on the fly.  
Good links: Eagle tutorial= http://www.youtube.com/playlist?list=PLDE1858BD83D19C70
General Arduion tutorials = http://tronixstuff.wordpress.com
http://www.gammon.com.au/forum/bbshowpost.php?bbtopic_id=123

cyclegadget


o5i_

I also thought you should know that you do not want to use Software Serial for communicating with the ECU. In my case, I found that it was far easier to use Hardware Serial.

Also, in my case, I used Serial1 for communication with ECU and Serial0 to repeat the data to my computer during testing.
I would recommend doing the same with your Mega if it is possible.
Good links: Eagle tutorial= http://www.youtube.com/playlist?list=PLDE1858BD83D19C70
General Arduion tutorials = http://tronixstuff.wordpress.com
http://www.gammon.com.au/forum/bbshowpost.php?bbtopic_id=123

o5i_

Hi, i had sucess, i got some AE 8F replys, but they were somewhere between the echos..
i only need to add
pinMode(TX, OUTPUT);
:D
But it is not working everytime i try..

Go Up