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. I will add a hyperlink below as soon as the software is ready. 

To follow up on the progress, you can either remember the link to this page or follow us on Facebook.

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...

Educational Guides To Atmel AVR Microcontroller Programming

The AVR Microcontroller and Embedded Systems Using Assembly and C: Using Arduino Uno and Atmel StudioThe AVR microcontroller from Atmel (now Microchip) is one of the most widely used 8-bit microcontrollers. Arduino Uno is based on the AVR microcontroller; it is inexpensive and publicly available around the world. In this book, the authors use a [...]

Read More »

Dual Isolated CAN FD Interface Board For Raspberry Pi, Arduino, And Other Embedded Systems

The 2-Channel CAN Bus interface board by Copperhill Technologies was primarily designed with the Raspberry Pi in mind but is, nevertheless, also suitable for other embedded systems such as the Arduino family of CPU boards. The board supports two CAN FD (CAN with Flexible Data-Rate) ports with a data rate of up to 8Mbps. It features [...]

Read More »

Internet-of-Things (IoT) Projects Using The GSM/GPRS/GPS SIM800 Shield For Arduino

Our GSM/GPRS/GPS board is an Arduino shield based on the Quad-band GSM/GPRS/GPS module SIM808, rendering cellular and GPS tracking, all in one module.  It allows you to add location-tracking, voice, text, SMS, and data to your application. This shield fits right on your Arduino or compatible device.  At the heart is a powerful GSM cellular module (we use [...]

Read More »

Internet-Of-Things (IoT) Development Board With Cortex M4 Core And Arduino Expansion

The LPC54018 IoT module, developed by NXP in partnership with Embedded Artists, is suitable for applications that require online and cloud access. It also includes software that allows your application to interface with AWS IoT Services. The module is based on NXP’s LPC54018 microcontroller, which comes with a Cortex-M4 core capable of operating at up to a 180 [...]

Read More »

Arduino SIM Provides Easy Global Cellular Connectivity For Arduino IoT (Internet of Things) Cloud Projects

Arduino introduced Arduino SIM, a service solely for IoT (Internet of Things) devices based on the Arduino platform, providing developers and manufacturers cellular access to an IoT Cloud platform with a single data plan and competitive pricing. Arduino SIM strives to present a route to cellular IoT device development in a setting that is familiar to the [...]

Read More »

Guide To Internet Connectivity With Arduino, Common IoT Protocols, Custom Web Visualization, And Android Apps

Building Arduino Projects for the Internet of Things helps you reach a firm foundation of Arduino-based device development, from which you can go in any direction according to your particular development requirements. Build Arduino-powered devices for daily use, and connect those devices to the Internet.The book introduces the building blocks of the Internet of Things (IoT), [...]

Read More »

Industrial Edge Controller Powered By An Industrialized Raspberry Pi And Arduino

Brainboxes released their BB-400 NeuronEdge Controller to receive, process and transmit machine data. Linking industrial hardware connections with the processing power of a Raspberry Pi Compute Module 3+, the BB-400 NeuronEdge offers the possibilities of open source software in an uncomplicated retrofit way, opening the potential of various types of equipment. The BB-400 NeuronEdge combines Brainboxes IO and serial [...]

Read More »

Building Arduino-Based Projects For The Internet Of Things (IoT)

The IoT: Building Arduino-Based Projects course takes you on a journey to become an expert in the use of IoT by developing a set of projects, and it leads you through securing your IoT environment.In the first module, Learning Internet of Things, you learn how protocols and patterns can put constraints on network topology. You also learn [...]

Read More »

Fun Internet of Things (IoT) Projects With Arduino

Arduino is a powerful and very versatile platform used by millions of people around the world to create DIY electronics projects. It can be connected to a wide variety of sensors and other components, making it the ideal platform to build fantastic Internet of Things (IoT) projects on―the next wave in the era of computing.This book [...]

Read More »