Page 2 of 2 FirstFirst 12
Results 11 to 17 of 17

Thread: OBD2 Source code for opto interface

  1. #11
    Low Bitrate
    Join Date
    Aug 2004
    Posts
    78
    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

  2. #12
    Raw Wave shotgunefx's Avatar
    Join Date
    Apr 2005
    Location
    Boston, MA
    Posts
    1,800
    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?

  3. #13
    Low Bitrate
    Join Date
    Aug 2004
    Posts
    78
    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

  4. #14
    Raw Wave shotgunefx's Avatar
    Join Date
    Apr 2005
    Location
    Boston, MA
    Posts
    1,800
    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.

  5. #15
    Low Bitrate
    Join Date
    Aug 2004
    Posts
    78
    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?

  6. #16
    Raw Wave shotgunefx's Avatar
    Join Date
    Apr 2005
    Location
    Boston, MA
    Posts
    1,800
    Quote Originally Posted by Maddog_rvo
    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?
    Probably a timing error. There are certain timings that need to be adhered to ,etc. If you don't know learn what needs to be done, it's probably going to be extremely difficult to probe around until you happen to make something work.

    If you don't want to try and read up on the interface, take a look at freediag and see if you can grok enough of it to get something working.

  7. #17
    Low Bitrate
    Join Date
    Aug 2004
    Posts
    78
    Piece of text i received through the opendiag group :

    You receive a OBD2 response 0x55-0x08-0x08 which indicates that
    there is more than one ECU in this car - you probably send 0x33 as
    adress.It also means that there must be 25mS - 50mS timeperiod
    between responses for adressed ECUs.
    Response 0x55-0x94-0x94 means that there is only one ECU that
    would answer and time for response is from 0ms - 50mS.
    If you want to connect to an OBD2-compliant car, do the following:

    Send: 0x33

    Receive: 0x55-0x08-0x08 ( or 0x55-0x94-0x94)

    Send: 0xF7 (complement of second 0x08) OR send: 0x6B (complement of second 0x94)

    Receive: 0xCC (complement of adress 0x33)

    Initsequence is now finished, you can start diagnostic session by:

    Send: 0x68-0x6A-0xF1-0x01-0x00-0xC4

    Rcv: 0x48-0x6B-EcuAdress-0x41-0x00-A-B-C-D-ChkSum

    Explanation and more info in: SAE9141, J1979 and ISO14230.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. GPS/MapPoint VB Source Code
    By stevieg in forum Software & Software Development
    Replies: 7
    Last Post: 01-28-2011, 04:59 PM
  2. My VB code for Elm interface! OBD2
    By infinkc in forum Engine Management, OBD-II, Engine Diagnostics, etc.
    Replies: 14
    Last Post: 01-29-2009, 11:22 AM
  3. Alpha Release: XMPC-CAR for XM
    By gork in forum Software & Software Development
    Replies: 88
    Last Post: 01-11-2006, 01:19 PM
  4. GPS:MM shutdown RR when switch skin
    By MatrixPC in forum RR Bug Tracker
    Replies: 5
    Last Post: 05-12-2005, 12:07 PM
  5. master volume doesnīt work
    By free2world8000 in forum RR Bug Tracker
    Replies: 14
    Last Post: 02-17-2005, 01:08 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •