NavyIsland
Posts: 1
Joined: Thu Sep 14, 2017 8:32 pm

CAN bus communication to and from a Pi

Thu Sep 14, 2017 8:36 pm

Hello, i am attempting to turn a Pi, model yet to be chosen, into a simple PLC using the can bus protocol.

Wondering if any pi supports can communication?

also, i am planing on using c++ as the programing language simply for execution speed. Wondering if anyone knows of any libraries that interpret can?

~Ben

djlegge
Posts: 11
Joined: Tue Jul 07, 2015 1:55 pm

Re: CAN bus communication to and from a Pi

Fri Sep 15, 2017 1:20 pm

The usual way is to use a can controller (eg. MCP2515) connected by the SPI interface to the PI.
Example :
http://www.industrialberry.com/canberrydual-v2-1/

Can bus is supported in the Linux kernel by socketcan and appears as a network interface.
https://en.wikipedia.org/wiki/SocketCAN
https://www.kernel.org/doc/Documentatio ... ng/can.txt

There are also test / debugging programs for socketcan here :
https://github.com/linux-can/can-utils

There are also USB can interfaces available but when I last looked but they were much more expensive and intended to be used with Windows PC's.
I hope this helps get you started.

Darren.

User avatar
PeterO
Posts: 4942
Joined: Sun Jul 22, 2012 4:14 pm

Re: CAN bus communication to and from a Pi

Fri Sep 15, 2017 1:32 pm

SK Pang does a CANBUS HAT.
http://skpang.co.uk/catalog/pican2-canb ... -1475.html
I've used one to communicate with PIC18F devices.

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

Return to “Advanced users”