Site Information

 Loading... Please wait...


LIN To CAN Bus Gateway - Prototyping And Firmware Development With The Arduino-Compatible Teensy Board

Posted by Wilfried Voss on

LIN to CAN Gateway Application

In general, let's start with a brief comparison of  CAN Bus (Controller Area Network) and LIN Bus (Local Interconnect Network): LIN Bus networks provide cost-efficient communication in applications where the bandwidth and versatility of the CAN Bus technology are not required. 

LIN Bus applications are relatively inexpensive using the standard serial universal asynchronous receiver/transmitter (UART) technology, which are embedded into most modern low-cost microcontrollers such as, for instance, the Arduino-compatible Teensy 3.2.

Lin Bus vs. CAN Bus

  • LIN is lower cost (less harness, no license fee, cheap nodes)
  • CAN uses twisted shielded dual wires (5V), while LIN uses single wire (12V)
  • A LIN master typically serves as gateway to the CAN bus
  • LIN is deterministic, not event driven (i.e. no bus arbitration)
  • LIN clusters have a single master - CAN Bus supports multi-master operation
  • CAN uses 11 or 29 bit identifiers vs a 6 bit identifiers used by the LIN BUS
  • CAN offers up to 1 Mbit/s vs. LIN at max 20 kbit/s

LIN To CAN Gateway Requirements

In view of the previously described features and applications of both serial communication technologies, there is very obviously a need to connect both networks. However, due to the very different nature of both protocols (i.e. their hardware layers, transmission speed, message frame formats, etc.) plus the requirement to provide a flexible message mapping, you will need to apply some computing in form of an embedded processor system. Also, considering LIN's low-cost approach, the gateway hardware should be as simple as possible.

Teensy 3.2 CAN Bus And LIN Bus Breakout Board

Consequently, we have chosen our  Teensy 3.2 CAN Bus And LIN Bus Breakout Board, because it supports easy and flexible programming features through the Arduino IDE, and it supports both, CAN Bus and LIN Bus, on the same board.

The board comes with an onboard 5 VDC regulator with reverse voltage protection and a CAN Bus transceiver. The LIN Bus connection is provided by the Microchip MCP2004A chip.

The Teensy 3.2 is a complete USB-based microcontroller development system, compatible with Arduino software and libraries. It comes in a minimal footprint, capable of implementing a great variety of projects. All programming is accomplished via the onboard USB port.

As mentioned in the LIN/CAN comparison above, a gateway typically utilizes a LIN Master to communicate with the CAN Bus network. The LIN master node loops through each of the slave node, sending a request for information, and each slave responds with data when polled.

The LIN transceiver can be switched between Master (LIN = High) and Slave (LIN = Low) mode, which is accomplished on the board by using jumper J9 (Closed = Master).

The LIN Bus output (using our breakout board) is controlled per serial communication (UART) using the Arduino Serial1 command (RX1/TX1), while the CAN Bus communication is managed through the processor's internal CAN Bus controllers and onboard CAN Bus transceivers.

The programming of both serial ports, CAN and LIN, is supported by extensive software libraries.

Development Resources

Before addressing the programming resources, it is important to choose the means of simulating and testing the application. First of all, let's look into simulating the LIN Bus, i.e. we need a LIN slave node.

Our  LIN Bus Slave RGB LED Breakout Board is an RGB LED breakout board based the the On Semi NCV7430 IC chip. The breakout board is controlled via a LIN-Bus connection, and it is ideal for use as a LIN Bus slave to test your LIN master software.

For testing the CAN Bus side, I'd recommend our  CAN Bus To USB Mini Converter, which, in combination with the corresponding Windows software, represents a very economical solution to run an effective CAN Bus Analyzer. It allows you to develop, test, manage, and maintain your own CAN Bus network, as well as receiving, sending, logging, and analyzing CAN Bus data.

In regard to programming samples, we have a number of Github downloads:

LIN-to-CAN Gateway Firmware Programming

Now that we have all necessary resources, I will prepare my setup and follow up with another post explaining details such as how to connect the various components and, finally, the LIN to CAN message mapping. 

To follow up on the progress, refer to the follow-up section under Programmable LIN To CAN / CAN FD Gateway.

Arduino Cookbook by Michael MargolisArduino Cookbook

Want to create devices that interact with the physical world? This cookbook is perfect for anyone who wants to experiment with the popular Arduino microcontroller and programming environment. 

You will find more than 200 tips and techniques for building a variety of objects and prototypes such as toys, detectors, robots, and interactive clothing that can sense and respond to touch, sound, position, heat, and light.

You don''t need experience with Arduino or programming to get started. Updated for the Arduino 1.0 release, the recipes in this second edition include practical examples and guidance to help you begin, expand, and enhance your projects right away, whether you are an artist, designer, hobbyist, student, or engineer.

  • Get up to speed on the Arduino board and essential software concepts quickly
  • Learn basic techniques for reading digital and analog signals
  • Use Arduino with a variety of popular input devices and sensors
  • Drive visual displays, generate sound, and control several types of motors
  • Interact with devices that use remote controls, including TVs and appliances
  • Learn techniques for handling time delays and time measurement
  • Apply advanced coding and memory handling techniques

More Information...

Industrial IoT 4G LTE Router & Gateway With Ethernet, RS232, RS485 Serial Ports Plus Digital I/O

The ICR-3200 LTE gateway by Advantech represents an excellent solution to connect IP or serial devices to a cellular network, allowing industrial M2M and IoT applications that comprise of kiosks, industrial PCs, HMIs, traffic controllers, meters, UPS systems, and more.Supporting LTE Cat.4 upload speeds of up to 50 Mbps and download speeds of up to 150 Mbps, the [...]

Read More »

CAN Bus And SAE J1939 Prototyping With The Arduino Due ARM Cortex M3 Processor

Whenever it comes to building rapid prototypes for new CAN Bus or SAE J1939 applications, my first choice is regularly the Arduino Due, a microcontroller board based on the Atmel SAM3X8E ARM Cortex-M3 CPU.In general, the Arduino platform couples an easy-to-use programming environment (IDE) with a vast number of hardware extensions (shields). While I do appreciate programming [...]

Read More »

SAE J1939 to Bluetooth Gateway - Android Code (Java) Sample Code

Just as a fair warning upfront, the code that I am referring to in this post is not a finished sample code, but it demonstrates how to receive and decode SAE J1939 message frames (PGNs) from our JCOM Bluetooth device.  To explain the situation: Some time ago, we had started a customer project with the intention [...]

Read More »

CAN FD To USB Gateway Project With Teensy 3.2 And Microchip MCP2517FD CAN FD Controller

Our Teensy 3.2 With CAN FD Breakout Board provides all the components needed to create your CAN FD to USB-Micro Gateway. The board comes with the Microchip MCP2517FD CAN FD controller, while the Teensy 3.2 provides the USB connection. It also has an onboard 5 VDC regulator and reverse-voltage protection. The MCP2517FD is a cost-effective and small-footprint CAN [...]

Read More »

CAN Bus To Ethernet TCP/IP Gateway Also Supports Bridge Mode

The EtherCAN/2 by esd electronics is a hat-rail mounted gateway that exchanges data between CAN Bus and Ethernet networks. In bridge mode, two EtherCAN/2 modules can be used to connect two CAN Bus networks via TCP/IP.The unit comes with one Ethernet interface (10/100 Mbit/s, RJ45) and one CAN Bus high speed (ISO 11898-2) compatible interface (20 kBit/s up [...]

Read More »

Industrial-Strength USB To RS232, RS485, TTL (UART) Isolated Converter

WaveShare introduced their industrial USB to RS232/485/TTL isolated converter with original FT232RL. It features embedded protection circuits such as power isolation, ADI magnetical isolation, and TVS diode, and more. Also, the USB TO RS232/485/TTL gateway comes with an aluminum alloy enclosure, making it robust and durable for industrial requirements.The USB TO RS232/485/TTL converter is very easy [...]

Read More »

jCOM.J1939.USB SAE J1939 ECU Simulator Board With USB Port - Firmware Update & Hardware Upgrade

Our jCOM.J1939.USB gateway board is a high-performance, low-latency vehicle network adapter for SAE J1939 applications. It allows any host device with a USB COM port the monitoring of SAE J1939 data traffic and communication with an SAE J1939 vehicle network.The board supports the full SAE J1939 protocol according to J1939/81 Network Management (Address Claiming) and J1939/21 Transport [...]

Read More »

LIN Bus To USB Gateway Simulates LIN Master Or LIN Slave

The Baby-LIN-II device by Lipowsky Industrie-Elektronik is a small but powerful system to control a LIN Bus via USB. It simulates LIN Bus master or LIN Bus slave nodes. The electrically-isolated LIN interface bypasses problems in noisy electrical environments.The device also supports stand-alone operation without a PC. A durability test sequence can be defined as a macro and [...]

Read More »

SAE J1939 (CAN Bus) to Modbus, PROFINET, EtherNet-IP Gateways Connect PLCs To Vehicle Engines

Moxa's MGate 5118 industrial protocol gateways support the SAE J1939 protocol, which uses the CAN Bus (Controller Area Network) technology as a hardware layer. SAE J1939 is used to perform communication and diagnostics between vehicle components, diesel engine generators, and compression engines, and it is suitable for the heavy-duty truck industry and backup power systems. It is now customary [...]

Read More »