Error Detection in CAN

Thread Starter

Kittu20

Joined Oct 12, 2022
482
I've been gone through the CAN protocol specifications, and I'm a bit confused about how error detection and correction works in CAN.

From what I understand, in the CAN protocol, one node transmits a message, and other connected nodes receive it. If the receiver node detects an error in the message, it sends an error frame to other nodes to notify them about the error.

I need you to clarify whether the sender node also checks for errors in the message before transmitting it, such as if the message is not following the rules or contains incorrect information.

So, my question is: does only the receiver node check for errors, or do both the sender and receiver nodes check for errors? In other words, does the sender node also check for errors before transmitting a message on the bus?

I'd appreciate any clarifications on this topic. Thank you in advance for your help!

@Papabravo
 

WBahn

Joined Mar 31, 2012
30,240
There's really no point in the sender checking the message for errors since it produced the message. If it can't construct a correct message, then there's little hope that it has the ability detect that the message it constructed is incorrect since, if it could, it wouldn't have produced an incorrect message in the first place.

The error detection performed by the receiver is to verify that the sender correctly constructed the message, but rather to detect errors that occur DURING transmission. In any transmission, there is a chance that a bit will be received incorrectly, usually due to some kind of noise that corrupts the signal, but also due to things like timing errors.

CAN does not do error correction -- instead it does error detection and retransmission. The distinction is that in an error-correcting protocol, the receiver has sufficient information to not only detect that the received frame has an error, but to determine where that error occurred within the frame and to correct it without having to notify the transmitter of the problem and getting the transmitter to retransmit another copy of the frame. As with all things, there are advantages and disadvantage to both approaches. CAN chose use error detection and retransmission (which is the much more widely chosen alternative in most network protocols).
 

Thread Starter

Kittu20

Joined Oct 12, 2022
482
There's really no point in the sender checking the message for errors since it produced the message. If it can't construct a correct message, then there's little hope that it has the ability detect that the message it constructed is incorrect since, if it could, it wouldn't have produced an incorrect message in the first place.
Thank you. In my understanding, both the sender node and the receiver node monitor the bus for errors. The sender node monitors the bus while it is transmitting a message to ensure that the transmitted bits match what it expects to send. The receiver node also monitors the bus while waiting to receive a message to ensure that the received bits match what it expects to receive. This dual monitoring ensures that errors can be detected and addressed promptly by either the sender or the receiver, depending on where the error occurs in the communication process

IMG_20240401_010807.jpg
 

WBahn

Joined Mar 31, 2012
30,240
We've gone through this with you several times before. The transmitter monitors for bit errors on the bus for the purpose of bus arbitration. If the signal it is trying to put on the bus doesn't match the value that is actually on the bus, it concludes that some other device is overriding it and it suspends transmission, relinquishing the bus to the other device, and will attempt to transmit again later. This is a completely unrelated activity compared to the CRC check performed by the receiver.
 

Papabravo

Joined Feb 24, 2006
21,258
There's really no point in the sender checking the message for errors since it produced the message. If it can't construct a correct message, then there's little hope that it has the ability detect that the message it constructed is incorrect since, if it could, it wouldn't have produced an incorrect message in the first place.
...
This is NOT true. The reason a CAN transmitting node checks for bit errors is that another node may "write" a dominant bit on top of the transmitter's recessive bit. A dominant bit always wins. This happens on every frame in the ACk slot. If there is no other node to "ACK" the message the transmitter throws an error frame, because of the bit error, and resends the message. Transmitters are not supposed to transmit on top of another transmission, but a node powering on or off or malfunctioning may cause some rules to be broken some of the time. It is hard to imagine the other type of bit error where the transmitter sends a dominant bit and hears a recessive bit. Every node on a CAN network checks every aspect of every message all the time.
 
Last edited:

WBahn

Joined Mar 31, 2012
30,240
This is NOT true. The reason a CAN transmitting node checks for bit errors is that another node may "write" a dominant bit on top of the transmitter's recessive bit. A dominant bit always wins. This happens on every frame in the ACk slot. If there is no other node to "ACK" the message the transmitter throws an error frame, because of the bit error, and resends the message. Transmitters are not supposed to transmit on top of another transmission, but a node powering on or off or malfunctioning may cause some rules to be broken some of the time. It is hard to imagine the other type of bit error where the transmitter sends a dominant bit and hears a recessive bit. Every node on a CAN network checks every aspect of every message all the time.
Read the question that was asked -- he specifically asked, more than once, if the sender checks the message for errors BEFORE it transmits it.

I've been gone through the CAN protocol specifications, and I'm a bit confused about how error detection and correction works in CAN.

From what I understand, in the CAN protocol, one node transmits a message, and other connected nodes receive it. If the receiver node detects an error in the message, it sends an error frame to other nodes to notify them about the error.

I need you to clarify whether the sender node also checks for errors in the message before transmitting it, such as if the message is not following the rules or contains incorrect information.

So, my question is: does only the receiver node check for errors, or do both the sender and receiver nodes check for errors? In other words, does the sender node also check for errors before transmitting a message on the bus?

I'd appreciate any clarifications on this topic. Thank you in advance for your help!

@Papabravo
As I explained in another post, the transmitter checking for bit errors is not looking to detect an error in the message, but rather for performing bus arbitration.

If every node on a CAN network checks every aspect of every message all the time, then that requires every node, including the sender, to perform the checksum computation on every message. Are you really claiming that this is the case? If so, what does a node do when it sees a message that is not for it but doesn't pass checksum? If it does nothing, then why does it need to compute the checksum of such messages? If it does something, then what is that something?
 

Papabravo

Joined Feb 24, 2006
21,258
@WBah wrote:
Read the question that was asked -- he specifically asked, more than once, if the sender checks the message for errors BEFORE it transmits it.

I missed that in the TS post.

@WBahn wrote:
If every node on a CAN network checks every aspect of every message all the time, then that requires every node, including the sender, to perform the checksum computation on every message. Are you really claiming that this is the case? If so, what does a node do when it sees a message that is not for it but doesn't pass checksum?

Yes, I am making that claim. A node that sees a message for someone else that has a CRC error will throw an ERROR frame which will lead to every other node doing the same thing.
 

Thread Starter

Kittu20

Joined Oct 12, 2022
482
I understand that in the CAN protocol, multiple types of errors can occur during communication, such as Bit Error, Stuff Error, Frame Error, Acknowledge Error, and CRC Error. However, I am particularly interested in understanding the outcome if two nodes attempt to transmit messages with the same identifier simultaneously.

From what I've gathered, it seems that only one message can be successfully transmitted due to the priority-based arbitration mechanism in CAN. However, I believe there should be an error generated in such a scenario. Which type of error will occur?

Could you kindly provide clarity on what exactly happens when two nodes transmit messages with the same identifier simultaneously? I understand that it's not recommended for two different nodes to use the same ID, but I am interested in understanding the specific outcome in terms of message transmission and type of error occur and error handling.
 
Last edited:

Papabravo

Joined Feb 24, 2006
21,258
I understand that in the CAN protocol, multiple types of errors can occur during communication, such as Bit Error, Stuff Error, Frame Error, Acknowledge Error, and CRC Error. However, I am particularly interested in understanding the outcome if two nodes attempt to transmit messages with the same identifier simultaneously.

From what I've gathered, it seems that only one message can be successfully transmitted due to the priority-based arbitration mechanism in CAN. However, I believe there should be an error generated in such a scenario. Which type of error will occur?

Could you kindly provide clarity on what exactly happens when two nodes transmit messages with the same identifier simultaneously? I understand that it's not recommended for two different nodes to use the same ID, but I am interested in understanding the specific outcome in terms of message transmission and type of error occur and error handling.
If two nodes make it through the arbitration process together because all of the bits are identical then both nodes will continue to transmit until one of the two nodes transmits a recessive bit and the other one transmits a dominant bit. The dominant bit will win on the wire, but the node that transmits the recessive bit will recognize that the bus is in the dominant state, and it will throw an ERROR frame. This will cause all the other nodes to throw ERROR frames as well. When the ERROR frames have subsided, some node will then try to transmit. It could be one or the other of the nodes which caused the problem or another node all together.

This problem is rare but can be avoided by making the rule in the protocol that sits above CAN, that two distinct nodes may not and cannot transmit the same identifier ever in normal operation. The one exception to this is any method used to detect duplicate source addresses of nodes on the network when nodes power on. IMHO, this is not a burdensome restriction.
 
Top