0
\$\begingroup\$

I am trying to see some data on the CANBUS line , I show the CANH and CANL data on the osciloscope line. And detect Rx line, When I show the Transmit message on the CANBUS line, I show the this data on RX line at the same time. Why this occurs ? Is that possible, or I have error ? I am using stm32f4 microcontroller and canbus tranceiver. enter image description here

The message we see on the Canbus line CANH-CANL messages are the data I send from the processor to the sensor. Therefore, why is the data I want to send coming back to the Rx line, ACK is added to the end, but only ACK is not required?

And if there is normal situation how does MCU decide to which is Real Rx data and the returned of the sent data with ack. I am so confused about that.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ If the actual bus status wasn't echoed back to the CAN controller, it would have no way of knowing if bus arbitration was successful or not, or if there were collisions/errors once it has sent everything past the arbitration segment. \$\endgroup\$
    – Lundin
    Jun 23, 2022 at 9:11
  • 1
    \$\begingroup\$ gogogo - Hi, FYI your duplicate question on Stack Overflow has been moved to here and merged with this one, to get all the answers in the same place and it's off-topic on SO. In future, please don't ask the same question on multiple SE sites. Thanks. \$\endgroup\$
    – SamGibson
    Jun 23, 2022 at 10:54

3 Answers 3

3
\$\begingroup\$

The receiver part of the CAN transceiver is active even when you are transmitting.

So you will always receive the transmitted message (as long as there is no error on the bus). The CAN controller uses this to determine that the message was sent correctly.

If the CAN controller receives exactly what is transmits, it knows that all is good. Then of course, it looks for the ACK after transmitting the entire message.

\$\endgroup\$
3
  • \$\begingroup\$ Thank you it was very clear for me, so MCU compare Rx and Tx message and if they match than this message is not considered a new message. \$\endgroup\$
    – gogogo
    Jun 23, 2022 at 8:30
  • \$\begingroup\$ I couldn't find any document describing this issue in detail. Do you have any document suggestions? no documentation mentions the comparison of Rx and Tx \$\endgroup\$
    – gogogo
    Jun 23, 2022 at 8:32
  • 1
    \$\begingroup\$ @gogogo You could read for example chapter 4 here: ti.com/lit/an/sloa101b/sloa101b.pdf \$\endgroup\$
    – Klas-Kenny
    Jun 23, 2022 at 8:36
4
\$\begingroup\$

This is normal. While transmitting, a CAN controller monitors the bus at the same time, and compares it with the transmitted one for possible mismatches.

  • If a mismatch occurs in the bus arbitration phase (transmission of CAN-ID), it means that the arbitration is lost to a higher priority message which is being transmitted by another node. In this case, node stops transmitting the message to try again later, when the bus is idle.

  • If a mismatch occurs in later stages (after the CAN-ID), it means an error in the bus. I can't remember the details of this case.

ACK is received if at least one other node receives the transmitted message. However, it doesn't mean that the node that acknowledged the message is the intended receiver.

\$\endgroup\$
3
  • \$\begingroup\$ does the device compare the message it sends with the message it receives? \$\endgroup\$
    – gogogo
    Jun 23, 2022 at 8:15
  • \$\begingroup\$ @gogogo , Yes, it simultaneously reads back & compares the message while it transmits, bit by bit. If it transmits a recessive bit (1), but reads back a dominant (0) bit, it means one of two cases I mentioned in my answer happened. \$\endgroup\$
    – Tagli
    Jun 23, 2022 at 8:33
  • \$\begingroup\$ Thank you for your reply. \$\endgroup\$
    – gogogo
    Jun 23, 2022 at 8:34
1
\$\begingroup\$

CAN is designed that any node can transmit at any time.

During the arbitration phase of the message each transmitting node will observe if the transmitted bits match the received bits. 0-bits are dominant and 1-bits are recessive. This means a 0-bit will win the arbitration phase. So if two or more nodes transmit at the same time, the node that sees a 0-bit while transmitting a 1-bit will know that it lost the arbitration, and it will stop transmission and delay the message for a bit.

https://upload.wikimedia.org/wikipedia/commons/5/54/CAN-bus-frame-with-stuff-bit-and-correct-CRC.png Source: https://en.wikipedia.org/wiki/CAN_bus

This mechanism only works if COB-IDs are unique. This is required to guarantee that colliding messages can always be detected during the arbitration phase.

Is that possible, or I have error ?

This is normal behaviour (by design).

Therefore, why is the data I want to send coming back to the Rx line, ACK is added to the end, but only ACK is not required?

ACK is added by any other node that received your transmitted message correctly.

And if there is normal situation how does MCU decide to which is Real Rx data and the returned of the sent data with ack. I am so confused about that.

If the transmitting node wins the arbitration phase, ACK is the first bit that differs from the transmitted sequence of bits.

\$\endgroup\$
3
  • \$\begingroup\$ does the device compare the message it sends with the message it receives? If there is Rx line device's send message with ack, how device which message sends another device ? \$\endgroup\$
    – gogogo
    Jun 23, 2022 at 8:17
  • 1
    \$\begingroup\$ "does the device compare the message it sends with the message it receives?": Yes \$\endgroup\$
    – Velvel
    Jun 23, 2022 at 8:21
  • \$\begingroup\$ "If there is Rx line device's send message with ack, how device which message sends another device ?": please rephrase this question, I don't understand what you mean. \$\endgroup\$
    – Velvel
    Jun 23, 2022 at 8:21

Your Answer

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

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