What is LIN
LIN is a protocol that connects to the CAN bus through a gateway and offers a cheaper communication option. Learn how to use LIN in this article
We all heard about the most popular protocol for automotive vehicles, CAN. We made some articles about it already, which we recommend to check. For starters, you should read CAN Protocol Overview (opens in a new tab), to understand its basics, if you never got to grips with it.
Today, the focus is on LIN (Local Interconnect Network). How can we define it, and why is it valuable where we have already CAN? Well, LIN is cheaper, and if you know anything about automotive, or any industry in general, is that money is key. That is even one of the main reasons Autosar exists, but it's not the only reason LIN is used. LIN offers a cheaper option (it uses a single 12V wire instead of the two from CAN, it does not have a license fee to use and the LIN nodes are cheaper), while giving a less-reliable and slower communication protocol, where its nodes are usually bundled in clusters, and rely on an existing CAN bus to communicate with each other, or with CAN nodes. In essence, LIN sort-of extends where CAN goes.
Now that we know why LIN is useful, let's dig it further. This is an example of what a LIN network can look like in a vehicle:
LIN network example
In it, you can see the aforementioned LIN networks cluestered, and each of them leading to the CAN bus. This connection to the big brother is made via a LIN main node. In each LIN network, there can be up to 16 secondary nodes connected to a main node, which is the gateway to the CAN bus. At this point, some of the differences between both LIN and CAN are becoming notorious. Let's put them all together:
- LIN uses a single wire with 12V (plus the ground wire, of course) instead of the two cables from CAN (CAN_H and CAN_L)
- No license fee and cheaper nodes than CAN
- Slower speed: maximum of 20 kbps instead of 1 Mpbs of CAN
- 6-bit message identifier, instead of 11 or 29 bits of CAN
- Single main node, where CAN has multiple
- LIN is deterministic, does not perform bus arbitration like CAN
Now, let's see some LIN features we did not touch yet:
- 1 Main node and up to 16 secondary nodes
- Time triggered
- Variable data length of 2, 4 and 8 bytes
- Error detection and checksum
- Sleep and wake-up support
- Bus length up to 40 meters
Now that we know the main differences between LIN and CAN, and its main features, let's take a look at the LIN frames and how the communication is performed. The communication is quite simple: the main requests to each secondary node information, and obtains the response from them, when it's their turn. This is done via two messages: the header, from the main to the secondary nodes, and the response in the opposing way. You can check these frames in the following picture:
LIN header and response messages
In the header, you find the SBF (Sync Break Field), which is like the start of frame we have on CAN, and is 14 bits long or more. This gets the attention of all the secondary LIN nodes in the bus. After that, the sync field of 8 bits with the value of 0x55 is sent, allowing the nodes to calculate the baud rate used by the main node, by measuring the time between rising and falling edges. Afther that, the 6-bit identifier is sent, along with 2 parity bits. The ID's of 60 and 61 are used for diagnostics and the 62 and 63 are reserved.
Regarding the response from the secondary nodes, it consists of the data, with sizes of 2, 4 and 8 bytes. This response size is always the same in each secondary node, and relates to the identifier of the node, where the ID's from 0-31 represent 2-byte responses, 32-47 are for 4 bytes and the remaining are for 8-byte responses. In the end, a checksum is sent, of 8 bits. Depending on the LIN version, the checksum can be classic or enhanced. Their main difference is the classic only considers the data of the response, while the enhanced contains also the ID. Classic checksum is used until LIN 1.3 and the enhanced version is used from LIN 2.0 onwards.
Sometimes, you can see an optional inter-byte space between the bytes. It grants the secondary nodes enough time to process the header from the main node and respond. This is necessary because the nodes can be low-performing, since they are usually cheap, and delays in the response would be usual.
Lastly, we have to answer a simple question: what are the LIN applications in a vehicle? Well, everything that can be considered of a lesser importance and not very time-critical is a good candidate for LIN. To name a few: climate control, wipers, radio, windows and seat controls. LIN is also present on other industries, such as some home appliances and factory automation.
To finish off, I hope this article gave you the necessary understanding of LIN and help you implement it on your next project with the Autosar layered architecture. Have a good one, and don't forget to add us to your mailing list, so you don't miss out!
Author: Micael Coutinho (opens in a new tab)
References:
© AutosarToday —@LinkedIn