7
\$\begingroup\$

Similar to question In a USB cable, is it OK to swap the D+ and D- wires?, is it okay if we interconnect CAN-H and CAN-L lines?

CAN is a differential protocol. Is it that dominant and recessive bits are nothing but voltage differences on these lines?

Information about other differential protocols would also be useful.

\$\endgroup\$
  • \$\begingroup\$ I think there would be two differences: H/L priority swap, and the data gets bitwise inverted. But I don't know enough about CAN to answer confidently. \$\endgroup\$ – travisbartley Jun 19 '13 at 6:15
  • 1
    \$\begingroup\$ No. No. @trav1s No. Note that the voltage difference has a specified polarity, and that recessive means that there is no voltage difference. \$\endgroup\$ – starblue Jun 20 '13 at 19:43
11
\$\begingroup\$

I couldn't find any reference that gave a definitive answer. But looking at a few datasheets, I don't think so. USB is looking at the presence or absence of a change in voltage. Whereas CANBus is looking at the voltage itself.

Here is an example of a USB transmission:

USB NRZ

The ones and zeros are coded depending on whether or not there is a transition.

As opposed to CANBus which takes the difference in the voltage levels as seen in this app note:

CANBus differential

If we look at a datasheet for a CANBus transceiver, for example the MCP2551, we see something along the lines of:

  Sym                  Characteristic                   Min     Max  Units
VDIFF(r)(i)    Recessive differential input voltage    -1.0    +0.5    V
VDIFF(d)(i)    Dominant differential input voltage      0.9     5.0    V

Since a negative voltage is mentioned, this leads me to believe that polarity is important and they are not taking the absolute value of the differential voltage.

So if we have:

$$CANH = 2.5V$$ $$CANL = 2.5V$$

Normally the transceiver would do:

$$CANH - CANL = 2.5V - 2.5V = 0.0V = Recessive$$

If you swapped the lines it would do:

$$CANL - CANH = 2.5V - 2.5V = 0.0V = Recessive$$

So far so good. The problem comes when we have:

$$CANH = 3.5V$$ $$CANL = 1.5V$$

Here, the transceiver would normally do:

$$CANH - CANL = 3.5V - 1.5V = 2.0V = Dominant$$

If you swapped the lines it would do:

$$CANL - CANH = 1.5V - 3.5V = -2.0V = Recessive (out\ of\ spec)$$

So you the receiving end would see nothing but recessive bits.

\$\endgroup\$
  • 3
    \$\begingroup\$ Aah... Interesting.... and and and 7 consecutive recessive bits is nothing but Error condition... How Intelligent specs designers are! :) \$\endgroup\$ – Swanand Jun 19 '13 at 17:50
  • \$\begingroup\$ Doubt: Why -2V will be considered as Recessive?? \$\endgroup\$ – Swanand Jun 20 '13 at 9:48
  • \$\begingroup\$ Doubt \$\endgroup\$ – Peter Mortensen Jun 20 '13 at 16:02
  • 1
    \$\begingroup\$ @Swanand The datasheet for that particular chip says that voltages between -1.0V and +0.5V are recessive. As I noted above, the chip will probably see a voltage of -2.0V as a recessive bit even though it is out of spec. Though technically the value is indeterminate just like a voltage of 0.7V (inbetween recessive and dominant) and so it could be either. Operating electronics out of spec is Schrödinger's cat so it's best not to do it if you don't want a headache. \$\endgroup\$ – embedded.kyle Jun 20 '13 at 23:03
  • 1
    \$\begingroup\$ @Swanand - 7 recessive bits is not an error condition, it happens all the time on an idle bus. And error frame is signified by dominant bits. \$\endgroup\$ – Martin Thompson Mar 7 '14 at 16:02
2
\$\begingroup\$

Swapping CAN-High and CAN-Low lines does not work. This is easy enough to establish empirically. I and my coworkers sometimes swap the lines by accident, and it is immediately apparent that it does not work.

\$\endgroup\$
  • \$\begingroup\$ @embedded.kyle's answer explains why this happens. \$\endgroup\$ – Swanand Jun 20 '13 at 6:26
1
\$\begingroup\$

Everything depends on the transciver model. They is a certain flexibility on the value of CAN_H and CAN_L but I DO think that the value of CAN_H has to be higher in any case (at least for all the model that I have seen).

If you just change the cable pin, as soon as all the CAN_L are connected to each other and the CAN_H as well, it should work.

\$\endgroup\$

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.