Arduino CAN BUS monitoring tool

General discussion about interfacing with the CAN bus
Post Reply
latonita
What's hacking?
Posts: 15
Joined: 2015 Apr 15 06:58

Arduino CAN BUS monitoring tool

Post by latonita » 2015 May 18 14:36

Guys,

Just want to share my tool to sniff CAN bus using Arduino + CAN BUS Shield. Link on github: https://github.com/latonita/arduino-canbus-monitor. This is an implementation of CAN232 serial protocol. Use it with software that understands it.

First, I started to use CAN_BUS_Shield library to read data and that was okay. Then I realized I need a software to visualize the data - and I used excel. But then I understood I need to interact with the bus and I decided to do it in some standard way - and just made an implementation of serial can bus protocol initially proposed by Lawicel and their CAN232/CANUSB. There a many tools which can work with this protocol. In my studies I use free tool called CANHacker v.2.00.01 (I found working downloadable link on this page: http://www.canhack.net/viewtopic.php?f= ... ddeaec14b1)

Step 1. Get my arduino-canbus-monitor. Build and upload to arduino. (I tested this on Arduino Uno)
Step 2. Download CANHacker or another analyzer tool which support serial can232 protocol. Choose a proper COM port.
Step 3. Have fun! Monitor your can bus, save traces, send messages, do what your analyzer/visualizer software can.

This arduino-canbus-protocol tool is free - everybody is welcome to fork and enhance it. If you like the tool or have a question/proposal - just drop me a line here or on github.

TheMatrix
How the heck did I end up here?
Posts: 10
Joined: 2006 Feb 15 22:13

Re: Arduino CAN BUS monitoring tool

Post by TheMatrix » 2015 Dec 20 09:05

Seem very useful, Thanks for implementing this communication protocol. I will try it in my car.
I am also using Excel since years to sort my CAN frames. I was looking for a better inexpensive tool. Thanks for your work, and many thanks for Sharing.
Scrolling !!!!

User avatar
linuxkidd
Site Admin
Posts: 343
Joined: 2005 Jul 22 15:48
Location: Anywhere, USA
Contact:

Re: Arduino CAN BUS monitoring tool

Post by linuxkidd » 2015 Dec 21 00:57

latonita wrote:Guys,

Just want to share my tool to sniff CAN bus using Arduino + CAN BUS Shield. Link on github: https://github.com/latonita/arduino-canbus-monitor. This is an implementation of CAN232 serial protocol. Use it with software that understands it.

First, I started to use CAN_BUS_Shield library to read data and that was okay. Then I realized I need a software to visualize the data - and I used excel. But then I understood I need to interact with the bus and I decided to do it in some standard way - and just made an implementation of serial can bus protocol initially proposed by Lawicel and their CAN232/CANUSB. There a many tools which can work with this protocol. In my studies I use free tool called CANHacker v.2.00.01 (I found working downloadable link on this page: http://www.canhack.net/viewtopic.php?f= ... ddeaec14b1)

Step 1. Get my arduino-canbus-monitor. Build and upload to arduino. (I tested this on Arduino Uno)
Step 2. Download CANHacker or another analyzer tool which support serial can232 protocol. Choose a proper COM port.
Step 3. Have fun! Monitor your can bus, save traces, send messages, do what your analyzer/visualizer software can.

This arduino-canbus-protocol tool is free - everybody is welcome to fork and enhance it. If you like the tool or have a question/proposal - just drop me a line here or on github.
Hey Iatonita,
I'm using the Seeedstudio CAN-shield for my sniffing and prototyping.. I have however just picked up 3 of low cost SPI bus CAN adapters from amazon (link)


Wondering if you could help me determine the proper CNF register values to get 250kbps on an 8mhz clocked MCP2515 with the same timings as these provide for 16mhz:
#define MCP_16MHz_250kBPS_CFG1 (0x41)
#define MCP_16MHz_250kBPS_CFG2 (0xF1)
#define MCP_16MHz_250kBPS_CFG3 (0x85)

I've tried the bit timing calculator here (https://www.kvaser.com/support/calculat ... alculator/), but while I can sniff traffic using the first few settings, it causes comms issues with other nodes on the bus whereas the ones listed above for the 16mhz clocked chip do not.

Thanks to anyone who can help!
LK
If you can read this, the light is still red.

User avatar
linuxkidd
Site Admin
Posts: 343
Joined: 2005 Jul 22 15:48
Location: Anywhere, USA
Contact:

Re: Arduino CAN BUS monitoring tool

Post by linuxkidd » 2015 Dec 21 12:29

I seem to have determined the answer... Found in the MCP2515 datasheet, the full details of each config bit set by the CNF1|2|3 values.

At this time, the following seems to operate quite well:
#define MCP_8MHz_250kBPS_CFG1 (0x40)
#define MCP_8MHz_250kBPS_CFG2 (0xF1)
#define MCP_8MHz_250kBPS_CFG3 (0x85)

All of the params configured use multiples of a value called Tq, which is calculated from the 6 LSBs of the CNF1 ( aka Baud Rate Prescaler or BRP ). Tq is calculated as: 2 x (BRP + 1)/Fosc
Where Fosc = Frequency of the Oscillator.

The good values for 16Mhz have the BRP set to 1, thus:
2 x ( 1 + 1 ) / 16Mhz = Tq of 0.00000025

Since the clock on the linked CAN SPI adapter is 1/2 that of the CAN-Shield, I reduced the BRP to 0:
2 x ( 0 + 1 ) / 8Mhz = Tq of 0.00000025

YEAH! Stable operations on my bus.. :D

fwiw, I'm using this to hack the RV-C (Recreational Vehicle CAN bus) on my 2016 Allegro Bus 45OP Motorhome.. :) The good news is that RV-C spec is open and quite well documented. Which is a damn good thing, since they use extended CanID, and overload it with the command, priority, data byte count and source address. Would have been difficult to figure that out.

LK
If you can read this, the light is still red.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest