CAN bus analyzer

Hello!

I am (completely) new to the Arduino stuff, so I need few advices. While I have good knowledge of C/C++ programming and basic knowledge of electronics (I'm IT student), I don't know much about Arduino ... yet.

So - what I would like to create is CAN bus analyzer/sniffer. The whole idea is to connect an Arduino to CAN bus equipped car on the one side, and PC on the other. The goal is to see the CAN messages on the PC ... and maybe even send them from PC to CAN bus. Later, I would add some kind of LCD to display some parameters like engine speed, temperature ... and so on.

So - my questions are:

  1. Which Arduino to buy? You can assume I don't have financial limits, because as I see, all versions are very cheap (aka under 100€). Would Mega 2560 be fine?
  2. Which CAN-bus shield to buy? I only found two of them: http://www.sparkfun.com/products/10039 and http://www.skpang.co.uk/catalog/arduino-canbus-shield-with-usd-card-holder-p-706.html ... is there any alternative, - in any case, which one is the best?
  3. Communication from Arduino to PC via USB. How hard is it to implement this? How fast is it? (Is it fast enough to send CAN packets directly to PC via USB, since CAN 2.0B speed is up to 1.0Mb/s?)
  4. LCD screen. Which one is the easiest to manage? Can it be physically connected in parallel with CAN bus shield, since CAN bus shield is pretty big piece and covers almost whole Arduino?

That's for a start. Thanks in advance for answering my questions!

Given the vast amount of general purpose logic analyzers with CAN decode and CAN-specific analyzers, what is the point of making your own?

Challenge & fun.

So, can anyone answer questions in post #1? Thanks.

  1. A Mega will be fine, and will give you plenty of scope for expansion.
  2. Those two links point to the same shield. Sparkfun stuff is generally ok. I can't speak for that device specifically, as I don't have one.
  3. When you connect the Arduino to the PC via USB, it creates a virtual serial port. You will need something on the PC to see the output from the serial port. This can be as simple, or as complex as you like. The standard speeds supported by the serial port go up to 115200 Baud, but I believe it can be made to go faster.
  4. The easiest LCD option is probably a serial connected one. As the Mega's have four hardware serial ports, adding one will be fine. The shield will only cover half(ish) of a Mega. EDIT: The Sparkfun shield has a socket to connect a serial LCD.

Thanks!

About serial LCD ... is there any library for it, like LiquidCrystal for the ones with HD44780 driver?

I believe there are. There are some links in the Playground.

Thanks.

Just the question about speed remains. CAN bus 2.0b supports speeds up to 1 Mbit/s ... while UART is much slower. How to solve this problem? Caching data on flash/sram/eeprom?

Canbus can communicate at that clock rate, but whether that is an issue depends on how much data is being sent. I don't know the details of that.

An Atmega UART can work up to about 2MHz IIRC, but if there's a lot of data you will not be able to keep up.

If the data is in bursts you should be able to buffer it in RAM then deal with it at the end of a packet. And you have to detect the end of packet as well (I don't know how that's done with CAN) while buffering data so the code will have to be pretty tight.

Atmel do make chips with inbuilt CAN support.


Rob