1
\$\begingroup\$

I'm going through some addressing schemes with CAN bus. I came across this post: Most efficient way to handle addressing / termination in a daisy-chained CAN bus?

There's a solution explained called EmCAN. The author says:

EmCan solves the node address problem without requiring special hardware. For details, see the EmCan spec, but basically, each node has a globally unique 7 byte ID. Each node periodically requests a bus address and sends this ID. The collision detection mechanism will guarantee that the bus master sees only one of these requests even if multiple nodes send a address request at the same time. The bus master sends a address assignment message that includes the 7 byte ID and the assigned address, so at most one single node is assigned a new address at a time.

So I'm thinking of this approach:

Until an address is assigned, nodes can only act upon broadcast messages from the bus master, and can only send requests for a address.

  1. There's an unique serial number of 8 bytes, derived from the unique chip identifier of the STM32.
  2. A node ID which is a number between 1 and 127

At first boots up, the node gets a default address 0. It sends its unique 8-byte serial number to master (in the data frame), which then assigns the node a shorter node ID between 1 and 127. As of that point, the node uses only the node ID assigned for communication.

So the big question: what if two nodes with no address assigned send the same address request with the same node Id of zero at boot up? This would cause a conflict no addressed by the CAN protocol.

\$\endgroup\$
4
  • \$\begingroup\$ That's what the serial number is for. \$\endgroup\$
    – DKNguyen
    Mar 31, 2021 at 3:03
  • \$\begingroup\$ But the serial number is sent in data frame, not in the standard or extended ID frame, or where am I wrong? \$\endgroup\$
    – Ander Cash
    Mar 31, 2021 at 3:04
  • \$\begingroup\$ CAN doesn't just stop ignoring what's on the line during transmission just because the address part is over. It might register as an error for the overridden transmitter since what was sent is not what is on the line, or it might back off silently and try again later. I'm not sure which it does if the address is over. \$\endgroup\$
    – DKNguyen
    Mar 31, 2021 at 3:05
  • \$\begingroup\$ I looked it up, it generates an error in the overridden transmitter if a collision occurs outside of the arbitration stage. \$\endgroup\$
    – DKNguyen
    Mar 31, 2021 at 3:18

1 Answer 1

1
\$\begingroup\$

That's what the serial number is for. CAN continues to monitor what is appearing on the line during transmission even after arbitration is over. If a device tries to place a recessive bit on the line bit outside of arbitration but detectes a dominant, it generates an error frame for that device.

\$\endgroup\$
2
  • \$\begingroup\$ Thanks. Another question... I'm not very familiar with Modbus, could a similar addressing method like this be implemented with modbus? \$\endgroup\$
    – Ander Cash
    Mar 31, 2021 at 12:08
  • \$\begingroup\$ I know very little about Modbus. \$\endgroup\$
    – DKNguyen
    Mar 31, 2021 at 19:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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