RPI - CANOpen: Difference between revisions
(4 intermediate revisions by the same user not shown) | |||
Line 9: | Line 9: | ||
https://copperhilltech.com/search.php?search_query=pican3&Search= | https://copperhilltech.com/search.php?search_query=pican3&Search= | ||
== Extenders == | |||
Various extender/repeaters or fiber media converters | |||
Bus extender: | |||
https://www.vitalsystem.com/can/canr.php | |||
Bridge: | |||
https://www.icpdas-usa.com/i_7532.html | |||
Media converter (fiber): | |||
https://moxastore.express-inc.com/ICF_1170I_M_ST_p/icf-1170i-m-st.htm | |||
Cable length verses data rate: | |||
CAN Bus | |||
Bit Rate Bus Length | |||
*1 Mbit/s 30 m | |||
*800 kbit/s 50 m | |||
*500 kbit/s 100 m | |||
*250 kbit/s 250 m | |||
*125 kbit/s 500 m | |||
*62.5 kbit/s 1000 m | |||
RS-232 | |||
*Bit Rate Bus Length | |||
*115200 bit/s 2.5 m | |||
*57600 bit/s 5.0 m | |||
*38400 bit/s 7.5 m | |||
*19200 bit/s 15 m | |||
*9600 bit/s 30 m | |||
== Config == | == Config == | ||
Line 35: | Line 67: | ||
== CANopen message structure == | == CANopen message structure == | ||
The CANopen frame contains the arbitration field (12 bits) and data fields (8 bytes)[[File:Fig1.1.png|thumb|none|upright=1.5|CANopen frame sequence]] | |||
The CANopen frame contains the arbitration field (12 bits) and data fields (8 bytes)[[File:Fig1.1.png|thumb|none|upright= | |||
The arbitration field contains an 11 bit identifier (COB-ID) which describes the message types. The cob-id defines the message priority, 0 is the highest, 0x7ff is the lowest. It also contains a 1 bit RTR (remote transmit request). This requests a response from the target device. [[File:Fig1.2.png|thumb|none|upright=1.5|Arbitration Fields]] | |||
The arbitration field contains an 11 bit identifier (COB-ID) which describes the message types. The cob-id defines the message priority, 0 is the highest, 0x7ff is the lowest. It also contains a 1 bit RTR (remote transmit request). This requests a response from the target device. [[File:Fig1.2.png|thumb|none|upright= | |||
NMT messages have cob-id of 0 (zero). These messages request the communication state of the node-id (data byte 2) be set to the designated state in data byte 1.[[File:Fig1.3.png|thumb|none|upright=1.5|NMT message structure]]Node Id is set on the device, can not be set via the CANopen protocols. | |||
NMT messages have cob-id of 0 (zero). These messages request the communication state of the node-id (data byte 2) be set to the designated state in data byte 1.[[File:Fig1.3.png|thumb| |
Latest revision as of 15:10, 29 July 2024
Links[edit | edit source]
https://www.autopi.io/blog/canopen-simple-introduction-explained/
https://copperhilltech.com/cangineberry-canopen-module-for-raspberry-pi/
https://copperhilltech.com/search.php?search_query=pican3&Search=
Extenders[edit | edit source]
Various extender/repeaters or fiber media converters
Bus extender: https://www.vitalsystem.com/can/canr.php
Bridge: https://www.icpdas-usa.com/i_7532.html
Media converter (fiber): https://moxastore.express-inc.com/ICF_1170I_M_ST_p/icf-1170i-m-st.htm
Cable length verses data rate: CAN Bus
Bit Rate Bus Length
- 1 Mbit/s 30 m
- 800 kbit/s 50 m
- 500 kbit/s 100 m
- 250 kbit/s 250 m
- 125 kbit/s 500 m
- 62.5 kbit/s 1000 m
RS-232
- Bit Rate Bus Length
- 115200 bit/s 2.5 m
- 57600 bit/s 5.0 m
- 38400 bit/s 7.5 m
- 19200 bit/s 15 m
- 9600 bit/s 30 m
Config[edit | edit source]
Running a Seeed mcp2518fd based board with 2 can bus.
after boot, should see the following:
$ dmesg | grep can
[ 11.115212] mcp251xfd spi0.1 can0: MCP2518FD rev0.0 (-RX_INT -PLL -MAB_NO_WARN +CRC_REG +CRC_RX +CRC_TX +ECC -HD o:40.00MHz c:40.00MHz m:20.00MHz rs:17.00MHz es:16.66MHz rf:17.00MHz ef:16.66MHz) successfully initialized.
[ 11.217854] mcp251xfd spi0.0 can1: MCP2518FD rev0.0 (-RX_INT -PLL -MAB_NO_WARN +CRC_REG +CRC_RX +CRC_TX +ECC -HD o:40.00MHz c:40.00MHz m:20.00MHz rs:17.00MHz es:16.66MHz rf:17.00MHz ef:16.66MHz) successfully initialized.
Now set the interface "up":
$ sudo ip link set can0 up type can bitrate 100000
$ sudo ip link set can1 up type can bitrate 100000
Now testing the link with can0 connected to can1.
$ candump can0
$ cansend can1 111#ff
CANopen message structure[edit | edit source]
The CANopen frame contains the arbitration field (12 bits) and data fields (8 bytes)
The arbitration field contains an 11 bit identifier (COB-ID) which describes the message types. The cob-id defines the message priority, 0 is the highest, 0x7ff is the lowest. It also contains a 1 bit RTR (remote transmit request). This requests a response from the target device.
NMT messages have cob-id of 0 (zero). These messages request the communication state of the node-id (data byte 2) be set to the designated state in data byte 1.
Node Id is set on the device, can not be set via the CANopen protocols.