LIN Bus network with a MCP2003 - Wiring of code problem?

Da_Beast:
I have no experience with the interrupt pins and therefore no idea how to use them? In what i understand is that I need to see if the interrupt pin (Rx) is low for 10µs and only then send the message? How can I do this? I'm thinking the arduino needs to watch the interrupt pin for a falling edge during 10µs and if there is no falling edge the message can be transmitted. Now how i translate this into code? I have NO idea and need to do some research.

I can't say it's the best or only way to do it (it's probably not), but I used the falling edge on Rx to flag that it's 'not clear to send' and to reset a timer. Then on a rising edge on Rx, I started a timer that fires another interrupt after 10ms to flag 'clear to send'. If the Rx signal falls before the 10ms timer has finished, the timer is reset again. You only get 'clear to send' if Rx stays high for longer than 10ms.

The MCP chips also have no need for extra components to do the same task. But maybe the arduino needs to work harder for the MCP chips than the TH chip?

I think the component count is much the same between the MCP2025 and TH3122, as both have the voltage regulator that requires input/output capacitors. It's only the MCP2003/2004 that require fewer components.

The question I have about the code is that it just calculates the checksum and you need to ad the calculated sum to the message? Like so:

byte checksumByte = 0;  

for (int i = 0; i <= length; i++){
       checksumByte ^= inByte[i];
     }
inByte[5] = checksumByte;

Correct. Once the checksum is calculated, YOU need to add the checksum to the correct place in the message you want to send. For arguments sake, you would probably call it outByte, or sendByte or something suitably descriptive. inByte is better for the receive side of things, but you can use what you like really.

You would do it the other way around on the receive end:

byte checksumByte = 0;  
      for (int i = 0; i <= length; i++){
        checksumByte ^= inByte[i];
      } 

      if (inByte[length + 1] == checksumByte){

       // do stuff
      }

If you use a fixed length message, you won't need to use inByte[length + 1], you would just use inByte[5] or wherever the checksum is located.

Ian.