capture/repeat data ?


Closed Thread
Results 1 to 40 of 45

Hybrid View

  1. #1
    Join Date
    Jun 2005
    Location
    Wisconsin
    Posts
    382

    Default

    Ok, that tells me a lot. Heres the story.

    First off, yes this is the standard protocol that I had expected. It follows the J2178 SAE standard.

    This is in a 3 byte form meaning the first byte is Priority/Type, second is Target Address (Functional), Third is Source Address.

    All the Sources are "Body Controllers."
    A0-BF are "Convience (Doors, Seats, Windows)"

    The Target Address is Functional which means its value determines the item being controlled.

    6A C2 A0 05 00 FA

    Lets use the above to describe what is what. C2 is the mirrors being sent a message from A0 a source inside the vehicle. 05 is telling the mirror to retract.

    05=retract mirror
    06=extend mirror

    SAE J2178 part 2 describes the packet, and J2178 Part 4 describes the functional addresses. If you google you may run across these documents.

  2. #2
    Join Date
    Mar 2004
    Posts
    92

    Default

    Thanks DynamoBen,
    I'll try to figure this out.

  3. #3
    Join Date
    Mar 2004
    Posts
    92

    Default

    Hi All,

    DynamoBen,thanks to this forum I've started learning to program serial into the PIC !

    Here is the code I'm using: (forgot how to do the code quote here)

    '12F675
    _CONFIG
    _INTRC
    _NOCLKOUT
    _WDT_ON
    _PWRTE_ON
    _MCLRE_OFF
    _BODEN_ON
    DEFINE OSCCAL_1K 1
    INCLUDE "modedefs.bas"
    TX_Pin VAR GPIO.0 'To DB9 RX pin 2
    RX_Pin VAR GPIO.1 'To DB9 TX pin 3

    TRISIO.0 = 0 'Set GPIO.0 to output.
    TRISIO.1 = 1 'Set GPIO.1 to input

    ANSEL = 0 'disable ADCs
    CMCON = 7 'disable comparator

    AChar VAR BYTE
    tx_pin = 0 'inverted mode idle state

    achar="A"
    Pause 100 'OSC settle time...

    loop:
    SerOut tx_pin,N9600,["AT SH 6A C2 00 ",13,10] 'set header
    Pause 2000
    SerOut tx_pin,N9600,["85 00",13,10] 'fold mirrors in


    Problem is the elm322 and the vehicle does not respond at all. I've tried sending inverted and non inverted but the data light on the elm never activates as it does when I send this same data to the vehicle with the laptop.

    Do I need to use a MAX232 for this or maybe modify the elm circuit as talked about in the elm docs ?

    I can read it all in hyperterminal fine, any advice and guidance is much appreciated.

  4. #4
    Join Date
    Jun 2005
    Location
    Wisconsin
    Posts
    382

    Default

    You don't need a max232. First thing to check is that Tx and Rx are crossed over. TX to RX and RX to TX. That would be enough to cause your problem.

    Also on page 17 of the datasheet it talks about about RX input being inverted based on the TTL standard. You would need to reinvert this line for this to work properly. This can be done via software or hardware.

    Let me know what you find.

  5. #5
    Join Date
    Mar 2004
    Posts
    92

    Default

    Hey Ben,
    You were right, I had to switch the serial output of the PIC from the 2 pin on the DB9 cable to the 3 pin. But, that still didn't work so I then removed the 1k resistor that I had inline btwn the PIC and the DB9 and directly connected it to the 3 pin of the DB9 and it worked perfectly!

    Now I have to learn SERIN,the code I posted actually came from a post from Mister_e because it seemed perfect for my project (thank you Mister_e) and then I just changed the output data. But, when I try to send anything from hyperterminal to the 12F675 nothing happens,nothing in the terminal window will show up regardless of any key I press???

    Here is the actual code from Mister_e's post that I need help with getting the SERIN part working if anyone has some suggestions on why it's not working for me.



    '12F675
    @ __CONFIG _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_ON & _MCLRE_OFF & _BODEN_ON
    DEFINE OSCCAL_1K 1
    INCLUDE "modedefs.bas"
    TX_Pin var GPIO.0 'To DB9 RX pin 2
    RX_Pin var GPIO.1 'To DB9 TX pin 3

    TRISIO.0 = 0 'Set GPIO.0 to output.
    TRISIO.1 = 1 'Set GPIO.1 to input

    ANSEL = 0 'disable ADCs
    CMCON = 7 'disable comparator

    AChar var byte
    tx_pin = 0 'inverted mode idle state

    achar="A"
    Pause 100 'OSC settle time...

    loop:
    SerOut tx_pin,N2400,["Waiting for ",achar,13,10]
    SERIN rx_pin,N2400,[achar]
    serout tx_pin,N2400,["Got it...",13,10]
    goto loop


    Thanks again, this is great!

  6. #6
    Join Date
    Jun 2005
    Location
    Wisconsin
    Posts
    382

    Default

    When you communicate with a PC you are now working with RS232 which requires a MAX232 or other circuitry to convert to TTL (the elm devices uses that circuitry for serial in/out). However, with the elm device you are talking TTL and can connect directly to a pic. BTW you can eliminate all the serial circuitry between the elm and pic (you will still need to flip Rx in software or add circuitry to do it via hardware).

  7. #7
    Join Date
    Mar 2004
    Posts
    92

    Default

    Please check out this thread: http://www.picbasic.co.uk/forum/show...=hyperterminal

    This is where I found the code I'm trying and they say a MAX232 isn't needed and I can read the data from the 12F675 in hyperterminal with only a 1k resistor in line with pin 2 direct to the pc which is running hyperterminal.

    However, I cannot get anything to show up in hyperterminal when I try typing on that pc. Nothing that I type shows in the hyperterminal window regardless if the DB9 is connected to the 12F675 or not. This is the same pc that I've used to communicate with the elm322 and when doing that,I'm able to enter characters in the h/t window.

    I'm certainly not doubting your previous statement at all but the guys in the thread above seem to have it working without a MAX232 chip so I thought it would work with my pc (laptop).

Similar Threads

  1. Using Nokia LCD
    By BobP in forum mel PIC BASIC Pro
    Replies: 300
    Last Post: - 3rd May 2018, 04:47
  2. Read/Write Problem
    By Tobias in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 10th February 2010, 01:51
  3. Big characters on HD44780 4x20
    By erpalma in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 7th January 2007, 02:21
  4. LCD + bar graph
    By DynamoBen in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 5th October 2005, 14:50
  5. Sinus calculating !
    By Don Mario in forum mel PIC BASIC Pro
    Replies: 29
    Last Post: - 28th November 2004, 23:56

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

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