Reprints     Printer-Friendly    Email this Article    RSS        Font Size     What's This?

[Ideas For Design]

Drive Local Interconnect Network With PC-Type UART Device



Yu Huang  |   ED Online ID #2100  |   April 15, 2002

Article Rating:

A new single-wire serial communication system, called the Local Interconnect Network (LIN), is intended for electronic control units in vehicles (www.lin-subbus.org). Using a PC UART for LIN provides a convenient and low-cost solution for developing and testing LIN devices.

Excluding the wakeup signal, a LIN message begins with a Break Marker of at least 13 bits and a Stop Marker of 1 bit or more, followed by a standard 8N1-coding data stream. Generally, a low-level driver is needed to access the UART hardware and interrupts to generate a startup signal that's compliant with the timing constraints defined by the LIN specification. The technique used here generates the signal via the standard Microsoft VCOMM driver.

The circuit in the figure is based on a modified K-Line interface. It's connected to a standard PC COM port. Two D-type flip-flops (IC4A and IC4B) are connected in series and used as a delay line to generate the startup signal. The TXD signal supplies both the LIN data and the delay line's clock. Diodes D2 and D3, plus resistor R2, form an AND gate, so that either TXD or IC4B can pull the LIN bus low.

The PC starts the LIN message by toggling the RTS line to reset both the D-type flip-flops that pull the LIN bus low. Next, TXD immediately starts transmission. The first two bytes are used to shift 1s through both D-type flip-flops, so that a proper startup signal is generated. Then the LIN bus is controlled only by the TXD signal after the second byte has been transmitted. The timing of the LIN messages is well maintained by the standard VCOMM driver at any baud rate.

The following procedure demonstrates how to implement a LIN master using Win32 API functions. The COM port is initialized in the following steps:

  1. Open the COM port by calling CreateFile.
  2. Initialize the COM port by calling SetupComm.
  3. Set up the COM port by calling SetCommState, SetCommTimeouts.
  4. Set and then clear RTS by calling EscapeCommFunction to reset both D-type flip-flops to 0.
  5. Send 0xDF, which includes two rising edges, to TXD by calling WriteFile and FlushFileBuffers. Then both D-type flip-flops are set to 1, and the LIN bus becomes 1.

The LIN message header is generated by the following COM port manipulations (see the waveforms in the figure):

  1. Enter the "Critical Section" to prevent the long delays caused by switching to other threads.
  2. Set and then clear RTS by calling EscapeCommFunction to reset both D-type flip-flops to 0.
  3. Send 0xF0, 0xF0, 0x55, and LIN message ID to TXD by calling WriteFile and FlushFileBuffers. This generates a 15-bit break marker, followed by a 5-bit stop marker, and 0x55, and the ID.
  4. Leave the "Critical Section" to avoid blocking other threads.
  5. Read back the received data to empty the receiving buffer and verify the data sent. Only three bytes—0 (break), 0x55, and ID—are available.




Reprints     Printer-Friendly    Email this Article    RSS        Font Size     What's This?


  • Automating Analog IP Process Migration
  • C Tools Accelerate HDV Development On Xilinx FPGAs
  • A New Design Inflection Point
  • Forecasting Industry Growth For 2009 And Beyond
  • EDA Retools To Exploit Multicore Architectures
  • Design And Verification Move Up In Abstraction
  • EDA Retools To Exploit Multicore Architectures
  • A New Design Inflection Point
    1) Transportation Guidelines For Lithium Batteries Get Updated
    (236 views today)
    2) Build A Smart Battery Charger Using A Single-Transistor Circuit
    (235 views today)
    3) The Field Of Energy Harvesting Begins To Ripen
    (122 views today)
    4) 2008 BEST Electronic Design Winners
    (116 views today)
    5) Easily Convert Decimal Numbers To Their Binary And BCD Formats
    (101 views today)
    ALL TOP 20







    Reader Comments

    You can also use a standard lin transceiver or a pulldown transistor with a pullup resistor for a transceiver. to send the syncbrake, just modify the baudrate to 8/13 of the nominal br and send 0x00. then switch back to the nominal br and send 0x55 and the identifier. then send/receive the data and chksum

    Anonymous -February 13, 2007

    Just what I was looking for!

    Anonymous -January 31, 2006   (Article Rating: )

    Simple and cheap way to do LIN development on a PC.

    Anonymous -January 25, 2006   (Article Rating: )

    POST YOUR COMMENTS HERE

    Name:

    Email:
    Rate this article:

     less useful more useful 
    1
    2
    3
    4
    5
    Your Comments:

    Enter the text from the image below




    Please refresh the page if you have trouble reading this text.
     
     

    PartFinder

    Find real-time pricing, stock status, same-day/next-day shipping options and more. Brought to you by Digi-Key. Go to PartFinder.    
    GlobalSpec

    PART SEARCH :
    Powered by: GlobalSpec - The Engineering Search Engine
    Sponsored Links

    Electronic Design Europe Electronic Design China EEPN Power Electronics Auto Electronics Microwaves & RF
    Mobile Dev & Design Schematics Find Power Products Military Electronics EE Events Related Resources