Local Interconnect Network (LIN) for Ardunio Uno with: MCP2003AT

I am attempting to create a LIN sniffer (slave Listen only) module with an Ardunio Uno (ATMega328P) as the controller and a Microchip MCP2003AT as the LIN transceiver chip.

MCP2003AT:Link

I have been able to setup the Hardware (HW) layers so my module is able to receive LIN messages. See attached for the HW schematic(s).

The HW and Software(SW) can to some degree process the LIN messages but I do not have a library that can reliably parse and process the LIN messages. Currently if I send a LIN message the HW/SW can read the number of incoming data bytes (it also includes the Sync Byte in addition to the Data and checksum Bytes). However sometimes when the SW processes a byte it does not process correctly and is returned as FFFFFFXX where XX is the hex data in question. See attached for my current SW files. Two examples are provided. One reads data out though the USB to the serial monitor, the other outputs the data to a LCM1602A LCD screen.

I am seeking to find/adapt/create LIN bus processing SW so the unit can reliably read LIN traffic and display to the LCD screen when certain messages are found.

In my searching I have found the following posts/libraries that approach creating libraries for LIN processing by Arduino or ATMega328P.

Arduino forum application for Arduno Uno with MCP2003
Link

This produces a very similar behavior to what I have cited above.

Github post for Arduno Mega
Link

The issue with this code is that it was written for a Arduno Mega board that utilizes a SAM architecture so the libraries are not compatible.

Microchip/Atmel example for "low-level drivers for LIN communication on ATtiny87/167 or ATmega32M1/32C1/64M1/64C1".
Link

The issue with this code is that it seems to be missing a .h file since it has approx. 35 undefined constants and will not compile. Apparently this code was meant for ATmega32M which has specific LIN HW in the MCU and the SW was written for IAR workbench with specific registers.

Another source was another Microchip/Atmel example:
AVR322: LIN Protocol Implementation on megaAVR Microcontrollers
Link

However this code supports: ATMega48/88/168, AT90CAN128, ATtiny45/85. the ATMega88 and ATMega328 are package and pin compatible but the SW was still written for IAR workbench and dependent on IAR header files to define the registers

Uno+LCD out.pdf (10.4 KB)

Uno+Ser out.pdf (9.19 KB)

sketch_jan04a_LIN_in_USBSER_out.ino (1.69 KB)

sketch_jan24a_SWLIN_in_LCD_out.ino (2.31 KB)

LiquidCrystal.h (2.67 KB)

Hello,

I see that you have a lot of experience with Arduino and LIN. I was looking for a solution to switch 5 relay's that need to be controlled with a few Lin message's. The messages coming from a ISOBUS joystick from an agriculture machine. This joystick is directly connected with the main controller with a LIN bus connection. I already figured out which message I need to have (with a PLIN system and a Peak-PRO). Now I found a lot of examples on the internet to connect 2 Arduino to each other with LIN, but I found nothing how to read out a specific part of the message to work with in the Arduino software.

Can you please help me on with some basics? Can I use the MCP2003?

Kind regards,

Daan W.