Git Product home page Git Product logo

lin's Introduction

This is a LIN (http://en.wikipedia.org/wiki/Local_Interconnect_Network) protocol
master implementation that supports LIN 1.X or LIN 2.X frame types.  

It is built on top of the "Arduino" Serial and digital IO APIs.  These 
"underface" APIs form a useful abstraction layer for any chip.  So its better to
implement them for your new microcontroller and then get LIN for free using this
library than to implement LIN over a raw register set.

The library supports injection of immediate LIN frames, or a "skew heap" based
schedule table.  The skew heap schedule table differs from what is suggested
by the LIN specification (which defines a linked list of LIN frames and time
intervals between them).  This implementation provides a similar "pile" of 
LIN frames, but instead of being a static list, the skew heap essentially 
dynamically sorts the frames to find the next scheduled frame.  This allows
frames to be easily inserted and removed from the schedule, and frame interval 
periods (the time between 2 issues of the same frame) to be changed
dynamically.  It also means that the frame interval period does not depend on
the total length of the schedule table (as it does for the specced linked list
implementation) which eliminates an unnecessary interaction between otherwise
independent LIN devices.

The library was tested on a Lightuino 5 (Arduino Duemilanove/Uno compatible 
board) using a LIN slave LED of unknown provenance.  So you will have to change
the test code to generate frames for whatever LIN device you have on hand.

lin's People

Contributors

gandrewstone avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lin's Issues

LIN transceiver

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

Software Serial

I am trying to convert you code to use software serial, so I can use it the the analyzer board I built based on Zapta's project (https://github.com/zapta/linbus/tree/master/analyzer)

It uses a ATA6631 Lin Transceiver with the RX pin hooked do D2 and TX hooked to C2 (Analog 2, but used at digital)

Goal is to be able send a full frame at a given time. I have already reverse engineered the frame that I need.

Could you maybe give me some pointers?

Lin(LIN_SERIAL& ser=Serial,uint8_t txPin=1);

I know I would change the TX pin to 16 (A2).
I tried defining a software serial by including the Library, and then

'Software Serial mySerial(2,16);'

and then changing ser=Serial to ser=mySerial, but it said mySerial was not not declared in this scope.

LIN response in frame

Hello, i want to use arduino to controll stepper motors by AMIS 30621. As LIN driver i using TJA1028t. Arduino Mega 2560 - uart 1.
With inicialization or send request i have no problem but when i want obtain actual motor position i cant read first byte from driver.

I using command GetActual Position what need to sesnd synchronization and ID from arduino and then immediately obtaining data from driver with checksum.

Data looks like this:
break sync , 0x55 , ID , 0x8C,0x00,0x00,0x00,0x00,checksum
break sync , 0x55 , ID - is from arduino
0x8C,0x00,0x00,0x00,0x00,checksum - response from driver

but i cant read first byte 0x8C and without it i cant do anything.
i trying to read faster but everytime i cant read it.
checksum without first bit is correct with error.

Thank you for response.
Radek

timeout period is longer than necessary

Calculated TBit is 1/10 the real value due to a missing zero. For 19200 baud TBit is 52ms not 5ms.
and 52 vs 50 isn't 40% different it's 4%. so the *14 to recover the missing resolution goes too far.

Probably shouldn't wait 2 frames for a response either.

A better timeout value would be:
timeout = (34+90)*1000000UL/serialSpd;

File missing

Hi, I tried your code but it keeps giving me this error when compiling: fatal error: lightuino5.h: No such file or directory
Help please

Serial Monitor Printing

Hey all,

I tried making two Arduino megas communicate via the LIN bus using the given library, but when I try to print the frame in the serial monitor, it gives some extra garbage values at the beginning and then prints the correct data transmitted and received. I believe that is due to the conflict between the use of serial ports on the Arduino.
image
in the above image 170 is the data sent, and the rest is garbage.
image

in the above image, 1, 170 and 3 are the data and the intial U and the inverted "?" are garbage. Can anyone help me to remove these garbage values, please.

Add header guard to lin.h file.

The code in lin.h file should be surrounded by header guard like this:

#ifndef LIN_H_
#define LIN_H_

// Code goes here.

#endif // LIN_H_

This way it can be included from several files at the same time without having problems of "redeclarations".

Have a nice day! :-)

Chris

LIN Slave

Hello,
is it possible to add the LIn Slave as a lib?
I think ist more tan jus removing the sync bit 0x55, right?
Thank's a lot
Alf

LIN diagnostic frames shall always use checksum calculation of protocol version 1.

in lin.cpp, line 124 should be exchanged to accomplish this automatically:

  // LIN diagnostic frame shall always use CHKSUM of protocol version 1.
  uint8_t cksum = dataChecksum(message, nBytes, (proto == 1 || addr == 0x3C) ? 0 : addrbyte);

Line 182 accordingly ;-):

    // LIN diagnostic frame shall always use CHKSUM of protocol version 1.
    if (proto == 1 || addr == 0x3D) idByte = 0; // Don't cksum the ID byte in LIN 1.x

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.