Search code examples
embeddedcan-buscanopen

CAN bus idle detection


For CAN, the frame starts when SOF (0) is encountered. But let’s say our system just now joined the CAN bus. How will it be able to detect the start of a new CAN Frame?

The EOF is of seven recessive bits plus three IFS (inter frame spacing) bits..so we can wait for 10 consecutive 1's and then if there is a switch to 0 afterwards we can consider that as a start of a new frame.

But, what if previously only one node was connected? Then if we see the ACK bit is 1, the ACK delimiter bit is 1 and the 7 EOF Frame bits are 1. So before the three IFS bits only we get a 10 bits (recessive). If our node starts sending the data in the IFS bit period, what would happen to the system?


Solution

  • Sorry, there was an error in my assumption. If we see the CAN frame structure then a node needs to monitor the bus and if 11 successive bits are detected as '1' then only the node will consider the bus as idle.

    Explanation for above statement.

    One ACK_DELIMETER bit, seven EOF bits and the three IFS bits.

    So, now if we assume that only one node was connected to the system and the next node got connected while the first node is transmitting the data part of the CAN Frame.

    Then the second node will detect, one in CRC-DELIMETER, ACK_SLT, ACK_DELIMETER, seven EOF bits, and three IFS bits. If node 2 has data to send then it would send it at two bits of the IFS time considering the bus as idle at that moment (as 11 bits of 1 value came).

    But as per the CAN 2.0 protocol specification by Bosch, if a node detects a 0 bit in 1 and two bits of IFS time then it sends starting the overload flag. So over here node 1 would start sending the overload flag and from next time onwards the communication would work correctly.

    The same thing will happen if 1 is also there as the last bit of the CRC then the second node might start sending the frame at the 1 sit bit of the IFS time and node 1 would start sending the overload frame as part of the specification.

    Please feel free to share for reviews if you think this is how it is not done.