Shop OBEX P1 Docs P2 Docs Learn Events
Trying to Interface Stamp to OBD Circuit — Parallax Forums

Trying to Interface Stamp to OBD Circuit

rilenrilen Posts: 7
edited 2006-11-02 13:32 in BASIC Stamp
Hi, this is my first post ever to this forum. I'm hoping to get some suggestions for a senior design project I'm working on.

As the title suggests, I'm trying to use my stamp micro-controller to send and receive 2 digit (8 bit) hex codes to an OBD interface chip, using SEROUT and SERIN commands. By sending these codes, I'm hoping to initialize the OBD chip and eventually pull data, such as engine RPM, to be held by the Stamp and later forwarded onto another system.

Here is the interface chip I'm using: http://obddiagnostics.com/schem.html

The interface chip website also has a programmer's page which may be of use: http://obddiagnostics.com/obdinfo/info.html


The problem I'm having is trying to connect the Stamp with the OBD interface circuit. I initially tried just wiring the two together and didn't have much luck, then I tried using line drivers between the two devices and that didn't work either. The cable between the two components is only about 5 feet long. I've verified my outgoing request signal from the Stamp is clean by putting it in a loop and looking at the bitstream with an oscilloscope.

I didn't think I would have such a hard time getting the Stamp and the OBD interface circuit to "talk" to each other. I was more concerned with the programming aspects of this project, but here I am dead in the water.


If anyone has any suggestions, I would greatly appreciate it. If more data is needed to diagnose my problem, feel free to ask.

Thanks,

Rocky

Comments

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-10-23 07:27
    Rocky -

    Which model Stamp are you using, and what baudmode are you using?

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
  • rilenrilen Posts: 7
    edited 2006-10-23 14:58
    Bruce,

    I'm using the BS2-IC which came with the Basic Stamp Discovery Kit I bought. For the baudmode I was using 16384, but switched it to 32 when I added the line driver chip because the line driver chip has an inverting function built into it.

    Thanks,

    Rocky
  • steve_bsteve_b Posts: 1,563
    edited 2006-10-23 16:13
    A "common" mistake is to not connect the 'common'!

    Be sure you connect the ground of your stamp to the ground of your circuit.

    The other easy fix is to be sure you are talking/listening to the proper serial pins. This is the other often-made mistake that's easy to check. Swap pins 2 and 3 on the serial connector (in the circuit you linked) and see if that changes things.

    (that schematic could do with a larger version...gets distorted when you zoom in)

    I can't tell what baud rate it's supposed to run at, but from what you indicated (in the previous post) it's 19200. There's a note in the help file indicating there may be problems with the BS2 synchronizing at that speed.

    At this point you might try posting your code to see if we can help that way!
    Is there a way to "dumb-down" the baud rate?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·

    Steve

    "Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."
  • stamptrolstamptrol Posts: 1,731
    edited 2006-10-23 16:20
    Rocky,

    Can you post a bit of your code? Are you calculating the checksum?

    At 19.2K, the Stamp may have difficulty listening to incoming strings, as noted in the Stamp Help files.

    I see on the reference pages you gave that several programs are available which talk to the OBD. You could get one of those working on a PC then have a look at their strings to see what the data looks like.

    Cheers

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tom Sisk

    http://www.siskconsult.com
    ·
  • rilenrilen Posts: 7
    edited 2006-10-23 16:27
    Here's the code I've been trying on the circuit. It's still in the Frankenstein stages:



    init_cntrl_word VAR Byte
    init_hdr_word1 VAR Byte
    init_hdr_word2 VAR Byte
    speed VAR Byte

    chp_cnnct_rec = $AA
    init_cntrl_word = $BB
    init_hdr_word1 = $CC
    init_hdr_word2 = $DD




    ' Request for chip connect. Send 20(HEX)=32(DEC)=, Receive FF(HEX)=255(DEC)
    Connect:
    DEBUG "Sending Chip Connect Request", CR
    SEROUT 1,32,[noparse][[/noparse]$20] '32 for 19200 baud + 16384 for inverted(removed inverted due to inversion on driver chip)
    SERIN 0,32,3000,Connect,[noparse][[/noparse]chp_cnnct_rec] 'SERIN 0,16416,1000,Connect,[noparse][[/noparse]chp_cnnct_rec]
    DEBUG "Code Received: $",HEX chp_cnnct_rec,CR
    IF (chp_cnnct_rec=$FF) THEN ConnectSuccess
    PAUSE 300
    DEBUG "Unexpected code received, sending CHIP CONNECT again....",CR
    PAUSE 300
    GOTO Connect

    ConnectSuccess:
    PAUSE 500
    DEBUG "Chip Connect Successful",CR


    'Request for Initialization. Send control byte 41(HEX)=65(DEC) then
    ' 2(HEX)=2(DEC) to select ISO 9141-2, Receive
    Initialize:
    DEBUG "Initialization Request Sent",CR
    SEROUT 1,32,[noparse][[/noparse]$41] 'Send 41(HEX) out
    PAUSE 700
    SEROUT 1,32,[noparse][[/noparse]$02] 'Send 02(HEX) out
    SERIN 0,32,3000, Initialize,[noparse][[/noparse]init_cntrl_word, init_hdr_word1, init_hdr_word2]
    DEBUG "Codes Received: $",HEX init_cntrl_word," $",HEX init_hdr_word1," $",HEX init_hdr_word2,CR
    IF (init_cntrl_word=$02) AND (init_hdr_word1=$00) AND (init_hdr_word2=$00) THEN InitSuccess
    PAUSE 300
    DEBUG "Unexpected code received, sending INIT REQUEST again....",CR
    PAUSE 300
    GOTO Initialize

    InitSuccess:
    PAUSE 300
    DEBUG "Initialization Successful", CR



    Basically, I'm trying to initialize the chip by sending the two digit hex numbers according to the chip documentation found on that website I referenced earlier.

    If 19200 baud rate is too fast, how would I go about determining that? Would I have to use some sort of buffer to remedy that problem if that were the case?

    Thanks,

    Rocky
  • rilenrilen Posts: 7
    edited 2006-10-23 16:31
    Tom,

    We have been using the software on that website prior to hooking up to the Stamp. We hooked up a RS-232 "sniffer" circuit and were able to see the hex codes going back and forth. At this point, using the Stamp, I am trying to mimic the initialization sequence, but am having little success.

    What do you mean by "calculating the checksum" ?

    Thanks,

    Rocky
  • rilenrilen Posts: 7
    edited 2006-10-23 16:38
    Steve,

    I have the grounds of all the circuits tied together. I'm going to swap the 2 and 3 pins next time I have a chance. Are the high and low signal levels critical? What would be the minimum voltage difference for this to work (I'm talking about the voltage difference between a 1 and 0 when sending hex codes)?

    Thanks,

    Rocky
  • RobbanRobban Posts: 124
    edited 2006-10-23 17:36
    Rocky!

    I am planning to do the same...have a BS2 and intend to connect this to the ODB2 computer in my car...
    Have you´ve been able to retreive any data?
    I ould like to receive speed,rpm,errormesseges...
    and onnes it it in the stamp,well i can send it anywhere...smile.gif
  • stamptrolstamptrol Posts: 1,731
    edited 2006-10-23 19:03
    Rocky,

    OK, using the sniffer was where I was headed. You should be able to duplicate the output of the PC software, as you say.

    The checksum question was based on looking at one of the reference docs and they described two versions of checksum calculation. But, if you can actually see the data by using the sniffer, that may be an unneeded step.

    Is there any way you can hook the stamp up to issue the command and have the sniffer see if the OBD device is sending anything back? In fact, hook the sniffer so it can see the stamp issue the command and compare it to what the PC software was seeing.

    There is one long-shot I ran into when working with vehicle scales and the stamp. Some older scale indicators didn't fully implement the rs-232 voltages and depended on getting the negative signal voltage from the PC. The stamp also depends getting the negative voltage from "the other end" so, if the OBD device doesn't have a negative rs-232 voltage, the stamp will appear to not be listening. But, if you're using rs-232 drivers, that shouldn't be the case. On the OBD device, measure from pin 2 to 5, and from pin 3 to 5. One of them should be at -8 to -12 volts when idle.

    If you plug the stamp into a PC running Hyperterminal, do you see the correct data?

    Cheers

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tom Sisk

    http://www.siskconsult.com
    ·
  • rilenrilen Posts: 7
    edited 2006-10-25 17:53
    I've been working in the lab and have some more information which may help to diagnose my problem.

    I hooked the OBD interface circuit up to a laptop and used a program called ComDebug to send 2 digit (8 bit) hex codes to the circuit. The circuit responded as expected. I used an oscilloscope to probe the receive port on the ODB chip. I measured the bitstream coming out of the laptop into the OBD circuit to ensure I had my Stamp outputting the correct voltage and baud rate.

    Next, I disconnected the laptop and hooked up the Stamp. I followed the signal from the Stamp, probing at various points. What I found was that the bitstream isn't making it all the way to the correct pin on the OBD circuit, which is why the circuit never responds when I send hex codes from the Stamp. The last place I can see it, is right before a couple 10k resistors. See this datasheet, page 3. On IC1, pin 1 is the receive pin. The last place I see the Stamp output is right before R1.

    http://obddiagnostics.com/DataSheet.pdf

    So, my guess is that the Stamp's output isn't "strong" enough to get past the resistors before IC1. I thought about bypassing the resistors, but am concerned about blowing the OBD chip.

    Anybody have any ideas on where to go from here? Do I need to install some kind of extra chip between the Stamp and OBD circuit?

    Thanks for all the suggestions so far.


    Rocky
  • stamptrolstamptrol Posts: 1,731
    edited 2006-10-25 19:39
    Rocky,
    Any progress is good! I take it you tried swapping pins 2,3 of the serial port just in case? I'm a bit surprised that a laptop could drive the port but the stamp couldn't. Laptop serial ports are notoriously weak-kneed.

    Rather than risk damaging the chip, just use one of the other pins on the stamp to send to the ODB. You get a bit more drive capability and if you put a 100 ohm resitor in series, you won't hurt the Stamp. You'll likely have to use the opposite inverted/noninverted SEROUT compared to what you're trying at the moment.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tom Sisk

    http://www.siskconsult.com
    ·
  • rilenrilen Posts: 7
    edited 2006-11-02 13:32
    Tom, what's the significance of the -8 to -12 idle voltage? When I have the laptop hooked up to the OBD circuit, the negative voltage is present when read with a multimeter, but I can't see it with an oscilloscope. When the STAMP is hooked up, the negative voltage isn't there at all.

    Also, when the laptop and the OBD circuit exchange hex codes, the low and highs are at 0-12V and 0-5V (see attached).·I don't understand why the negative voltage would be significant? I thought·the high and low hex code voltage levels were·the only critical parameters? Who cares what happens when it's idle?

    OK, so next question would be.....if the negative idle voltage is critical, how would I implement that? I have some MAX232 chips but don't have any experience with these. I've hooked·a MAX232 chip as a buffer, and it just increases my Stamp hex code output from 0-5V to 0-20V.

    Thanks for any suggestions.
Sign In or Register to comment.