Difference between revisions of "Controller Area Network (CAN)"

From Humanoid Robots Wiki
Jump to: navigation, search
(MCP2515 Driver)
 
(3 intermediate revisions by 2 users not shown)
Line 10: Line 10:
  
 
== Applications  ==
 
== Applications  ==
 +
 
The [https://python-can.readthedocs.io/en/stable/ python-can] library provides Controller Area Network support for Python, providing common abstractions to different hardware devices, and a suite of utilities for sending and receiving messages on a CAN bus.
 
The [https://python-can.readthedocs.io/en/stable/ python-can] library provides Controller Area Network support for Python, providing common abstractions to different hardware devices, and a suite of utilities for sending and receiving messages on a CAN bus.
  
Line 15: Line 16:
  
 
=== Pi4 ===
 
=== Pi4 ===
 +
 
Raspberry Pi offers an easy to deploy 2-Channel Isolated CAN Bus Expansion HAT which allows to quickly integrate it to the peripheral devices. See the [https://www.waveshare.com/wiki/2-CH_CAN_HAT tutorial] for more information
 
Raspberry Pi offers an easy to deploy 2-Channel Isolated CAN Bus Expansion HAT which allows to quickly integrate it to the peripheral devices. See the [https://www.waveshare.com/wiki/2-CH_CAN_HAT tutorial] for more information
  
 
=== Arduino ===
 
=== Arduino ===
 +
 
Arduino has a good support of the MCPs with many implementations of the [https://github.com/Seeed-Studio/Seeed_Arduino_CAN drivers]
 
Arduino has a good support of the MCPs with many implementations of the [https://github.com/Seeed-Studio/Seeed_Arduino_CAN drivers]
  
 
=== MCP2515 Driver ===
 
=== MCP2515 Driver ===
By default the CAN bus node is supposed to acknowledge every message on the bus weather or not that node is interested in the message. However, the interference on the network can drop some bits during the communication. In the standard mode, the node would not only continuously try to re-send the unacknowledged messages, but also after a short period it would start sending error frames and then eventually go to bus-off mode and stop. This causes sever issues when the CAN network works with multiple motors.
+
 
 +
By default the CAN bus node is supposed to acknowledge every message on the bus whether or not that node is interested in the message. However, the interference on the network can drop some bits during the communication. In the standard mode, the node would not only continuously try to re-send the unacknowledged messages, but also after a short period it would start sending error frames and then eventually go to bus-off mode and stop. This causes sever issues when the CAN network works with multiple motors.
  
 
The controller has a [http://ww1.microchip.com/downloads/en/DeviceDoc/MCP2515-Stand-Alone-CAN-Controller-with-SPI-20001801J.pdf one-shot] setup that requires changes in the driver.
 
The controller has a [http://ww1.microchip.com/downloads/en/DeviceDoc/MCP2515-Stand-Alone-CAN-Controller-with-SPI-20001801J.pdf one-shot] setup that requires changes in the driver.
 +
 +
=== Wiring ===
 +
 +
Here is some suggested equipment for wiring a CAN bus:
 +
 +
* Molex Mini-Fit Junior connectors
 +
** [https://www.digikey.ca/en/products/detail/molex/0638190901/9655931 Crimper]
 +
** [https://www.digikey.ca/en/products/detail/molex/0766500013/2115996 Connector kit]
 +
** [https://www.aliexpress.us/item/3256805730106963.html Extraction tool]
 +
* CAN bus cable
 +
** [https://www.digikey.ca/en/products/detail/igus/CF211-02-01-02/18724291 Cable]
 +
** [https://www.digikey.com/en/products/detail/igus/CF891-07-02/21280679 Alternative Cable]
 +
* Heat shrink
 +
** [https://www.amazon.com/Eventronic-Heat-Shrink-Tubing-Kit-3/dp/B0BVVMCY86 Tubing]
  
 
== References ==
 
== References ==

Latest revision as of 18:13, 27 May 2024

The Controller Area Network (CAN) represents an essential vehicle bus standard. It was explicitly engineered to facilitate communication between microcontrollers and devices without resorting to a central computer. The primary purpose of CAN is to enhance vehicle interconnectivity and foster swift data exchange between various systems within the vehicle.

MCP2515[edit]

The MCP2515 is an integrated circuit produced by Microchip Technology, constructed to function as a stand-alone CAN controller. It exhibits compatibility with an SPI (Serial Peripheral Interface) which makes it versatile in various applications. Although its primary use is in automotive industries, it is also used in a variety of other control applications.[1]

The MCP2515 bridges the connection between the CAN protocol and the SPI protocol by receiving CAN messages and translating them into SPI data, allowing the microcontroller to interpret the information. Similarly, it transforms SPI data into CAN messages for transmission.[2]

The MCP2515's operational details include its capacity to support CAN 2.0A and B, drawing attention to its alignment with established CAN standards and equipping it for both basic and extended frame format usage.[3]

Applications[edit]

The python-can library provides Controller Area Network support for Python, providing common abstractions to different hardware devices, and a suite of utilities for sending and receiving messages on a CAN bus.

There is an example of an installation on Jetson_Orin here.

Pi4[edit]

Raspberry Pi offers an easy to deploy 2-Channel Isolated CAN Bus Expansion HAT which allows to quickly integrate it to the peripheral devices. See the tutorial for more information

Arduino[edit]

Arduino has a good support of the MCPs with many implementations of the drivers

MCP2515 Driver[edit]

By default the CAN bus node is supposed to acknowledge every message on the bus whether or not that node is interested in the message. However, the interference on the network can drop some bits during the communication. In the standard mode, the node would not only continuously try to re-send the unacknowledged messages, but also after a short period it would start sending error frames and then eventually go to bus-off mode and stop. This causes sever issues when the CAN network works with multiple motors.

The controller has a one-shot setup that requires changes in the driver.

Wiring[edit]

Here is some suggested equipment for wiring a CAN bus:

References[edit]

  1. MCP2515 Stand-Alone CAN Controller with SPI Interface. Microchip Technology. Official datasheet.
  2. MCP2515 Stand-Alone CAN Controller with SPI Interface. Microchip Technology. Official datasheet.
  3. MCP2515 Stand-Alone CAN Controller with SPI Interface. Microchip Technology. Official datasheet.