can-busdivider

Switching between two CAN messages


I have a robot that is moving when it received the CAN message. So, on the robot side I have only one Port for CAN message receiving but I am giving the CAN message from two difference controller, one is from Arduino that receives message from a remote controller and the 2nd is from my laptop thatbconnect with a CAN to UsB cable. What i want to switch between these two messages. For now i am always changing the CAN cable manually. I want to know that is there any CAN switch available or any other way to switch???

Now I am trying to changing the port everytime.


Solution

  • Physical connection

    All you need is to connect all devices in one CAN network. Note that only two terminators (resistors) shall be there. Your network should look like this:

    +---------+--------+---------+--------+ CAN_H
    [120Ω]    |        |         |     [120Ω]
    +----------+--------+---------+-------+ CAN_L
              ||       ||        ||       
             Robot   Arduino   Laptop
    

    Communication

    Option 1

    You might configure each device in a different way, for example:

    Option 2

    Warning

    If both Arduino and laptop would try to control your robot at the same time, it would get duplicated or requests in contradiction. Also it might cause errors on CAN network. I strongly recommend to avoid situations with two devices simulating the same CAN node at the same time as it might cause undefined behavior, CAN devices go to ERROR state or even damage to your robot.

    Some Knowledge Sources

    Other Comments

    This question is not code related, so it does not belong to Stackoverflow (check other spaces for more suitable one).