cbus:socketcan-en
Differences
This shows you the differences between two versions of the page.
| — | cbus:socketcan-en [2024/04/12 07:42] (current) – created - external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== SocketCAN ====== | ||
| + | [[: | ||
| + | [[: | ||
| + | [[: | ||
| + | * [[: | ||
| + | * [[: | ||
| + | |||
| + | \\ | ||
| + | |||
| + | // | ||
| + | |||
| + | \\ | ||
| + | =====Introduction===== | ||
| + | The __**[[: | ||
| + | SocketCAN is only available if the Rocrail server runs on the same Raspberry Pi with the PiCAN on it.\\ | ||
| + | The communication with RCAN((Supports also CBUS)) is direct and binary; No bidirectional conversion needed between the MERG Gridconnect ASCII framing.\\ | ||
| + | The 12VDC power supply for the connected CANGC* units can be provided wit a __**[[: | ||
| + | |||
| + | |||
| + | \\ | ||
| + | |||
| + | =====Documentation===== | ||
| + | * https:// | ||
| + | * https:// | ||
| + | |||
| + | \\ | ||
| + | |||
| + | ===== Pi01CAN Interface ===== | ||
| + | * **[[: | ||
| + | |||
| + | [[: | ||
| + | //The I2C parts can be left out If the RocNet connection is not needed. (Just write a remark in case its ordered at GCA.)//\\ | ||
| + | \\ | ||
| + | =====Raspi Setup===== | ||
| + | |||
| + | ====config.txt==== | ||
| + | Modify the following file as super user, sudo, with a text editor of your choice.\\ | ||
| + | **/ | ||
| + | |||
| + | Remove the comment '#' | ||
| + | //before modify// | ||
| + | < | ||
| + | # | ||
| + | </ | ||
| + | //after modify// | ||
| + | < | ||
| + | dtparam=spi=on | ||
| + | </ | ||
| + | |||
| + | Add the following lines to the end of this file: | ||
| + | < | ||
| + | dtoverlay=mcp2515-can0, | ||
| + | dtoverlay=spi-bcm2835-overlay | ||
| + | </ | ||
| + | ====Reboot==== | ||
| + | < | ||
| + | sudo shutdown -r now | ||
| + | </ | ||
| + | |||
| + | ====interfaces==== | ||
| + | Modify the following file as super user, sudo, with a text editor of your choice.\\ | ||
| + | **/ | ||
| + | |||
| + | Add the following lines to the end of this file: (The comment line '#' | ||
| + | < | ||
| + | # CAN Interface | ||
| + | auto can0 | ||
| + | iface can0 inet manual | ||
| + | pre-up /sbin/ip link set $IFACE type can bitrate 125000 restart-ms 100 | ||
| + | up / | ||
| + | down / | ||
| + | </ | ||
| + | //If the Pi-CAN should be used with MBUS, the bitrate must be set to 250000.//\\ | ||
| + | |||
| + | :!: **Note:** On newer PiOS versions add a file named / | ||
| + | ====Check==== | ||
| + | < | ||
| + | dmesg | egrep -i " | ||
| + | [ 3.998382] CAN device driver interface | ||
| + | [ 4.051102] mcp251x spi0.0 can0: MCP2515 successfully initialized. | ||
| + | </ | ||
| + | \\ | ||
| + | |||
| + | ===== Rocrail Setup ===== | ||
| + | {{: | ||
| + | * Select type SocketCAN | ||
| + | * Set Hostname(device name) to **can0** (If not set: can0 will be used.) | ||
| + | |||
| + | ====Check the device name==== | ||
| + | Check the device name by using the command **ifconfig** on the Raspberry Pi: | ||
| + | < | ||
| + | pi@keltenbahn: | ||
| + | can0: flags=193< | ||
| + | unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 | ||
| + | RX packets 0 bytes 0 (0.0 B) | ||
| + | RX errors 0 dropped 0 overruns 0 frame 0 | ||
| + | TX packets 0 bytes 0 (0.0 B) | ||
| + | TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 | ||
| + | </ | ||
| + | |||
| + | \\ | ||
| + | |||
| + | ===== CANService ===== | ||
| + | As alternative to running Rocrail on the Raspberry Pi, it is also possible to use the __**[[: | ||
| + | It behaves like a GC1e.\\ | ||
| + | |||
| + | \\ | ||
| + | ===== Alternative CAN Board ===== | ||
| + | This low-cost // | ||
| + | {{: | ||
| + | The Raspberry __[[# | ||
| + | < | ||
| + | oscillator=8000000 | ||
| + | </ | ||
| + | Check the board which frequency the crystal has printed on it:\\ | ||
| + | {{: | ||
| + | This example shows 8000 kHz -> 8000000 Hz\\ | ||
| + | For CAN speeds above 125kHz it is recommended to replace this crystal with a [[https:// | ||
| + | \\ | ||
| + | |< >| | ||
| + | | Wiring | ||
| + | ^ Shield ^ Rpi ^ Rpi Pin number(s) ^ Remark ^ | ||
| + | | VCC | 5V | 2, 4 | With 3V3 it will receive, but cannot send CAN packets. | | ||
| + | | GND | Masse (Ground) | 6, 9, 20, 25, 30, 34, 39 | | ||
| + | | CS | GPIO 8 (CE0) | 24 | | ||
| + | | SO | GPIO 9 (MISO) | 21 | | ||
| + | | SI | GPIO 10 (MOSI) | 19 | | ||
| + | | SCK | GPIO 11 (SCLK) | 23 | | ||
| + | | INT | GPIO 25 | 22 | | ||
| + | |||
| + | **Notes:** | ||
| + | * This board is __not isolated__. (ISO1050) | ||
| + | * A ground connection on the screw terminal is missing, and it is __strongly recommended to connect the ground__ of the CAN cable to the GND pin of this board to avoid static voltage which could destroy the electronics. | ||
| + | |||
| + | |||