I've read couple of threads, but they are all closed now. It seems like it's ongoing struggle on arduino from time to time.
I've hooked MCP2003 to my arduino with LIN pull up so it's set as master.
I've manager to read some messages from my car LIN like
Where 0 I am assuming is sync break. B5 - is that Sync byte ? normally it's 0x55 but I can't see that anywhere in my read dump.
C0 - could be slave address
90 - keeps changing beetween 90/80
B2 - is a colour selection - B1-B5
68 - that's brightness of the color.
and then checksum
Now reading looks correctm but I am struggling to send anything. I mean I want to light it up on my bench but all the slaves is reporting is FF
So I've read that the 0 break sync has to be very specific and found something like that
void syncBreak(){
Serial.end(); //End Serial1
digitalWrite(TX_PIN,LOW); // Force the Tx pin LOW
delayMicroseconds(1400); // LIN spec says Sync Break should be >=13 bit length (1354.16usec)
Serial.begin(9600,SERIAL_8E1); // Re-enable Serial1 (in my case 8N1 rqd)
delayMicroseconds(100); // Allow Serial to pull Tx High - sync break delay
}
I've change module to mcp2021, read articles and check libraries, and everywhere it's pretty simply explained,
fou have break frame 0x00, then sync frame 0x55 and then PID frame. But what I am getting looks nothing alike and I just can't figure it out
So when I was playing in the car and changing colors, it was sending longer message which looks like repeat of previous state plus new state request (?)
dots in example are just repeated previous line (it's spamming those lines so I think it could be slaves sending current state ?)
since 0x00 is my break byte, does that mean 0x20 is my sync byte ? then next byte would be PID or ID ?
Also last byte should be CRC but that does not make sense either since last byte is always 0x26
My goal is so I can trigger LED module from my car on my bench, but I am getting nowhere.
Are you looking at complemented data and or have the wrong baud rate? What error flags are you getting from the LIN control module? This information should be in the data sheets.
I've assumed standard baud rate for LIN of LinBus.begin(19200, SERIAL_8N1);
I've had LIN sniffer from microchip for a moment, and that detected 10417 baud, but I've read that baud rate is fine within some tolerance. also that sniffer gave also way different readings.
However, the fact that messages changes when I am playing with LIN network on the car, tells me that it reads something of the car.
But it's just nothing alike I was reading about LINE, every article mentioned that SYNC byte is always 0x55 but I am not getting that at all, ever.
On My car there is ambient light modules which also have mcp2021 on it, that's why I went with 2021 to exclude module differences (just in case).
When I power module on the workbench, it transmits nothing, but I assume I supposed to wake it up with master, so with break byte and sync byte.
I do not have a lin network set up. You properly troubleshoot you need to have a known good quality signal or a network analyzer. You could get some of the inexpensive 24Mhz logic analyser generally in the $7.00 range and see what you get with them. I believe they will decode LIN, they do fine on SPi, CAN, I2C for me.
Thank you for that, I was looking for way of debugging sygnal cheaper than an oscilloscopes with LIN support, so I will deffinitely try one of those analyser.
CAN is fairly easy, there is plenty of libraries and known mcp2515 and all you need to know is baud rate of your network.
Didnt exoect so much trouble with LIN. I have teansciver as above, and it seems to be reading something, but it just doesnt make sense to me
i been down this road. its all about bound rate when it comes to LIN BUS. For example GM uses 10,417 on everything. if you don't set your LINSerial to that, it will come over with bunch of junk.
When it comes to LIN bound rates, following cover 99% of cars.. 19200, 10417, 9600, 4800, 2400, 1200.
ah, that makes total sense. I think I've seen 10417 one I had a LIN analizer for 5min to mess with it messages were coming and it detected 10417 baudrate, but I thought it's not true since most of them have 19200, but now when you mentioned that .... Great stuff Thanks. I will have a go again
Just have a side question - how to distinguish between 0x00 in a data, and 0x00 break ? I mean it's easier if I know message length and then I can try to look for a pair 0x00 0x55, but maybe there is something smarter ?