Sponsored links

Go Back   MP3Car.com > Mp3Car Technical Hardware > Engine Management, OBD-II, Engine Diagnostics, etc.


Reply
 
Share Thread Tools Display Modes
Old 09-08-2005, 01:47 AM   #1
Low Bitrate
 
Join Date: Aug 2004
Posts: 78
Maddog_rvo is on a distinguished road
OBD2 Source code for opto interface

Can anyone help me to OBD2 source code for a optocoupler interface, i can only find source code for the elm interface and i dont have one. My car is a Seat Leon TDI (VW TDI is the same) and i want to make a virtual dashboard but i dont have a clue of where to start (never did RS232 Programming and dont know how to initialize / talk to the ECU)
Maddog_rvo is offline   Reply With Quote
Advertisement
 
Advertisement
Sponsored links

Old 09-08-2005, 11:51 PM   #2
Low Bitrate
 
Join Date: Aug 2004
Posts: 78
Maddog_rvo is on a distinguished road
Quote: Originally Posted by Maddog_rvo
Can anyone help me to OBD2 source code for a optocoupler interface, i can only find source code for the elm interface and i dont have one. My car is a Seat Leon TDI (VW TDI is the same) and i want to make a virtual dashboard but i dont have a clue of where to start (never did RS232 Programming and dont know how to initialize / talk to the ECU)

I can program in c#, found something to get me going for a small bit. I need to send the ECU 0x33 (in what format?) at 5 baud to initiate communication.

How can i send 0x33 to the ECU? I can program the comport but dont know what to send

is it like com.Output("0x33");
or com.Output(51);

Can anyone please help me (if u could provide some more information, like how to ask RPM or something PLEASE )

This is drivin me
Maddog_rvo is offline   Reply With Quote
Old 09-09-2005, 11:00 AM   #3
Low Bitrate
 
Join Date: Aug 2004
Posts: 78
Maddog_rvo is on a distinguished road
I tried the elm interface from a friend of mine, downloaded 3 different logging programs and they are WAY to slow for what i want (updated like once in a second) I want graphic dials that show Boost, Speed and RPM (maybe some more) but with elm i drove 100km/h and it still said 80km/h while if i use VAG-COM with my opto coupler interface it updates almost instantly so i really need help with designing software for interrogating my PC
Maddog_rvo is offline   Reply With Quote
Old 09-12-2005, 11:57 PM   #4
Low Bitrate
 
Join Date: Aug 2004
Posts: 78
Maddog_rvo is on a distinguished road
Anyone please?
Maddog_rvo is offline   Reply With Quote
Old 09-16-2005, 04:45 PM   #5
Newbie
 
Join Date: Sep 2005
Posts: 38
jjakes24 is on a distinguished road
Well, I program c# for a living. I have done a lot of interactions with machines through TCP and UDP. Now 0x33 is just a hex number that would fill one byte. I Imagine you would be sending a command set that is a certain number of bytes, this might just be one.

byte [] tmp = new byte[1];
tmp[0] = 0x33;

All you would have to do is send off that byte. I haven't done much with RS232 but it can't be far off. I would have to look at the RS232 libraries which i think are available with .net 2.0 which is still being developed. How are you connecting to the RS232 port? What is the data structure the libraries want you to send across the device?

I imagine you are going to have to work with bytes because the ELM device from what I understand converts to ASCII and thats probably where the delay comes in. If you use a non ELM device, the only way would be to convert the Hex that comes in, which is probably stored in bytes.

Last edited by jjakes24; 09-16-2005 at 04:47 PM.
jjakes24 is offline   Reply With Quote
Old 09-16-2005, 04:51 PM   #6
Newbie
 
Join Date: Sep 2005
Posts: 38
jjakes24 is on a distinguished road
here is a c++ function I found that is suppose to handle the init for 5 baud:

char diag_l0_initbus(void)
{

TRISC6 = 0; //Set RC6 as output
//Now we need to sent address of 0x01 at 5 baud

OBD_K_LINE = 0;

DelayMs(200);

OBD_K_LINE = 1;

DelayMs(200);

OBD_K_LINE = 0;

DelayMs(200); //A high of 1400mS
DelayMs(200);
DelayMs(200);
DelayMs(200);
DelayMs(200);
DelayMs(200);
DelayMs(200);

OBD_K_LINE = 1;

//Now config serial port
SPBRG=29; // data rate for sending/receiving @ 10400 baud
BRGH=0; // data rate for sending/receiving
SYNC=0; // asynchronous
SPEN=1; // enable serial port pins
CREN=1; // enable reception
SREN=0; // no effect
TXIE=0; // disable tx interrupts
RCIE=0; // disable rx interrupts
TX9=0; // 8-bit transmission
RX9=0; // 8-bit reception
TXEN=1; // enable the transmitter

}

from http://www.skpang.co.uk/ecu_reader.htm
jjakes24 is offline   Reply With Quote
Old 09-18-2005, 11:50 PM   #7
Low Bitrate
 
Join Date: Aug 2004
Posts: 78
Maddog_rvo is on a distinguished road
Quote: Originally Posted by jjakes24
Well, I program c# for a living. I have done a lot of interactions with machines through TCP and UDP. Now 0x33 is just a hex number that would fill one byte. I Imagine you would be sending a command set that is a certain number of bytes, this might just be one.

byte [] tmp = new byte[1];
tmp[0] = 0x33;

All you would have to do is send off that byte. I haven't done much with RS232 but it can't be far off. I would have to look at the RS232 libraries which i think are available with .net 2.0 which is still being developed. How are you connecting to the RS232 port? What is the data structure the libraries want you to send across the device?

I imagine you are going to have to work with bytes because the ELM device from what I understand converts to ASCII and thats probably where the delay comes in. If you use a non ELM device, the only way would be to convert the Hex that comes in, which is probably stored in bytes.

Thanks, i`ll look into that, try to get that code to work

I`m going to send bytes into the optocoupler interface which sends it unmodified to ECU (Well i`m trying to do that ) The datastructure that the libraries want is either a string or a byte. The library is use is one i found on internet (found a VB source code called RS232 and made a DLL out of that which i use for C#)

The bit of code i have now is found on : http://members.home.nl/hjmoers
Warning : I`m not a good programmer and i dont even know if this code is going to work. I`m still learning programming and i do have help from a friend but he wont help with this yet, he says i gotta do it myself

Last edited by Maddog_rvo; 09-19-2005 at 05:51 AM.
Maddog_rvo is offline   Reply With Quote
Old 09-19-2005, 09:18 AM   #8
Newbie
 
Join Date: Sep 2005
Posts: 38
jjakes24 is on a distinguished road
the code looks ok to me as long as that RS232 class does what it is suppose to do. I haven't built my device yet so I haven't been able to play around with things but it should take me no longer than a day to get my stuff going. I'll let you know where I stand in about 3 weeks. Let me know of your progress if the code worked for you or not.
jjakes24 is offline   Reply With Quote
Sponsored links
Advertisement
 
Advertisement
Old 09-20-2005, 12:19 AM   #9
Low Bitrate
 
Join Date: Aug 2004
Posts: 78
Maddog_rvo is on a distinguished road
Quote: Originally Posted by jjakes24
the code looks ok to me as long as that RS232 class does what it is suppose to do. I haven't built my device yet so I haven't been able to play around with things but it should take me no longer than a day to get my stuff going. I'll let you know where I stand in about 3 weeks. Let me know of your progress if the code worked for you or not.

Well i dont think the RS232 class does what it is supposed to do, i get no errors or whatsoever but it does totally nothing. I`m going to try and find another RS232 class
Maddog_rvo is offline   Reply With Quote
Old 09-20-2005, 11:55 PM   #10
Low Bitrate
 
Join Date: Aug 2004
Posts: 78
Maddog_rvo is on a distinguished road
Quote: Originally Posted by jjakes24
the code looks ok to me as long as that RS232 class does what it is suppose to do. I haven't built my device yet so I haven't been able to play around with things but it should take me no longer than a day to get my stuff going. I'll let you know where I stand in about 3 weeks. Let me know of your progress if the code worked for you or not.

I`ll post some new code, got it working for now, the code sends some bytes to the ECU but the only thing i receive are the exact same codes and sometimes the program crashes and says frame error


A nice link with good info (in german )
http://www.blafusel.de/misc/obd2_kw1281.html#5
Another one in english :
http://www.hex.co.za/vaginfo/index.html

I think i cant get the 5 Baud rate to work properly so the ECU wakeup wont work and thats probably the reason why i dont get a response

Last edited by Maddog_rvo; 09-21-2005 at 02:21 AM.
Maddog_rvo is offline   Reply With Quote
Old 09-21-2005, 03:11 AM   #11
Low Bitrate
 
Join Date: Aug 2004
Posts: 78
Maddog_rvo is on a distinguished road
According to the first site, vag-com does the 5baud init like this :

IOCTL_SERIAL_SET_BREAK_ON
IOCTL_SERIAL_SET_RTS
IOCTL_SERIAL_CLR_DTR
IOCTL_SERIAL_SET_BREAK_OFF -> Start-Bit?
IOCTL_SERIAL_CLR_RTS
IOCTL_SERIAL_SET_BREAK_ON -> 0
IOCTL_SERIAL_SET_RTS
IOCTL_SERIAL_SET_BREAK_ON -> 0
IOCTL_SERIAL_SET_RTS
IOCTL_SERIAL_SET_BREAK_ON -> 0
IOCTL_SERIAL_SET_RTS
IOCTL_SERIAL_SET_BREAK_ON -> 0
IOCTL_SERIAL_SET_RTS
IOCTL_SERIAL_SET_BREAK_ON -> 0
IOCTL_SERIAL_SET_RTS
IOCTL_SERIAL_SET_BREAK_ON -> 0
IOCTL_SERIAL_SET_RTS
IOCTL_SERIAL_SET_BREAK_ON -> 0
IOCTL_SERIAL_SET_RTS
IOCTL_SERIAL_SET_BREAK_OFF -> 1
IOCTL_SERIAL_CLR_RTS
IOCTL_SERIAL_SET_DTR
Maddog_rvo is offline   Reply With Quote
Old 09-21-2005, 03:29 AM   #12
Raw Wave
 
shotgunefx's Avatar
 
Join Date: Apr 2005
Location: Boston, MA
Posts: 1,800
shotgunefx is on a distinguished road
Quote: Originally Posted by jjakes24
here is a c++ function I found that is suppose to handle the init for 5 baud:

char diag_l0_initbus(void)
{

TRISC6 = 0; //Set RC6 as output
//Now we need to sent address of 0x01 at 5 baud

OBD_K_LINE = 0;

DelayMs(200);

OBD_K_LINE = 1;

DelayMs(200);

OBD_K_LINE = 0;

DelayMs(200); //A high of 1400mS
DelayMs(200);
DelayMs(200);
DelayMs(200);
DelayMs(200);
DelayMs(200);
DelayMs(200);

OBD_K_LINE = 1;

//Now config serial port
SPBRG=29; // data rate for sending/receiving @ 10400 baud
BRGH=0; // data rate for sending/receiving
SYNC=0; // asynchronous
SPEN=1; // enable serial port pins
CREN=1; // enable reception
SREN=0; // no effect
TXIE=0; // disable tx interrupts
RCIE=0; // disable rx interrupts
TX9=0; // 8-bit transmission
RX9=0; // 8-bit reception
TXEN=1; // enable the transmitter

}

from http://www.skpang.co.uk/ecu_reader.htm


You know that's for a PIC Microcontroller right?
shotgunefx is offline   Reply With Quote
Old 09-21-2005, 03:45 AM   #13
Low Bitrate
 
Join Date: Aug 2004
Posts: 78
Maddog_rvo is on a distinguished road
Quote: Originally Posted by shotgunefx
You know that's for a PIC Microcontroller right?

Yup, but its good for looking how to initialize connection to the ECU
Maddog_rvo is offline   Reply With Quote
Old 09-21-2005, 04:02 AM   #14
Raw Wave
 
shotgunefx's Avatar
 
Join Date: Apr 2005
Location: Boston, MA
Posts: 1,800
shotgunefx is on a distinguished road
Quote: Originally Posted by Maddog_rvo
Yup, but its good for looking how to initialize connection to the ECU

But pretty much all that code is to set up the PIC's UART, not the ECU.

The reason that most readers are slow, is there's a 20ms delay between queries. That's part of the specs I believe. If you could cut that down, then they would update faster. Wether this would cause problems on your vehicle, who knows.

Do you know what interface your car is using? Is it ISO 9141? That's K-Line.

Your best bet is to look at what docs are available for your specific interface.
shotgunefx is offline   Reply With Quote
Old 09-21-2005, 03:14 PM   #15
Low Bitrate
 
Join Date: Aug 2004
Posts: 78
Maddog_rvo is on a distinguished road
Quote: Originally Posted by shotgunefx
But pretty much all that code is to set up the PIC's UART, not the ECU.

The reason that most readers are slow, is there's a 20ms delay between queries. That's part of the specs I believe. If you could cut that down, then they would update faster. Wether this would cause problems on your vehicle, who knows.

Do you know what interface your car is using? Is it ISO 9141? That's K-Line.

Your best bet is to look at what docs are available for your specific interface.

Its iso 9141 indeed, i think with the current code the init succeeds, but i now get a framing error as soon as data is received, which crashes my app. Does anyone know what kind of error this is and how to solve it?
Maddog_rvo is offline   Reply With Quote
Sponsored links
Advertisement
 
Advertisement
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
My VB code for Elm interface! OBD2 infinkc Engine Management, OBD-II, Engine Diagnostics, etc. 14 01-29-2009 10:22 AM
Alpha Release: XMPC-CAR for XM gork Software & Software Development 88 01-11-2006 12:19 PM
GPS:MM shutdown RR when switch skin MatrixPC RR Bug Tracker 5 05-12-2005 11:07 AM
master volume doesnīt work free2world8000 RR Bug Tracker 14 02-17-2005 12:08 PM
GPS/MapPoint VB Source Code stevieg Software & Software Development 4 06-08-2004 02:24 PM



All times are GMT -5. The time now is 04:21 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.2
Copyright © 1999 - 2008 Mp3Car.com Inc.Ad Management by RedTyger
Message Board Statistics