# How to check the CAN bus is free or not

I read a lot of stuff regarding CAN bus arbitration, but it didn't answer my questions.

If one node is already transmitting the data on the bus and in between another node wants to initiate the data transfer, how will that "another node" get to know that the bus is busy?

All the documents (which I read) take condition that both nodes are starting transmission simultaneously and then one with first dominant bit will get the bus but nobody explained the condition which I want to know.

• Swanand, you may get better answers to your questions if you wait a little bit longer to accept the answer. This is an international community, and some experts may not be able to respond instantly.
– W5VO
Jan 31, 2011 at 12:52
• @W5VO I will remember it next time! Thanks for suggestion! :) Jan 31, 2011 at 13:13

The short answer is that the node must monitor the CAN lines to be idle for a certain time before it attempts to transmit. So if another node is transmitting, it must keep quiet till the other node is done.

A CAN bus is based in differential signalling. The two lines, CAN-High (CAN+) and CAN-Low (CAN-), are both at the same potential when the bus is idle. To send bits, a CAN transmitter puts a differential voltage on the lines of about 2 volts.

A CAN transmitter first sees if the bus is idle and if it is, starts to transmit. How the arbitration works is that a transmitter monitors the bus as it's transmitting. Transmission is done as above by either keeping the two lines at the same potential or at a differential potential. So if the transmitter transmits a bit by keeping the lines at the same potential (sic), but it sees that the two transmit lines have a differential potential, that means that some other node is transmitting and the first transmitter has lost the arbitration. It must then stop transmitting.

When a node first starts transmitting, the bits transmitted are the same until the address of the transmitting node which are obviously different. If two nodes start transmitting together, they will transmit together in sync till the address part is reached. When the address differs, a node will notice a potential difference on the lines even when it is not putting one on the lines. Then it knows it has lost and has to try again. The winning node continues transmitting without knowing that some other node was trying as well. Of course, this logic extends to more than two nodes also.

I hope this helps.

• Good answer! If I remember correctly, sending a '0' is dominant over a '1', which results in the lowest address winning arbitration. A neat feature of this is that if the losing node stops when it's supposed to stop, there will be no data corruption on the bus.
– W5VO
Jan 31, 2011 at 12:44
• Great answer !! Will be most grateful if you could just clear this up: Lets say the identifiers are "1011001" and "1000110" when the third bit is reached the first transmitter is sending "1" and second one is sending "0"; so as per CAN protocol the dominant bit is 0, and it overwrites the recessive bit. So now the Bus holds "0"; the first module detects this and will stop transmission while the second one will keep on transmitting. Is my understanding correct ?? Dec 14, 2016 at 11:29
• @FebinSunny Yes... What you said is correct! Jan 9, 2017 at 11:27
• This answer is neither "good" nor "great". In fact, it is totally wrong. First, transmitter does not "keep the two lines at the same potential" to send recessive bit. It simply stops pulling lines apart, and the termination resistors equalize the potential. Second, the address of the transmitting node is not a part of the arbitration field in CAN spec, although some higher level CAN-based protocols do use it as part of message ID. Third, neither of this has anything to do with detecting idle bus Oct 1, 2018 at 15:00

I know of two ways to resolve it:

First, the CAN controller would always monitor the bus; when it detects a message on the bus it begins the receiving process. Now that it's in the receiving state, it knows the bus is in use when a transmit is requested.

Second, by bit stuffing, the CAN transceiver will not have the same bit for more than five cycles (unless a bus error is detected, in which case you'll see up to 12 dominant bits in a row). The exception to this is when nothing is being transmitted on the bus, when a passive bit is always read. A controller just starting could listen to the bus for five cycles before declaring 'probably free'.

I do not guarantee that these are the actual processes, but based on my (limited) knowledge of CAN, these would work.

• I liked 2nd trick! That is pure logical and awesome! Jan 31, 2011 at 8:45
• You're missing the major point of bus arbitration - that the very first thing in a CAN packet is the address.
– W5VO
Jan 31, 2011 at 12:41
• That wasn't really his question; the question was how a controller determines if there's activity on the bus Jan 1, 2014 at 17:43
• @W5VO CAN frames do not have an address, unless some higher level protocol makes it a part of message ID. Oct 1, 2018 at 15:04
• @CoderTao while bit stuffing is not how controller detects idle bus, you are correct in that it plays important role in this process, by making sure transmitted data cannot be mistaken for end of frame Oct 1, 2018 at 17:52

As CoderTao says - the CAN controller is continually monitoring the bus, so it knows when a transmission is already in progress. So the only time when a collision can happen is when both nodes start to transmit "simultaneously" - within a bit-time of eachother (+a small amount of additional time for bus propagation). Hence those are the only cases you've found in documents :)

The node address determines priority, lower addresses being high priority. The transmission starts with the node broadcasting its address. At the same time it transmits, it listens. Let's say node three and two transmits at the same time. As the last bit of the address, node three broadcasts a 1 and node two broadcasts a 0. Because of the 0, the data line is pulled down to the 0 state. Node three see that instead of the 1 it broadcast, the line is a 0 and stops transmitting.

CAN was first used in cars and trucks. Some sensors needed to have much higher priority than others. For example, anti skid braking needed to have a higher priority than the low windshield washer fluid.

• I already know this.... My Question was not about Arbitration at Start.... It was about in between transmission.... Jan 31, 2011 at 14:18

There are four key elements in CAN specification that allow CAN controllers to detect idle bus state:

• Wired-AND signalling makes it possible for dominant bit transmitted by one of the nodes to be detected by all other nodes transmitting recessive bit at the same time. So, if any node transmitting recessive bit sees dominant state of the bus it knows that the bus is busy.

• Bit stuffing makes sure that there are no more than 5 identical consecutive bits. By itself, bit stuffing is used to maintain synchronization. However a side effect of it is that no more than 5 consecutive recessive bits can occur within the frame bits up to CRC delimiter.

• End-of-frame is a series of 7 recessive bits at the end of a frame. They are not bit-stuffed, so they can be easily detected by controllers. Note, that the bus is not yet idle during this time, as EOF is considered to be a part of the frame.

• Interframe space is a series of 3 recessive intermission bits between the frames, followed by bus idle state. No node is permitted to initiate a transmission during intermission, unless they want to send error or overload frames. Furthermore, the node that transmitted last frame must also send 8 recessive suspend transmission bits after the intermission before initiating another transmission. This last requirement allows other nodes to start sending pending messages, so no node can "hog the bus" indefinitely.

From all of the above, here is how nodes detect idle bus state:

• Receiving nodes simply wait for 10 consecutive recessive bits, which includes EOF and intermission. After that time they consider the bus to be idle and can attempt to begin transmission of their own.

• Transmitting node sends 11 consecutive recessive bits after EOF of the last frame it transmitted. If no other node initiates transmission during this time it considers the bus to be idle and can attempt to begin another transmission. If dominant bit is detected during this time the node becomes a receiver.

The above information plus additional info on bit timing can be found in the CAN specification developed by BOSCH.

• There is a bus with multiple active nodes. A new node is plugged in when there was no communication going on. How this new node will know that bus is idle? 10 consecutive recessive bits are transmitted when this new node was not in picture. Oct 2, 2018 at 7:32
• "Wired-AND signalling" means that recessive bits are not "transmitted" as such, it means transmitting node does not actively generate dominant potential. But they are received, i.e. the receiving nodes sample the bus at bit intervals and they see recessive bit on the line. So, if this new node samples the bus 10 times and sees recessive bit every time it considers the bus idle. Oct 2, 2018 at 8:24
• There is no difference between "10 consecutive recessive bits transmitted when this new node was not in picture" and idle state of the bus after that. If there is no communication any reading of the bus will return recessive bit ("1"). So it does not matter when you start sampling, during or after last dominant bit. As long as receiver sees 10 bits it can start transmitting. BTW, nobody sends 10 bits. The last transmitter "sends" 11 recessive bits, 3 intermission + 8 suspend. If waiting node starts transmitting after 10th the last transmitter loses arbitration and yields the bus to new node Oct 2, 2018 at 8:40

A particular node initiates its transmission after the INTERMISSION period only (this duration is also called SUSPENDED duration, in this period 3 recessive bits are transmitted to the bus after the Transmission of the DATA/REMOTE frame to the bus. This indicates that the BUS is in IDLE state), because, during this period, none of the nodes initiate the Transmission. After the BUS is in IDLE STATE, the node who wants the bus for transmission goes into the ARBITRATION.

After the transmission of the inter frame space to the bus, the nodes present in the CAN network will try to initiate the Transmission. Hence, a particular node knows whether the Bus is busy or not.

• What if, it is going to be first transmission on the bus? In that case there will not be any "Intermission period". Refer @Doc's answer for details. Jan 18, 2017 at 7:46