gandrewstone / LIN

The LIN protocol implemented over Arduino APIs (Serial and Digital IO)
118 stars 46 forks source link

LIN transceiver #2

Open slabiak opened 8 years ago

slabiak commented 8 years ago

Hello, do I need to use a LIN transceiver (for example this one http://www.atmel.com/images/atmel-4916-lin-networking-ata6662c_datasheet.pdf ) with your library? I want to generate LIN 2.0 master frame with 8 bytes of data. I used your library to do that, my code looks like this: void loop() { uint8_t cmd1[] = { 0x47, 0x20, 0xF8, 0x73, 0x00, 0x00, 0xCF, 0xFF}; uint8_t cmd2[] = { 0x44, 0x10, 0xF0, 0x73, 0x00, 0x00, 0xCF, 0xFF}; uint8_t cmd3[] = { 0x23, 0xF0, 0xF0, 0x73, 0x00, 0x00, 0xCF, 0xFF}; uint8_t cmd4[] = { 0x5d, 0x47, 0xF0, 0x73, 0x00, 0x00, 0xCF, 0xFF}; uint8_t cmd5[] = { 0xE4, 0xD0, 0xF0, 0x73, 0x00, 0x00, 0xCF, 0xFF}; uint8_t cmd6[] = { 0x42, 0xE1, 0xF2, 0x73, 0x00, 0x00, 0xCF, 0xFF};

lin.send(0x30, cmd1,8,2); delay(70);
lin.send(0x32, cmd2,8,2); delay(70);
lin.send(0x33, cmd3,8,2); delay(70);
lin.send(0x35, cmd4,8,2); delay(70);
lin.send(0x36, cmd5,8,2); delay(70);
lin.send(0x37, cmd6,8,2); delay(70);
} when i look at the TX through my saleae analyzer i see that data bytes are okay but there is something wrong with the checksum, i don't know what's the reason.

lin

gandrewstone commented 8 years ago

Yes, I used the ATA6663: http://www.atmel.com/images/atmel-9146-lin-networking-ata6663-ata6664_datasheet.pdf

You absolutely need a transceiver to communicate with LIN devices (unless of course your uP has an integrated transceiver)... I do not think that the transceiver chip would affect the checksum though (or any other bits). AFAIK it just handles the electrical issues

tlewiscpp commented 8 years ago

Thank you for the information. Follow up question, my LIN device operates at 12V. Does the transceiver step the voltages down so it can communicate serially with the Arduino's 5V hardware serial port? On Mar 14, 2016 2:27 PM, "gandrewstone" notifications@github.com wrote:

Yes, I used the ATA6663: http://www.atmel.com/images/atmel-9146-lin-networking-ata6663-ata6664_datasheet.pdf

You absolutely need a transceiver to communicate with LIN devices... I do not think that the transceiver chip would affect the checksum though (or any other bits). AFAIK it just handles the electrical issues

— Reply to this email directly or view it on GitHub https://github.com/gandrewstone/LIN/issues/2#issuecomment-196456226.

gandrewstone commented 8 years ago

yes look as section 3 (Absolute Maximum Ratings) of http://www.atmel.com/images/atmel-9146-lin-networking-ata6663-ata6664_datasheet.pdf . the LIN pin ranges from -27 to 40 v, the logic pins (including TX) from -0.3 to 5.5v.

On Mon, Mar 14, 2016 at 3:19 PM, Pinguinsan notifications@github.com wrote:

Thank you for the information. Follow up question, my LIN device operates at 12V. Does the transceiver step the voltages down so it can communicate serially with the Arduino's 5V hardware serial port? On Mar 14, 2016 2:27 PM, "gandrewstone" notifications@github.com wrote:

Yes, I used the ATA6663:

http://www.atmel.com/images/atmel-9146-lin-networking-ata6663-ata6664_datasheet.pdf

You absolutely need a transceiver to communicate with LIN devices... I do not think that the transceiver chip would affect the checksum though (or any other bits). AFAIK it just handles the electrical issues

— Reply to this email directly or view it on GitHub https://github.com/gandrewstone/LIN/issues/2#issuecomment-196456226.

— Reply to this email directly or view it on GitHub https://github.com/gandrewstone/LIN/issues/2#issuecomment-196483310.

tlewiscpp commented 7 years ago

Sorry to revive this old thread, but the ATTiny167 appears to be a rare AVR 8-bit chip that supports a LIN controller on the UART pins. Since there exists a port of the Arduino libraries for the ATTiny line, this would eliminate then need for an external LIN transceiver, right? I apologize for the basic questions.

EDIT: Nevermind, I have found the answers to my questions. The answer is NO, the ATTiny does not have a built in LIN transceiver. This software repository is a software implementation of a LIN master MCU, that MUST communicate via TTL serial levels (pins 0 and 1 on the Arduino UNO, or any other UART - The Arduino Mega has 4 of them) to a dedicated LIN transceiver. The one I've found that is the easiest to "breadboard" is the MCP2003/4-A series (http://www.microchip.com/wwwproducts/en/MCP2004A). So, you will communicate with a LIN transceiver IC using the software gandrewstone has written over a dedicated TTL serial port (as I mentioned, pins 0 and 1 for the Uno, or any other UART), and you will attach your LIN bus (LIN only uses 1 pin for data, and 1 pin for GND) to the LIN transceiver.

t3rral33t commented 7 years ago

I'm trying to make this LIN communication work and I could really use some guidance. I want to use an ATmega2560 as a master and have multiple Atmega328p for slaves. I could really use some help understanding how to implement this code and what to change for the master and slave devices. Any help would be very much appreciated, Thanks in advance.

ghislaingautier commented 6 years ago

I'm trying to use this project with this Lin board and an arduino UNO. http://skpang.co.uk/catalog/linbus-breakout-board-p-1417.html have someone experienced it? i cant make it work till now. are they "compatible"?

trainman419 commented 6 years ago

@ghislaingautier that should be compatible; I have a similar project using the MCP2003B and an Arduino Uno that was originally based on this library: https://github.com/trainman419/bekant

ghost commented 5 years ago

@trainman419 do you know how i must use your libary to connect two of these boards https://copperhilltech.com/lin-bus-breakout-board/ with an Arduino Mega2560 one as slave and the other as master and then the master should say "hello" to the slave so that i can read it from the Arduino

trainman419 commented 5 years ago

@philipk25 sorry; this project and my project only implements the LIN master.

ghost commented 5 years ago

@trainman419 do you know a libary for a lin slave to use on this breakout board?