falco
Posts: 2
Joined: Thu Jun 30, 2016 1:31 am

Re: CAN controller

Thu Jun 30, 2016 3:10 pm

@cadsenthilkumar:

unfortunately I wasn't able to fix with kernel 4.4.x yet. The only thing I tried which works quite well is the use of kernel version 4.1.19 on Raspberry Pi3 B. When using this version I can bring can0 up. Sadly, I had no time for further tests on sending can messages to the physical bus yet.
So, for me it seems there is no problem about the Pi3.
I guess that the problem is caused by myself, but up to now I can't fix it on my own, tried to many things and just doing circles...

Cheers

cadsenthilkumar
Posts: 29
Joined: Wed Sep 25, 2013 11:09 am

Re: CAN controller

Fri Jul 01, 2016 11:47 am

Thanks for you support :)

You means that i can go for the Pi3.

I hope you watched my previous post in the CAN controller regarding pressure sensor value to CAN. Is it possible to connect the one SPI port for CAN and another one for ADC. ?
falco wrote:@cadsenthilkumar:

unfortunately I wasn't able to fix with kernel 4.4.x yet. The only thing I tried which works quite well is the use of kernel version 4.1.19 on Raspberry Pi3 B. When using this version I can bring can0 up. Sadly, I had no time for further tests on sending can messages to the physical bus yet.
So, for me it seems there is no problem about the Pi3.
I guess that the problem is caused by myself, but up to now I can't fix it on my own, tried to many things and just doing circles...

Cheers

edo1
Posts: 136
Joined: Sun Jun 15, 2014 3:33 pm
Location: Russia

Re: CAN controller

Sun Jul 03, 2016 10:08 pm

cadsenthilkumar wrote:Is it possible to connect the one SPI port for CAN and another one for ADC. ?
yes

and you could connect several slaves to one SPI bus

lkernan
Posts: 10
Joined: Wed Apr 27, 2016 12:10 pm

Re: CAN controller

Sat Jul 09, 2016 11:53 am

Is it possible to power the PI3 from a PiCAN2 SMPS?

I'm assuming not since it only outputs 1amp, but just wanted confirmation since it claims to be ok for Pi 2.

bpkeith
Posts: 2
Joined: Thu Jul 21, 2016 5:29 pm

Re: RPi3 with Pican2 Problems

Thu Jul 21, 2016 5:33 pm

By the terminator relay do you mean the one on the PICAN2 board?
1bonp wrote:Hello everyone!

I recently purchased a brand new RaspberryPi 3 Model B+ for my internship project.
The goal is to establish a CAN connection beetween the microcontroller and a device
(which is a battery but it isn't the purpose of my post).

For that i also ordered the Pican2 board from the skpgang website:
skpang.co.uk/catalog/pican2-canbus-board-for-raspberry-pi-2-p-1475.html

Now, i followed every tutorial available on the site, and the "easy to install driver thing" simply won't work.
The Pi can't send any frame. I don't know what to do so far, and i'm blocked since 2 weeks and I can't find the problem.
Any help/suggestion/support would be gladly appreciated.

Now here is the detail of everything i've done so far:

-First of all, I installed the latest Rasbian downloaded from the Raspberry site. I've not encountered any problems formatting my SD card and writing the image. The Rpi boots

normally, i have a HDMI monitor connected to it directly and also a keyboard and a mouse. The first thing i do after configuring the boot is

Code: Select all

sudo apt-get update
sudo apt-get upgrade
in order to have the latest updates. The uname -a command returns me
Linux raspberrypi 4.1.19-v7+
-After a reboot, i added the last 3 lines in config.txt as stated in the tutorial to enable spi and the overlays of mcp-2515 and bcm2835 drivers.

Code: Select all

dtparam=spi=on
dtoverlay=mcp-2515-can0,oscillator=16000000,interrupt=25
dtoverlay=spi-bcm2835-overlay
-Again, i reboot, and i bring up the can interface with this command:

Code: Select all

sudo /sbin/ip link set can0 up type can bitrate 250000 
I use 250 baudrate because the battery uses that transfering speed. But it's not important at the moment. The command ifconfig can0 returns me the can0 connection


-Now, for installing can-utils I used different methods: the result is exactly the same and i can't figure out why. I did a reset of the Rasbian Jessie for each method and

the result is still the same.

1st method

Code: Select all

sudo apt-get install can-utils
sudo reboot
2nd method
As in the tutorial at
http://skpang.co.uk/blog/archives/1165

I did:

Code: Select all

sudo wget http://www.skpang.co.uk/dl/can-test_pi2.zip
unzip can-test_pi2.zip
cd can-test_pi2.zip
for executing the programs as cansend, candump

3rd method

http://elinux.org/Can-utils
I followed exactly what's evoked on the tutorial.
I installed these packages first, because the compiling of the can-utils gave me some errors:

Code: Select all

sudo aptitude install automake autoconf
sudo aptitude install libtool


Now the thing is: whenever i try to use the cansend command, it executes fine.
However,

Code: Select all

 cansend can0 123#13371337 
should send on can0 this frame.
The command it executes.
When i try to use candump can0, the console stays on hold until i'm obliged to ctrl^C

This is the output after sending my frame (the output is exactly the same after accomplishing all the methods)

Image
Image

I don't know what to do so far, i followed every step and it should work but it doesn't..
Is it because it is a RaPi3 and not 2 ?
Strange because the GPIO ports are exactly the same between the 2 models.

I tried also using wireshard to record any incoming input. I used a Usb Pcan connected directly to the 4 way screw terminal
With the software installed on the pc Pcan View i tried sending a frame every 1000ms but the device doesn't record any input.

Image

I noticed there is a LED on the right side of the 4way screw terminal, near the R8 resistance. It's always off, i'm asking myself if there is a connectivity problems between the Can module and the Pi (strange because when i try to bring the can0 interface up, it recognises my device .. )




Thank you in advance for considering helping me.

Filip


EDIT:
Okay , so finnally i discovered what was wrong all this time: if you want to use the Raspberry Pi with an external device, you MUST enable the terminator resistor to avoid reflections/perturbation of the signal. Once you enabled it just follow the steps and it will work

bpkeith
Posts: 2
Joined: Thu Jul 21, 2016 5:29 pm

Re: CAN controller

Mon Jul 25, 2016 3:05 pm

Has anyone used the PICAN2 board to talk to GMLAN? I cannot get can0 to receive anything.

mauerflitza
Posts: 2
Joined: Fri Aug 26, 2016 4:11 am

Re: CAN controller

Fri Aug 26, 2016 5:56 am

So I tried to connect the Pican2 Can Controller board to my compute module. I am able to load the can interface, but after that nothing is working. So I cant dump or send any can messages.
Is there a difference for the compute module or what else can I try?
My kernel version is 4.4.19

this is my /boot/config.txt:

Code: Select all

dtparam=spi=on
dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25
dtoverlay=spi-bcm2835
Is there any other way to test if anthing is working or did someone before got the Compute module to work with the mcp2515 CAN-controller?

MikeR92
Posts: 1
Joined: Tue Sep 27, 2016 11:09 am

Re: CAN controller

Tue Sep 27, 2016 11:26 am

Using RPI and PICAN Rev B 10/12 I set up everything, it works fine, with can-utils cansend and candump works but...

1. I want do this line:
sudo /sbin/ip link set can0 up type can bitrate 500000
in startup, how to do it?

2. In my project I connect to Lidar by CAN bus, my program should send in some time periods some frames - exactly the same frames in period of 10 ms, 20ms and others, and between this it must get some frames from lidar. Can you help me?

templar47
Posts: 1
Joined: Tue Oct 04, 2016 5:37 am

Re: CAN controller

Thu Oct 06, 2016 3:46 pm

Hi there,

It looks like 1 person was able to get PiCAN2 to work with kernel 4.19. I tried the same thing and still nothing came out of can dump although i can bring up the interface.

tira
Posts: 1
Joined: Wed Oct 26, 2016 11:11 pm

Re: CAN controller

Wed Oct 26, 2016 11:14 pm

Here my pican2 works correctly on a raspberry pi 3 b with the more recent 4.4 kernel:
Linux raspberrypi3 4.4.26-v7+ #915 SMP Thu Oct 20 17:08:44 BST 2016 armv7l GNU/Linux

berne
Posts: 25
Joined: Sat Sep 24, 2016 10:53 pm

Re: CAN controller

Wed Nov 02, 2016 5:00 pm

update... i have mod my click, so its now 3V:) will try this guide, and see what will happend


EDIT:

Code: Select all

[email protected]:~ $ ls /sys/bus/spi/devices/spi0.0
driver  modalias  net  of_node  subsystem  uevent
[email protected]:~ $ ls /sys/bus/spi/devices/spi0.0/net
can0
[email protected]:~ $ ls /sys/bus/spi/devices/spi0.0
driver  modalias  net  of_node  subsystem  uevent
[email protected]:~ $ ls /sys/bus/spi/devices/spi0.0/net/
can0
[email protected]:~ $ ls /sys/bus/spi/devices/spi0.0/net/can0/
addr_assign_type  carrier_changes  duplex             iflink            operstate       speed         uevent
address           device           flags              link_mode         phys_port_id    statistics
addr_len          dev_id           gro_flush_timeout  mtu               phys_port_name  subsystem
broadcast         dev_port         ifalias            name_assign_type  phys_switch_id  tx_queue_len
carrier           dormant          ifindex            netdev_group      queues          type

this works like a charm:)

but the next step:

Code: Select all

[email protected]:~ $ sudo ip link set can0 up type can bitrate 125000
iget: RTNETLINK answers: Device or resource busy
idees?

berne
Posts: 25
Joined: Sat Sep 24, 2016 10:53 pm

Re: CAN controller

Fri Nov 04, 2016 4:25 pm

berne wrote:update... i have mod my click, so its now 3V:) will try this guide, and see what will happend


EDIT:

Code: Select all

[email protected]:~ $ ls /sys/bus/spi/devices/spi0.0
driver  modalias  net  of_node  subsystem  uevent
[email protected]:~ $ ls /sys/bus/spi/devices/spi0.0/net
can0
[email protected]:~ $ ls /sys/bus/spi/devices/spi0.0
driver  modalias  net  of_node  subsystem  uevent
[email protected]:~ $ ls /sys/bus/spi/devices/spi0.0/net/
can0
[email protected]:~ $ ls /sys/bus/spi/devices/spi0.0/net/can0/
addr_assign_type  carrier_changes  duplex             iflink            operstate       speed         uevent
address           device           flags              link_mode         phys_port_id    statistics
addr_len          dev_id           gro_flush_timeout  mtu               phys_port_name  subsystem
broadcast         dev_port         ifalias            name_assign_type  phys_switch_id  tx_queue_len
carrier           dormant          ifindex            netdev_group      queues          type

this works like a charm:)

but the next step:

Code: Select all

[email protected]:~ $ sudo ip link set can0 up type can bitrate 125000
iget: RTNETLINK answers: Device or resource busy
idees?

any one?

berne
Posts: 25
Joined: Sat Sep 24, 2016 10:53 pm

Re: CAN controller

Wed Nov 16, 2016 8:47 pm

Code: Select all

ls /sys/bus/spi/devices/spi0.0/net
my answer:

Code: Select all

can0
so so far so good, evryting looks it sholde work,
if i do

Code: Select all

ifconfig
i cant find the can.

and when tying to set ip link to 125 i get:
RTNETLINK answers: No such device

berne
Posts: 25
Joined: Sat Sep 24, 2016 10:53 pm

Re: CAN controller

Fri Nov 18, 2016 4:45 pm

i have followd u guide, and think all is set, i am SSH to pi from my mac, and download the program USBtin, but what port am i telling to work on? i saw some one com5... i got error on that on. im am coonectet in the same network

Puckysmile
Posts: 6
Joined: Sun Nov 27, 2016 5:22 pm

Re: CAN controller

Mon Nov 28, 2016 8:02 pm

Hello,

I have build my own adapter PCB for CAN, similar to skpangs. My chip is working in loopback mode but I am not able to communicate with PCAN-USB (http://www.peak-system.com/PCAN-USB.199.0.html?L=1) on the other side.

I am not able to send/receive anything. All the steps that others did worked like a charm, cansend exucutes with no errors. When I try to send a message bus goes to bus-off. I tried connecting the GND along with CANH and CANL but that did not help.

I am running out of ideas for debugging, does somebody maybe have any advice?

Thank you.

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

Re: CAN controller

Mon Nov 28, 2016 8:11 pm

Are you sure you have the same bit rate set on both nodes ? I've seen similar behaviour with two nodes on a bus and one with the wrong bit rate .

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

Puckysmile
Posts: 6
Joined: Sun Nov 27, 2016 5:22 pm

Re: CAN controller

Mon Nov 28, 2016 8:24 pm

PeterO wrote:Are you sure you have the same bit rate set on both nodes ? I've seen similar behaviour with two nodes on a bus and one with the wrong bit rate .

PeterO
I use this command (or variations) on RPi: [email protected]:~ $ sudo ip link set can0 up type can bitrate 500000 and set 500 kbit/s on my PCAN-USB. Am I missing something?

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

Re: CAN controller

Mon Nov 28, 2016 8:37 pm

Puckysmile wrote:
PeterO wrote:Are you sure you have the same bit rate set on both nodes ? I've seen similar behaviour with two nodes on a bus and one with the wrong bit rate .

PeterO
I use this command (or variations) on RPi: [email protected]:~ $ sudo ip link set can0 up type can bitrate 500000 and set 500 kbit/s on my PCAN-USB. Am I missing something?
No, that should be doing the trick :-) What are you using as a Bus Transceiver ?

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

Puckysmile
Posts: 6
Joined: Sun Nov 27, 2016 5:22 pm

Re: CAN controller

Mon Nov 28, 2016 9:00 pm

PeterO wrote:
Puckysmile wrote:
PeterO wrote:Are you sure you have the same bit rate set on both nodes ? I've seen similar behaviour with two nodes on a bus and one with the wrong bit rate .

PeterO
I use this command (or variations) on RPi: [email protected]:~ $ sudo ip link set can0 up type can bitrate 500000 and set 500 kbit/s on my PCAN-USB. Am I missing something?
No, that should be doing the trick :-) What are you using as a Bus Transceiver ?

PeterO
I am using MCP2551.

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

Re: CAN controller

Mon Nov 28, 2016 9:24 pm

What test equipment do you have available ?

Can you monitor the TXD and RXD pins to see the bit streams when sending form each end ??

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

Puckysmile
Posts: 6
Joined: Sun Nov 27, 2016 5:22 pm

Re: CAN controller

Mon Nov 28, 2016 9:34 pm

PeterO wrote:What test equipment do you have available ?

Can you monitor the TXD and RXD pins to see the bit streams when sending form each end ??

PeterO
I will try to measure with an oscilloscope, what could I expect and is there anything I can do to change it? I suppose I will see some error state very fast...

Puckysmile
Posts: 6
Joined: Sun Nov 27, 2016 5:22 pm

Re: CAN controller

Sat Dec 03, 2016 12:00 pm

Hi,

I managed to do some measurements with my scope.

As I said on the other side I have PEAK-CAN and a PCAN-view program. Nothing is received and it is written busheavy immediatelly. When I try to send from PEAK-CAN i get BUSS-OFF and on my scope I see only few small impulses not more than 1 Vpp and after that nothing. Ofcourse nothing is received on my PI.

The same thing happens when I try to send from the Pi, nothing is sent... BUS-OFF after one cansend. When I set wrong GPIO for interrupt then my Pi constantly sends the message but it is not read on the PEAKCAN. I can see the signal on the scope...

Everything works fine in loopback mode. I hava a termination resistor on my adapter, for PEAKCAN I am not sure, but the device works with other modules...

Connecting the GNDs does not help.

Thank you for your help.

annerajb
Posts: 2
Joined: Sat Dec 17, 2016 4:02 am

Re: CAN controller

Sat Dec 17, 2016 4:39 am

Hello,

I am having issue trying to get the can working.
I am using a MCP2515 boards they work fine on chipkit core but for some reason when I try to get it to work it does not.
My only guess is that the kernel version is wrong/not supported?

Dmesg shows nothing showing as the driver being loaded and failling.

Code: Select all

[email protected]:~ $ sudo dtoverlay -l
No overlays loaded

Code: Select all

sudo /sbin/ip link set can0 up type can bitrate 250000
Cannot find device "can0"

Code: Select all

modprobe can
dmesg shows: [  468.742480] can: controller area network core (rev 20120528 abi 9)

Code: Select all

uname -a Linux raspberrypi 4.4.38-v7+ #938 SMP Thu Dec 15 15:22:21 GMT 2016 armv7l GNU/Linux

Code: Select all

[email protected]:~ $ lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description:    Raspbian GNU/Linux 8.0 (jessie)
Release:        8.0
Codename:       jessie

Code: Select all

dtparam=spi=on
dtoverlay=mcp2515-can0-overlay,oscillator=16000000,interrupt=25
dtoverlay=spi-bcm2835-overlay
Any idea?

nickb834
Posts: 1
Joined: Sat Dec 17, 2016 10:56 pm

Re: CAN controller

Sat Dec 17, 2016 11:00 pm

If you're on a recent install with a likely 4.4 kernel - you'll find the overlay names need to change.

Have a look at the bottom of section 2.1 on this link:

https://www.raspberrypi.org/documentati ... md#part2.1
UPDATE: The Dynamic Device Tree support in the kernel requires a different format of "local fixups" in the overlay. To avoid problems with old and new styles of overlay coexisting, and to match other users of overlays, the old "name-overlay.dtb" naming scheme has been replaced with "name.dtbo" from 4.4 onwards. Overlays should be referred to by name alone, and the firmware or utility that loads them will append the appropriate suffix. For example:

dtoverlay=awesome-overlay # This is wrong
dtoverlay=awesome # This is correct
now have a look in:

Code: Select all

/boot/overlays
I bet your overlays no longer have "-overlay" as part of the name.....have a look at your dtoverlay in here:

Code: Select all

/boot/config.txt
and I'd bet your overlays are thus:

Code: Select all

dtparam=spi=on 
dtoverlay=mcp2515-can0-overlay,oscillator=16000000,interrupt=25 
dtoverlay=spi-bcm2835-overlay
remove the "-overlay" from those two lines, reboot and et voila - can module loaded (check lsmod) and then you can bring can0 up.

annerajb
Posts: 2
Joined: Sat Dec 17, 2016 4:02 am

Re: CAN controller

Sun Dec 18, 2016 7:30 pm

That did it. I swear trying to remove the -overlay since I read it in this thread on another page.

Return to “Interfacing (DSI, CSI, I2C, etc.)”