Shop OBEX P1 Docs P2 Docs Learn Events
Serial Protocol — Parallax Forums

Serial Protocol

J LudwigJ Ludwig Posts: 19
edited 2012-01-09 21:44 in Propeller 1
Hi All,

I'm trying to communicate serially with a Prop to a GM Engine Control Unit ALDL port. It calls for 8 bits, no parity, and 1 stop bit, 8192 Baud. My command string is "$F4 $57 $01 $00 $B4". When I send that out using FullDuplexSerial.spin does it automatically include the stop bit or do I need to do something else? I have been able to read the data out with the Prop by tapping into the serial port receive line of my laptop running TunerPro software but can't get the command string to work using only the Prop. I'm using a MAX232 as an interface between the Prop and the serial line. The ECU is a TTL level interface on a single wire and I purchased a cable that converts to RS-232 with both Tx and Rx lines.

One other question, does serial transmit LSBit first or MSbit first?

The command string code I'm using looks like this:
PUB Main | i, r, d, Rx

  request[0] := $F4
  request[1] := $57
  request[2] := $01
  request[3] := $00
  request[4] := $B4
  
  ser.start(7, 6, %0000, 8192)                       'Start ALDL communications with FullDuplexSerial
  term.start(12)                                                'Start TV Terminal
  waitcnt(clkfreq + cnt)                                    'Give methods chance to start
  term.str(@title)                                             'Print Title on TV screen
                                   
  repeat
     repeat i from 0 to 4                                  'Send command string to ECU
      ser.hex(request[i],2)

JL

Comments

  • DynamoBenDynamoBen Posts: 366
    edited 2012-01-06 14:32
    Are you communicating directly with the ECU or are you going through some sort of serial dongle, I can't tell for sure from your description. If it's direct are you connecting to the ODBII interface under the dash or somewhere else?

    I've done a lot of ODBII work but it has always been with an ELM IC in between largely to make the code on the uC side a little more straight forward. Also if you want to go direct their datasheet has a schematic but you will need to work out the protocol in code.
  • J LudwigJ Ludwig Posts: 19
    edited 2012-01-06 15:02
    My system is ODB1, a 1993 GM P30 Motorhome. I'm connecting through an interface cable I bought from aldlcable dot com, it's the 12 pin serial interface model.

    JL
  • StefanL38StefanL38 Posts: 2,292
    edited 2012-01-06 15:30
    Hi JL,

    we got the same lastname (Stefan Ludwig)
    from your posting it is not really clear to me what you have tested.

    If you "tapped in the serial port receive line of your laptop" do you mean propeller
    laptop---ECU and receiving works this way ?
    or do you mean propeller
    laptop laptop receives data send from the propeller?

    the max232 does voltage levelshifting from 0V/5V to +-12V. So if your ECU is at TTL-level 0V/5V you just need 4.7kOhm-resistors to limit the current into the propeller-io-pins down below 500microampare
    that the internal clamping diodes can drive away the voltabe above 3.6V. Hope you haven*t connected the +-12V side of the max not to the propeller.

    Make tests with most parts as well known working properly. This means connect a PC through a PC +-12V to 00/5V voltage-levelshifer (MAX232) with the ECU directly sending the request string
    to test if the string is right and the ECU is answering

    connect the propeller-chip to the PC-COm_port testing does the propeller send the right request-string

    if this works connect propeller to ECU. Maybe you can solder an Y-cable to hook-up the PC-comport in parallel to listen to the traffic between propeller and ECU

    keep the questions coming
    best regards
    Stefan
  • J LudwigJ Ludwig Posts: 19
    edited 2012-01-06 16:23
    Danke, Stefan!

    I have software called TunerPro RT in my laptop that allows me to monitor values in my engine's computer and I have a cable that converts the ECU's TTL level (I think) to RS-232 levels to feed the laptop. My Prop has a MAX232 connected to convert the voltage levels. What I did was open up the serial cable (essentially a Y-cable) and connect the high level side of the MAX232 to either TX or RX and was able to read data with the Prop on the way to and from the ECU to the laptop. My problem is I can't get the ECU to recognize the command string from the Prop by itself. I've tried connecting directly to the ECU, I've tried using a 74HC04 as a level shifter to bring the 3.3v output from the prop up to 5v, tried both inverted and non-inverted and nothing seems to work. I'm questioning my programming at this point. And, yes, I'm using a resistor in the input to the Prop.

    JL
  • kuronekokuroneko Posts: 3,623
    edited 2012-01-06 16:36
    Just for clarification, how many bytes is the target expecting for the command? It looks like 5 but you're sending 10 ... If it is ASCII based, do you need $ and spaces as well (as indicated in your first post)?
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-01-06 16:46
    To go along with what kuroneko is asking, does ODBI expect ASCII characters representing the values "$F4 $57 $01 $00 $B4" or does it expect the values themselves.

    If you're supposed to send just the values, change:
    repeat i from 0 to 4 'Send command string to ECU
      ser.hex(request[i],2)
    

    To:
    repeat i from 0 to 4 'Send command string to ECU
      ser.tx(request[i])
    
  • J LudwigJ Ludwig Posts: 19
    edited 2012-01-06 21:04
    kuroneko, Duane,

    Your comments may hold the solution to my problem. When I was able to monitor the datastream, the output was in indiviual bytes. I was able to read and display in hex and convert to individual byte values, then identify the parameters according to the datastream definition A138.DS. It lists an initial response from the ECU as $F4 $56 $01 followed by 59 data bytes. I converted the definition file to a text file so it can be opened with notepad if you care to look at it. I believe the ECU is looking for byte values, not ASCII values. I will change my code per your suggestion but will be Monday before I have a chance to try it.

    Thanks for your comments,

    JL
  • J LudwigJ Ludwig Posts: 19
    edited 2012-01-09 19:47
    It works! After I changed the command data from ASCII to numerical, the ECU started replying. It's a work in progress but the important part is working. Here's the code I have at present"
    {The purpose of this object is to capture data from an Engine Control Unit and display that data on a TV screen}
    
    
    CON
            _clkmode = xtal1 + pll16x                     'Standard clock mode * crystal frequency = 80 MHz
            _xinfreq = 5_000_000
    
    VAR
    
      long  request[5]                                   'Stack space for command bytes
      long  data[67]                                     'Stack space for data
        
    OBJ
      ser      : "FullDuplexSerialPlus"
      term     : "tv_text"
      
    PUB Main | i, r, d
    
      request[0] := $F4
      request[1] := $57
      request[2] := $01
      request[3] := $00
      request[4] := $B4
      
      ser.start(7, 6, %0000, 8192)                       'Start ALDL communications with FullDuplexSerial
      term.start(12)                                     'Start TV Terminal
      waitcnt(clkfreq + cnt)                             'Give methods chance to start
      term.str(@title)                                   'Print Title on TV screen
                                       
      repeat
        ser.rxflush
        repeat i from 0 to 4                            'Send command string to ECU
          ser.tx(request[i])
        repeat r from 0 to 66                            'Fill array
          data[r]:= ser.rx
        term.str(string($A,1,$B,2))                      'Set display position
        repeat d from 0 to 66                            'Display array
          term.hex(data[d],2)
          term.str(String($20))
    

    Here's a picture of the display with the engine idling.
    640 x 478 - 119K
    aldl.jpg 118.8K
  • Cluso99Cluso99 Posts: 18,069
    edited 2012-01-09 21:44
    Nice job... congratulations!
Sign In or Register to comment.