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

Re: [quick-guide] CAN bus on raspberry pi with MCP2515

Sun Oct 30, 2016 8:37 am

pitchlynn wrote:Yes, it works! I'm reading and sending can messages on my grand cherokee. Able to unlock and lock the doors which is the first order of business. Some sketchy software in the jeep makes the passive entry flaky so I'm going use this as a work around. Thanks again for the op post and everyone's help!

Does anyone know how I would incorporate these can utility messages into a script to run all the time on the RPi. I'm sure this is basic RPi stuff but I'm not sure where to look for information. I'm hoping it is python since I use it a little in my day job.
if u do

Code: Select all

uname -a
can u post that?:)

pitchlynn
Posts: 16
Joined: Sun Oct 23, 2016 9:11 pm

Re: [quick-guide] CAN bus on raspberry pi with MCP2515

Sun Oct 30, 2016 11:20 pm

Linux raspberrypi 4.4.26+ #915 Thu Oct 20 17:02:14 BST 2016 armv61 GNU/Linux

I've tried so many things now I don't even know what OS I thought I had loaded and even if it was full or lite. Does the uname -a results above show if it is the full or lite version? Is 4.4.26 the latest?
berne wrote:
pitchlynn wrote:Yes, it works! I'm reading and sending can messages on my grand cherokee. Able to unlock and lock the doors which is the first order of business. Some sketchy software in the jeep makes the passive entry flaky so I'm going use this as a work around. Thanks again for the op post and everyone's help!

Does anyone know how I would incorporate these can utility messages into a script to run all the time on the RPi. I'm sure this is basic RPi stuff but I'm not sure where to look for information. I'm hoping it is python since I use it a little in my day job.
if u do

Code: Select all

uname -a
can u post that?:)

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

Re: [quick-guide] CAN bus on raspberry pi with MCP2515

Mon Oct 31, 2016 4:08 pm

pitchlynn wrote:Linux raspberrypi 4.4.26+ #915 Thu Oct 20 17:02:14 BST 2016 armv61 GNU/Linux

I've tried so many things now I don't even know what OS I thought I had loaded and even if it was full or lite. Does the uname -a results above show if it is the full or lite version? Is 4.4.26 the latest?
berne wrote:
pitchlynn wrote:Yes, it works! I'm reading and sending can messages on my grand cherokee. Able to unlock and lock the doors which is the first order of business. Some sketchy software in the jeep makes the passive entry flaky so I'm going use this as a work around. Thanks again for the op post and everyone's help!

Does anyone know how I would incorporate these can utility messages into a script to run all the time on the RPi. I'm sure this is basic RPi stuff but I'm not sure where to look for information. I'm hoping it is python since I use it a little in my day job.
if u do

Code: Select all

uname -a
can u post that?:)



yes that is the latest... what can are u using?
... i have tryde somany times, did ju just do this guide?
what pi do u use?


krunch
Posts: 7
Joined: Sat Mar 28, 2015 2:50 pm

Re: [quick-guide] CAN bus on raspberry pi with MCP2515

Mon Oct 31, 2016 5:12 pm

berne wrote:im using
http://www.mikroe.com/click/can-spi-5v/
http://www.mikroe.com/click/pi2-shield/

but cant get it to work... dont know why:S
You need the 3.3 Volt Version. The RaPi uses CMOS definition and does not fly with TTL. But you get a 3.3V CAN click shield from MikroE

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

Re: [quick-guide] CAN bus on raspberry pi with MCP2515

Mon Oct 31, 2016 5:46 pm

krunch wrote:
berne wrote:im using
http://www.mikroe.com/click/can-spi-5v/
http://www.mikroe.com/click/pi2-shield/

but cant get it to work... dont know why:S
You need the 3.3 Volt Version. The RaPi uses CMOS definition and does not fly with TTL. But you get a 3.3V CAN click shield from MikroE
pin 2 and 4 is 5v.. or im thinking worng? or cant it do som wiring to get it to work?

i was reding that can works betwen 3.3v and 5v thinking so i dont "loss can "code" on the way "

pitchlynn
Posts: 16
Joined: Sun Oct 23, 2016 9:11 pm

Re: [quick-guide] CAN bus on raspberry pi with MCP2515

Mon Oct 31, 2016 6:52 pm

berne wrote: ... i have tryde somany times, did ju just do this guide?
what pi do u use?
[/quote]

Yes, I followed the guide exactly even used the same can adapter. Found it on ebay 3 for $12 with shipping. I made the same mode to the board to separate power to the 2 different ICs. I did not put the capacitors on because I didn't have the right values in my stash and I figure the power is coming from the Pi which according to the schematics looks like it might have plenty of power supply filtering on board.

I'm using the pi zero.

pitchlynn
Posts: 16
Joined: Sun Oct 23, 2016 9:11 pm

Re: [quick-guide] CAN bus on raspberry pi with MCP2515

Mon Oct 31, 2016 6:55 pm

krunch wrote:
berne wrote:im using
http://www.mikroe.com/click/can-spi-5v/
http://www.mikroe.com/click/pi2-shield/

but cant get it to work... dont know why:S
You need the 3.3 Volt Version. The RaPi uses CMOS definition and does not fly with TTL. But you get a 3.3V CAN click shield from MikroE
If berne subjected the Pi to 5V from the can adapter could the Pi also be damaged and still not work when used with the correct adapter? Just one more thing to check that might keep it from working once the correct can adapter is used.

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

Re: [quick-guide] CAN bus on raspberry pi with MCP2515

Tue Nov 01, 2016 6:54 pm

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


EDIT:

Code: Select all

pi@piv2:~ $ ls /sys/bus/spi/devices/spi0.0
driver  modalias  net  of_node  subsystem  uevent
pi@piv2:~ $ ls /sys/bus/spi/devices/spi0.0/net
can0
pi@piv2:~ $ ls /sys/bus/spi/devices/spi0.0
driver  modalias  net  of_node  subsystem  uevent
pi@piv2:~ $ ls /sys/bus/spi/devices/spi0.0/net/
can0
pi@piv2:~ $ 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

pi@piv2:~ $ sudo ip link set can0 up type can bitrate 125000
iget: RTNETLINK answers: Device or resource busy
idees?

pitchlynn
Posts: 16
Joined: Sun Oct 23, 2016 9:11 pm

Re: [quick-guide] CAN bus on raspberry pi with MCP2515

Wed Nov 02, 2016 7:23 pm

berne wrote:

but the next step:

Code: Select all

pi@piv2:~ $ sudo ip link set can0 up type can bitrate 125000
iget: RTNETLINK answers: Device or resource busy
idees?
I have seen this error message now and I think you might be ok. If you try to set up can0 after you have already done it you will get that error. Connect to a can buss and see if it works

Also, try this to shut can0 down:

Code: Select all

"sudo /sbin/ip link set can0 down"
Then set can0 up again and see if you still get the "busy" error:

Code: Select all

sudo ip link set can0 up type can bitrate 125000
If you still have problems check ifconfig to see if you have any other can related items

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

Re: [quick-guide] CAN bus on raspberry pi with MCP2515

Wed Nov 02, 2016 8:50 pm

pitchlynn wrote:
berne wrote:

but the next step:

Code: Select all

pi@piv2:~ $ sudo ip link set can0 up type can bitrate 125000
iget: RTNETLINK answers: Device or resource busy
idees?
I have seen this error message now and I think you might be ok. If you try to set up can0 after you have already done it you will get that error. Connect to a can buss and see if it works

Also, try this to shut can0 down:

Code: Select all

"sudo /sbin/ip link set can0 down"
Then set can0 up again and see if you still get the "busy" error:

Code: Select all

sudo ip link set can0 up type can bitrate 125000
If you still have problems check ifconfig to see if you have any other can related items


after doing
sudo /sbin/ip link set can0 down
nothing is rely happing, no error .. just a new line

sudo ip link set can0 up type can bitrate 125000
same :RTNETLINK answers: Device or resource busy

note iam pretty new at this, can be good to know:)

are u think of the network info, or something eles? ifconfig

eth0 Link encap:Ethernet HWaddr b8:27:eb:23:99:30
inet6 addr: fe80::ac8e:682c:f2d9:5b0/64 Scope:Link
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:212 errors:0 dropped:0 overruns:0 frame:0
TX packets:212 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:17931 (17.5 KiB) TX bytes:17931 (17.5 KiB)

wlan0 Link encap:Ethernet HWaddr b8:27:eb:76:cc:65
inet addr:192.168.1.137 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::4ece:38ed:4ae2:a919/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:862 errors:0 dropped:23 overruns:0 frame:0
TX packets:554 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:303707 (296.5 KiB) TX bytes:69724 (68.0 KiB)


EDIT: when i do cansend can0 456#43414e2054657374 i am geting:
write: Network is down

isent that strange, but when using:
ls /sys/bus/spi/devices/spi0.0/net i get
can0

is connected, and working but in the same time, is not exsist... mmmm

pitchlynn
Posts: 16
Joined: Sun Oct 23, 2016 9:11 pm

Re: [quick-guide] CAN bus on raspberry pi with MCP2515

Thu Nov 03, 2016 3:16 pm

I'm new at this too so my knowledge is limited. I just know that if can0 is already up you will get that busy error if you try to do it a second time. That is why I suggested taking it down to see if you still got the busy error message when you bring it up. So it looks like you have a different problem that I'm not familiar with. When you bring can0 up successfully, it will show up when you do the ifconfig command. Maybe someone else will notice something in your ifconfig results that could explain your problem.

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

Re: [quick-guide] CAN bus on raspberry pi with MCP2515

Tue Nov 15, 2016 5:50 pm

any one have any ides? im stuck... cant get it to work:/

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

Re: [quick-guide] CAN bus on raspberry pi with MCP2515

Tue Nov 15, 2016 8:27 pm

I'm coming in at the end of this, and I haven't read the whole thread,

But.... do you have another CAN device on the bus that will receive the packets ? Without something to acknowledge your transmitted packets they will cause an error.

PeterO


FYI: I'm using a PICAN2 card (MCP2515 + MCP2551) to communicate with a PIC18F4585.
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: [quick-guide] CAN bus on raspberry pi with MCP2515

Sun Nov 27, 2016 5:33 pm

Hello,

can somebody please explain when exactly you need to connect the GND along with CAN_H and CAN_L?
I have build my own adapter PCB for CAN, similar to the 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. Is it maybe because I did not connect the GNDs? On the other hand, I read that somebody managed to send/receive without GND connection. Maybe, he was not aware that GND is the same (through USB ports maybe)?

Thank you.

Drift3r
Posts: 2
Joined: Sat Dec 03, 2016 5:18 pm

Re: [quick-guide] CAN bus on raspberry pi with MCP2515

Sat Dec 03, 2016 5:44 pm

Hi All!
I've just tested the device train. I can successfully listen to two of my car's three CAN buses.
But when I try to send, nothing happens. Moreover, after trying to send listening do not work till I restart can0 interface.
What could it be?
Here is the video:
https://www.youtube.com/watch?v=fRoa8Z57pCs
Connection is to the 3.3V RPi pin.

pitchlynn
Posts: 16
Joined: Sun Oct 23, 2016 9:11 pm

Re: [quick-guide] CAN bus on raspberry pi with MCP2515

Sat Dec 10, 2016 6:42 am

I've followed the op guide except with a pi zero and have been running in my vehicle for a couple of months now. Today I noticed the 3.3v regulator on my pi zero has died :( I suspect the can controller board was too much load since it was powered off 3.3v regulator on the pi.

Looking up what specs I could find the max current for the pi zero 3.3 external power ours 50ma and the can controller can use up to 75ma.

Not sure how I want to resolve it. I liked how simple and cheap the setup was. I could add bigger regulator for the can controller.

Or maybe just try another $5 pi Zero and hope I'm wrong and just had bad luck. It sure ran a good while!

pitchlynn
Posts: 16
Joined: Sun Oct 23, 2016 9:11 pm

Re: [quick-guide] CAN bus on raspberry pi with MCP2515

Sun Dec 11, 2016 12:04 am

pitchlynn wrote:I've followed the op guide except with a pi zero and have been running in my vehicle for a couple of months now. Today I noticed the 3.3v regulator on my pi zero has died :( I suspect the can controller board was too much load since it was powered off 3.3v regulator on the pi.

Looking up what specs I could find the max current for the pi zero 3.3 external power ours 50ma and the can controller can use up to 75ma.

Not sure how I want to resolve it. I liked how simple and cheap the setup was. I could add bigger regulator for the can controller.

Or maybe just try another $5 pi Zero and hope I'm wrong and just had bad luck. It sure ran a good while!
I did some investigation, removed L1, and found that the regulator failed such that it is putting out 5v which has fried something, most likely the processor. Applying 3.3v externally resulted in a dead short.

The only information I can find for the 3.3v max current is 50 ma but that was for an earlier pi and this one uses a different switching regulator. The can controller is only using the 3.3v for the MCP2515 which takes a max of 10 ma. So, I think this setup would not have caused the failure. I also remembered at one point, when I was powering the pi from a 12v usb adapter, I had connected reverse polarity to the 12v usb adapter. The adapter was destroyed and fuse blown in the vehicle but the pi still worked. I'm hoping this caused damaged that lead to this failure. I'm going to try again with a new pi zero I just ordered. Wish me luck!

Drift3r
Posts: 2
Joined: Sat Dec 03, 2016 5:18 pm

Re: [quick-guide] CAN bus on raspberry pi with MCP2515

Sat Dec 17, 2016 5:48 pm

Drift3r wrote: What could it be?
...
Connection is to the 3.3V RPi pin.
So, the answer was in the same post. After the upgrade and supplying +5 volts the chip is able to send.

edismurtzis
Posts: 1
Joined: Mon Jan 02, 2017 9:34 am

Re: [quick-guide] CAN bus on raspberry pi with MCP2515

Mon Jan 02, 2017 11:10 am

Nice post.
We are using two rpi with one mcp2515 module each. We already follow all the tutorial and we didn´t get any error message.
We receive the same answers like you when we enter ifconfig. But when we try to send some data, is never arriving to the other rpi.
The network interface is up with:sudo ip link set can0 up type can bitrate 125000
And the sending (cansend can0 456#43414e2054657374) and receiving (candump can0) commands give us no error.
What can be wrong? Do we need to try with a different can id? Is it possible/necesary to change the id somewhere?
Attached some pictures.
Thank you for your help.
Attachments
rpi.jpeg
Rpi connection
rpi.jpeg (33.81 KiB) Viewed 3432 times
can_module.jpeg
Can modules MCP2515
can_module.jpeg (14.47 KiB) Viewed 3432 times
full.jpg
All the system
full.jpg (54.17 KiB) Viewed 3432 times

User avatar
saper_2
Posts: 230
Joined: Sun Aug 03, 2014 10:08 am
Location: PL

Re: [quick-guide] CAN bus on raspberry pi with MCP2515

Fri Jan 06, 2017 4:32 pm

Hi all,

Sorry for late comment, I don't check forum everyday :)
I've read last 2 pages of this topic, and I'll give answers/suggestions in point without relating to specific post :) (it's pain in neck to do so) ;)

1. You have to connect GND with CAN_L&H, CAN bus is differential bus, but driver (TJA1050/MCP2551/etc.) for proper recognition of voltage levels on L & H bus wires need a reference point (which is GND = ground).

2. If you ever connected to Pi IOs a 5V from some board (chip), like from MCP2515 powered from 5V you got this pin burned, this pin is doomed for life (nothing never work on that pin again). You can try use ALT IO pin...

3. If you power both MCP2515 and CAN transceiver (MCP2551/TJA1050/etc) from 3,3V , you might be able to read because MCP2551(or other) will be able to properly detect signals transition on CAN bus wires, but you won't be able to send anything because other devices (which implement a standardized CAN bus interface) will consider CAN bus voltage levels at point +3,3V as noise (this is MAX voltage level from you MCP2551 - which is powered from 3,3V).

4. Pi0 is a tiny version of fully fledged Pi 1. SO the VReg 3,3V is smaller too :) . Sorry for you loss of Pi0 pitchlynn, but now we know that on Pi0 CAN-board need external power regulator (e.g. one of those for 2USD/5pcs from aliexpress :) )

5. If I'll feel like, I might test my "quick-guide" on latest raspbian & Pi3 :)

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

Re: [quick-guide] CAN bus on raspberry pi with MCP2515

Fri Jan 13, 2017 9:37 pm

saper_2 wrote:Hi all,



5. If I'll feel like, I might test my "quick-guide" on latest raspbian & Pi3 :)

yes pleas:)

User avatar
rpdom
Posts: 12398
Joined: Sun May 06, 2012 5:17 am
Location: Essex, UK

Re: [quick-guide] CAN bus on raspberry pi with MCP2515

Fri Jan 13, 2017 10:42 pm

saper_2 wrote:4. Pi0 is a tiny version of fully fledged Pi 1. SO the VReg 3,3V is smaller too
Are you sure? It looks like exactly the same chip to me.

leocat3
Posts: 7
Joined: Sat Jan 14, 2017 11:02 am

Re: [quick-guide] CAN bus on raspberry pi with MCP2515

Sat Jan 14, 2017 11:10 am

You can use my device: UART <-> CAN adapter "CAN Gate". Download: open-plc.com/download.html
It's device have simple text protocol for communicate to CAN BUS, like Linux cansend, candump.
Project is opensource.

User avatar
saper_2
Posts: 230
Joined: Sun Aug 03, 2014 10:08 am
Location: PL

Re: [quick-guide] CAN bus on raspberry pi with MCP2515

Mon Jan 16, 2017 9:08 pm

rpdom wrote:Are you sure? It looks like exactly the same chip to me.
I took a quick look at Pi3 (I don't have PiA/B+ only PiB with 26pin IO header). PiB (not "+") have 3,3V linear regulator (which I believe should be capable of providing up to 0,5A).

But back to the chip, I looked at Pi3 and Pi0. Both have that same chip but the coils are very much smaller in Pi0 than in Pi3 (don't just look at dimensions, the construction and material of ferromagnetic core of power choke is very important too).

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

Who is online

Users browsing this forum: No registered users and 5 guests