CanBus general questions

Hi. (sorry from the moderators as I have posted recently questions about can bus, but that questions have answered and editing the previous post to add the new questions will be little confusing)

My new questions about canbus protocol :

  1. Let's say that I have a can network consisting from 5 nodes. I am going to use one node as prime (arduino or raspberry) to host my main code and the other four nodes will be just to send data.. But one of then (one of the forth) is more critical to function than the other 3..

Is any function / code in can bus protocol that could make my main node to check every specific time (let's say every second) if the second major node is still working or else do something (go to standby mode and switch an alarm)

  1. In one test I made with 2 arduino send and receive messages between of them I notice that in one of them (through monitor output) that some times the message came broken (shorted). What have to do in order to be sure that the message was send full and received full? ( I know that would be helpful if I had post the code but as I am at work and posting from my mobile is not easy to post it.. )

Thanks in advance.

although canbus is not a master-slave network you can impose a master-slave protocol on top of it
the master can send messages to poll the slaves (every second say) and if a response is not received within a specified time generate an alert
you can assign each node an ID and the nodes can filter incomming messages to only accept message with its ID (or use an if() statement to check message IDs)

Edit: any particular reason to use Canbus?

CAN allows you to reliably send short messages with a numeric ID as a label (and priority). That's about all. There's no built-in keep-alive or heartbeat functionality to provide status monitoring.

If you are receiving truncated messages then you are either sending messages with an incorrect length value, or you are trying to send messages longer than 8 bytes which isn't possible using regular CAN.

1 Like

The CAN controllers count errors and will not short a message until it has been retried many times. Have you checked the errors and validated there was no error timeout. It appears one is showing a partial message and the other is apariently ok. Check your Bus termination. Power everything down and measure the resistance it should be around 60 Ohms. If much lower you have an extra terminator in the bus. If much higher you are missing one. Also the terminators belong in the nodes on the physical ends of the bus, if not you will probably get something like you are seeing. Also until it is reliable be sure the grounds are connected.

thanks all.. i will take it notice everything you suggest me ...

Hi,
Have you got the gnds of both Arduinos connected together?

Good to see someone actually trying these things instead of simulating or just thinking up questions.
I have some Canbus modules I was going to use as comms on a model railway T-Track display, but pandemic got in the way and plans change.
They were very interesting comms system to use.
You have me slightly motivated to get a test board made up of a number of nodes for a play.

What Canbus modules are you using?

Tom... :+1: :smiley: :coffee: :australia:
PS. The terminating resistors are very important.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.