0
\$\begingroup\$

I am working with a CAN bus implementation of ATSAMC21 microcontroller now and have a question about CAN arbitration, but not for the ID field, everything is clear there, dominant bit gets the bus.

I have some problems with getting a lot of different IDs for my system and I have to work with CAN 2.0 format, so I have only 11 bits. The idea is to use some more info in the data field of the CAN packet. So the question is how the CAN arbitration within the data field works.

What happens if 2 or more CAN devices will try to transmit packets simultaneously with the same ID? Must the arbitration also process the data field correctly? I have done some tests and it seems to work, but not always, so sometimes MCU detects transmission errors, packet is corrupted (I am monitoring it with a logic analyzer) and TEC value of the error counter is incremented. Is it a right behavior or am I just lucky and it will not work?

I need this functionality for broadcasting commands and would like to know about this feature.

\$\endgroup\$
3
  • \$\begingroup\$ CANbus IDs are UNIQUE by specification. By specification, this will be an error state for the bus and likely something will produce an ERROR frame. \$\endgroup\$
    – pgvoorhees
    May 19, 2020 at 17:41
  • \$\begingroup\$ Yes, probably a short time shift between replies made it possible, but if both transmissions are started within one CAN bit, it fails then. Thank you for your reply! \$\endgroup\$ May 20, 2020 at 7:36
  • \$\begingroup\$ FWIW (keeping in mind it's been a while since I've played in CAN ics), I've NEVER seen a controller IC NOT support the 29b extended ID format. If you really need more IDs than the 11b can get you, see if you can have the format moved over to the 29b \$\endgroup\$
    – pgvoorhees
    May 20, 2020 at 11:36

1 Answer 1

1
\$\begingroup\$

So the question is how the CAN arbitration within the data field works.

It doesn't. The arbitration field is identifier + RTR bit. If two nodes attempts to send the same identifier but with different length or data, there will be a data collision resulting in error frames.

I know from experience that SAMC21 specifically goes haywire if you attempt to send different data with same id. It will sporadically send out error frames and soon go error passive. I encountered that situation myself when I was doing stress tests for a project with that MCU. Which isn't the MCU's fault - it follows the CAN spec.

One possible solution could be to time multiplex different data with the same id, so that they are never sent at the same time.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.