arbitration, mask filter

Thread Starter

Dadu@

Joined Feb 4, 2022
155
I want to explore CAN protocol exploration, and while going through different documents, I stumbled upon a image on LinkedIn. Unfortunately, I saved the image but forgot to note the link. I'll make an effort to find the link and share it soon. My primary focus is on understanding the information related to Frame, Arbitration, and Message Filter in the picture. The image show four nodes on the CAN bus, and I'm interested about how arbitration functions in this multi-master, multi-slave protocol work

IMG-20240115-WA0002.jpg
 

Irving

Joined Jan 30, 2016
5,070
Basically every device on bus is both transmitting and listening simultaneously. The '0' level is an active pull-down, '1' is a weak (relatively) pull up, so '0' is dominant and always 'wins'. I want to transmit a message so I listen to bus and if its idling (at '1') then I send a start bit followed by 11 or 29 bits of message ID (standard v extended frame). If at any time I transmit a '1' but see a '0' I know there is another device on the bus that started transmitting at the same time that has a lower message ID which gives it priority so I stop transmitting and wait for the bus to become idle again.

Does that help?

[edit] The picture is slightly wrong IMHO. The ID that is sent is not the node address, its the message ID. CANBus is an address-less system, it is a message-based protocol so the only thing of interest is the message ID. So, for example, in one of my systems the battery manager node sends out, every second, a message ID #64 whose data field contains the current battery voltage. Only nodes that are interested in battery volts acknowledge and process the message, all other nodes ignore it. The receiving node has no idea where the message originated. Message #7D0 - a very low priority message - on that system is a general 'who are you and how are you?' message sent out by the main node**. Every node responds with the message ID #7Dx where x = 1 - F representing their node type as there can only be one node of any type in the system. The data field returns the status of the node.

** Although CANBus is a multi-master multi-slave network in most implementations there is generally one node that oversees the total environment.
 
Last edited:

Thread Starter

Dadu@

Joined Feb 4, 2022
155
Thank you very much for detail information @Irving

I'm still unclear about how the receiver nodes decide whether to accept or ignore a message?

Assuming three nodes on the bus, if Node 1 sends a message with ID 0x01 and 1 byte of data, I want Node 2 to ignore the message and Node 3 to accept it. I'm unsure how Node 2 decides to accept the message and how Node 3 decides to ignore it ?
 

Papabravo

Joined Feb 24, 2006
22,066
Thank you very much for detail information @Irving

I'm still unclear about how the receiver nodes decide whether to accept or ignore a message?

Assuming three nodes on the bus, if Node 1 sends a message with ID 0x01 and 1 byte of data, I want Node 2 to ignore the message and Node 3 to accept it. I'm unsure how Node 2 decides to accept the message and how Node 3 decides to ignore it ?
The process of deciding which messages to process is described by a simple phrase: "mask and match". There are two processes involved. Process #1 is to decide which bits are relevant to the decision. The "mask" has a 1 bit in each position that must be considered. A 0-bit in the "mask" means that bit is a don't care: it can be a 0 or a 1 – it does not matter. Process #2 takes each of the bits for which the "mask" had a 1-bit and compares it to the "match" value. If the bits selected by the "mask" are equal to the bits in the "match" then the frame is passed onto the processor. That's it.
 

Thread Starter

Dadu@

Joined Feb 4, 2022
155
The process of deciding which messages to process is described by a simple phrase: "mask and match". There are two processes involved. Process #1 is to decide which bits are relevant to the decision. The "mask" has a 1 bit in each position that must be considered. A 0-bit in the "mask" means that bit is a don't care: it can be a 0 or a 1 – it does not matter. Process #2 takes each of the bits for which the "mask" had a 1-bit and compares it to the "match" value. If the bits selected by the "mask" are equal to the bits in the "match" then the frame is passed onto the processor. That's it.
I need your more help to understand general process on what's required to create CAN network, assuming there should be three nodes in network.

We have the following parts available:

Microcontroller with CAN feature (Qty: 3)
CAN Controllers (Qty: 3)
Transceiver ICs (Qty: 3)

I'm unsure whether we can create the three nodes using one microcontroller with CAN feature and three transceiver ICs, and CAN controller not required or if I need a set of microcontroller, CAN controller, and transceiver IC for each node.
 

Papabravo

Joined Feb 24, 2006
22,066
I need your more help to understand general process on what's required to create CAN network, assuming there should be three nodes in network.

We have the following parts available:

Microcontroller with CAN feature (Qty: 3)
CAN Controllers (Qty: 3)
Transceiver ICs (Qty: 3)

I'm unsure whether we can create the three nodes using one microcontroller with CAN feature and three transceiver ICs, and CAN controller not required or if I need a set of microcontroller, CAN controller, and transceiver IC for each node.
The simple answer is that IMHO, a CAN controller is not functional without a processor, but a processor with an internal CAN controller needs only a transceiver. All of this would be abundantly clear by sitting down and reading the datasheets. If you can't get past the datasheets, you might need some introspection to determine the root cause.
 

Thread Starter

Dadu@

Joined Feb 4, 2022
155
The simple answer is that IMHO, a CAN controller is not functional without a processor, but a processor with an internal CAN controller needs only a transceiver. All of this would be abundantly clear by sitting down and reading the datasheets. If you can't get past the datasheets, you might need some introspection to determine the root cause.
How many microcontrollers (inbuilt CAN features )and transceivers are needed for a three-node CAN network?

Is it one microcontroller with three transceivers or three microcontrollers with a three transceivers?
 

Papabravo

Joined Feb 24, 2006
22,066
How many microcontrollers (inbuilt CAN features )and transceivers are needed for a three-node CAN network?

Is it one microcontroller with three transceivers or three microcontrollers with a three transceivers?
You can do a large number of different things, but not all of them make ANY sense. I would start with three processors with onboard CAN peripherals and a transceiver for each processor. I would envision each processor/transceiver on a separate PCB connected by a twisted pair cable. You should also terminate the cable in 1 place with 1/2 the characteristic impedance of a twisted pair. 1/2*120Ω ≈ 60 Ω for a "short" cable system.
 

nsaspook

Joined Aug 27, 2009
16,275

atferrari

Joined Jan 6, 2004
5,007
The simple answer is that IMHO, a CAN controller is not functional without a processor, but a processor with an internal CAN controller needs only a transceiver. All of this would be abundantly clear by sitting down and reading the datasheets. If you can't get past the datasheets, you might need some introspection to determine the root cause.
As a personal challenge I decided to learn the basics of CAN. First I read a huge document about the protocol and then, as @Papabravo suggests, the datasheet of the PIC18F4585 (IIRC). Yes, it was long ago.

In spite of reading many times the advice of testing your nodes against an already working network, I simply implemented three nodes and connected them to each other. To my satisfaction they worked on the first try.

Code was written in pure assembly and I recall passing it to a member of a now extinct forum in UK who could replicate the network with no troubles. Transceivers were not from MCHP.
 
Last edited:

Papabravo

Joined Feb 24, 2006
22,066
We started with a single lonely node to verify that we understood the implications of various choices for the bit timing parameters. A lonely node will retry an unsuccessful transmission (one that receives no Ack in the Ack Slot) forever.
 
Top