Site Information

 Loading... Please wait...

Blog

LIN To CAN Bus Gateway - Implementing CAN Bus And Lin Bus Master With Arduino-Compatible Teensy Board

Posted by Wilfried Voss on

NCV7430 LIN-Bus breakout board in combination with the Teensy 3.2 LIN Bus master

This post is a follow-up to a previous entry, LIN To CAN Bus Gateway - Prototyping And Firmware Development With The Arduino-Compatible Teensy Board.

The Teensy USB Development Board

Teensy is a brand of microcontroller development boards created by PJRC and designed by the co-owner, Paul Stoffregen. As a long-time maker of creative technologies, Paul saw the versatility and potential of the Arduino. He combined it with the power and flexibility of ARM-based microcontrollers, which add substantial performance over the more commonly used AVR chips. Out of this idea, he created the Teensy.

I have repeatedly stated that I consider the Arduino series of CPU boards an ideal choice for rapid prototyping, and my preference was always the Arduino Due. The Due is based on an ARM processor, and it comes with ample memory resources and great speed. I admit I was never a great friend of the Teensy series of Arduino-compatible CPU boards, but I understand the advantages of the small form factor and the low-cost approach.

My reservations are regarding the additional installation efforts to make the Teensy compatible with the Arduino IDE, and which, in my humble opinion, would benefit from more efficient documentation.

Programming the Teensy requires the installation of the Loader Application. After installation, the Teensy Loader is in hardware/tools. It is run automatically when using Verify or Upload within the Arduino IDE.

Also, make sure you download all library code as recommended by the installation program, because it includes the necessary code for CAN Bus programming.

Teensy 3.2 CAN Bus And LIN Bus Breakout Board

Teensy 3.2 CAN Bus And LIN Bus Breakout Board

Nevertheless, SKPang Electronics has created their Teensy 3.2 CAN Bus And LIN Bus Breakout Board, which represents exactly the hardware we need to create a CAN to LIN Bus gateway. And, despite my reservations, the programming turned out to be an easy task.

This is a CAN Bus breakout board for use with the Teensy 3.2 (included in the scope of delivery). It comes with an onboard 5 VDC regulator with reverse voltage protection, a CAN Bus transceiver and a prototyping area. The LIN Bus connection is provided by the Microchip MCP2004A chip.

In addition, for more effective testing, we used the LIN Bus Slave RGB LED Breakout Board. This board is an RGB LED breakout board based 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.

CAN Bus And LIN Bus Sketches

As I mentioned previously, programming CAN Bus and LIN Bus functionality was a breeze, and I won't waste anybody's time to explain the code (which is, literally, self-explanatory).

The CAN Bus Demo (Includes the FlexCAN Library), transmits a CAN data frame every 1 second, and displays any received CAN data through the Serial Monitor. The CAN baud rate is set to 500 kBit/sec.

Note: Any professional CAN Bus functionality test requires the use of a CAN Analyzer board plus software running under Windows, because it provides the best means of displaying and testing CAN Bus data.

The LIN Bus Demo switches the LIN Slave LED from green to blue to red. The actual code is ridiculously short, and the LIN Bus communication is easy to understand.

CAN to LIN Bus Gateway Firmware

The previously introduced sketches provide a CAN Bus and LIN Bus functionality test, but they don't represent a LIN-to-CAN gateway. A gateway between two very different serial protocols usually requires message mapping, i.e. a translation of data frames. Thus, the programming of such a gateway requires a closer look at and comparison of CAN Bus and LIN Bus data frames, which will assist in the process of creating a functionality outlining. This will the theme of my next post.

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

Unified Centralized Software Stack For Automotive Networking

A new high-speed network solution for in-vehicle infotainment with device control over Internet Protocol (IP) is now available from Microchip Technology Inc. The Unified Centralized Software Stack (UNICENS) is a software module available at no charge to Microchip customers who are using Intelligent Network Interface Controllers (INIC) such as the OS81118, OS81119 and any future INICs.Modern cars [...]

Read More »