Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Post History

66%
+2 −0
Q&A CAN bus open circuit detection

There is no direct way to determine whether the PIC is connected to a CAN bus. Part of the problem is that the PIC never directly connected to the CAN bus anyway. There is a transceiver chip like...

posted 3mo ago by Olin Lathrop‭

Answer
#1: Initial revision by user avatar Olin Lathrop‭ · 2024-07-19T12:10:31Z (3 months ago)
There is no direct way to determine whether the PIC is connected to a CAN bus.  Part of the problem is that the PIC never directly connected to the CAN bus anyway.  There is a transceiver chip like the MCP2551 between the PIC and the bus.  The PIC interfaces to the transceiver via two digital signals: CANTX and CANRX.

CANRX indicates the state of the bus, whether it is in recessive (idle) or dominant state.  Since it is a digital signal, you only get one of those two indications.  There is no way to signal <i>not connected</i>.

CANTX allows the PIC to either drive the bus to the dominant state or leave it alone.  Again, it's a digital signal, so you only get those two choices.

The signal levels on the CAN bus itself (CANH and CANL lines) are quite different from digital logic signals.  The two lines are passively pulled together by a total of 60 &Omega; when everything is connected correctly.  There is also circuitry in the driver chips to float these signals at a nominal 2.5 V.  To signal the dominant state, CANH is pulled high by 900 mV, and CANL low by 900 mV.  To "read" the bus, you decide whether the signals are at the same level, or 1.8 V apart.  That makes the bus differential, with good common mode noise immunity.

The MCP2551 weakly holds both CAN lines together, so they float at the same voltage when nothing is connected to the CANH and CANL pins.  The PIC therefore sees no difference between a bus in the idle state, and no bus connected.

To truly check whether a valid CAN bus is connected to CANH and CANL, you would have to look at their analog levels and test their impedance.  This would take additional hardware, and could also interfere with bus operation when there is a real bus connected.

About the best you can do from the PIC without additional hardware is see whether messages are sent successfully.  For a message to be sent, there has to no only be a bus connected, but there has to be at least one other node on the bus to respond with ACK to the message.  If the PIC sends a message and receives no ACK, then it retries automatically.  I don't remember if it gives up after some number of retries to avoid polluting the bus, but either way, this is something you should be able to detect.