CODESYS - the IEC 61131-3 automation software
https://forum.codesys.com/

CAN communications with Raspberry Pi and CodeSys
https://forum.codesys.com/viewtopic.php?f=21&t=7315
Page 1 of 1

Author:  egret [ Mon Oct 31, 2016 7:41 am ]
Post subject:  CAN communications with Raspberry Pi and CodeSys

Codesys Forum,

I would like to use the Raspberry Pi with an SPI CAN module to establish CAN communications. However, I'm unclear on a few points:

With "CODESYS Control for Raspberry Pi SL" is bi-directional CAN communications supported or is it only possible to monitor the CAN bus?

I'm considering the following CAN modules. Can anybody recommend one over another?
SK Pang Electronics - PiCAN2
MikroElektronika - CAN SPI click 3.3V with Pi 2 click SHIELD
IndustrialBerry - CanBerryDual V2.1

If CAN communications is the only requirement is the Beaglebone a better alternative?

Regards, Ben

Author:  menno [ Wed Nov 09, 2016 1:15 pm ]
Post subject:  Re: CAN communications with Raspberry Pi and CodeSys

CODESYS supports SocketCAN communication. I managed to get CODESYS CAN communication working on a Raspberry Pi 3 with CanberryDual. However, for some reason it only works if one mcp2515-overlay is configured in /boot/config.txt, so only one CAN bus is working. Still figuring out, why that is the case and whether it is a CODESYS or SocketCAN problem. Any help on this appreciated.

Author:  bmunsil [ Tue Nov 15, 2016 2:00 pm ]
Post subject:  Re: CAN communications with Raspberry Pi and CodeSys

I have the PiCanV2 from Skpang it took some browsing of the forums here, but there is a really good thread on it that will help you get it working. you can compile socketcan into you image and configure the codesys control to auto load on CAN1. I actually have an image that I would be more than happy to share if you send me your information. as a side note I am NOT a Linux or Codesys expert. I have just compiled the bits and pieces that the community has provided to make a working system.

so far I have it running on a Raspberry PI B, and Raspberry PI 2 B. I don't have a Raspberry PI 3 yet to get it working but I have been told that there is little difference in the configurations.

I do know however that the Device version 3.5.9.20 doesn't work for me. I have to use an older device version in Codesys V3.

I know this was a bunch of random info put into a not so nicely formatted post but I hope it somewhat helps.

Author:  CanBohr [ Tue Jan 09, 2018 4:31 pm ]
Post subject:  Re: CAN communications with Raspberry Pi and CodeSys

@bmunsil
I have a problem with PiCanV2 from Skpang
Codesys gives me the error message "Bus not running"
But the canbus is working on the raspi, I can see messages by using candump can0.
Codesys Version is 3.5.12.0.
Can you tell me where you found the solution for your problem?
Cheers,
CanBohr

Author:  Edwin Schwellinger [ Thu Jan 11, 2018 6:54 am ]
Post subject:  Re: CAN communications with Raspberry Pi and CodeSys

Hi,
to have this script executable is mandatory:
viewtopic.php?f=21&t=8463#p20132


#!/bin/sh
BITRATE=`expr $2 \\* 1000`
ifconfig $1 down
echo ip link set $1 type can bitrate $BITRATE
ip link set $1 type can bitrate $BITRATE
ifconfig $1 up

BR
Edwin

Page 1 of 1 All times are UTC+01:00
Powered by phpBB® Forum Software © phpBB Limited
https://www.phpbb.com/