# CAN bus simulation (automotive purpose) - tried Arduino and SparkFun

I repair electric powered steering systems for cars, especially Fiat, Alfa, and Lancya (Delphi manufacturers), and I'm in need of making some tool to test these reparations. I mean just turning it on, for example.

I have researched during some time, and I figured I need CAN bus signals to be simulated as the eps ECU is receiving ignition packets from CAN. Here I go...

I need to know what way I could read and send CAN packets from/to the bus. I mean, what tool or anything else. I have been trying with Arduino Uno + a SparkFun CAN BUS Shield, but I don't get any results. When everything is connected, my serial console isn't sniffing any packets. I have connected all correctly, I think, and tried different bit rates, changed Arduino boards and shield, tried many different examples. I invested lots of hours with no profit... I was using SEAT Ibiza 2010 for I+D, connected CAN-H and CAN-L on the OBD port, in the CAN lines from the radio, etc...

Any idea of what could be wrong is welcome, as is a new method to make my project...

Information:

Libraries Used

UPDATE 2 (28/12/2014): I used a multimeter because I dont have a oscilloscope. Reading the voltages are always giving me plain 2.5V on CAN-H and CAN-L, I get this readings at Arduino CAN-H CAN-L and in OBD2 Port (Pins 6 and 14)

UPDATE 3 (29/12/2014): I'm planning to switch to some programming language with a CAN interface, any suggestions are welcome, thanks!

UPDATE 3.1 (30/12/2014): Definitely, I'm taking another way to do this, I'm waiting Kvaser and ECOM to reply me in their support emails. That way we may know if their tools fit with my project. I will keep you updated, thanks for all the help guys! :)

• My best guess is that your CAN receiver is receiving the broadcast packets. But since your identifier doesn't match with the destination address, your CAN receiver simply drops the packet. You might be looking for something like this ebay.com/itm/… Dec 26 '14 at 5:49
• @Nick Alexeev but as i think the code used is for sniffing all data roaming in this lines, shouldnt it show something? X_X Anyways, i had ordered the ELM already, but i dont know if i can send custom HEX packets to CAN Bus for my purpose of simulating signals.. Thanks for your attention! :) Dec 26 '14 at 12:57
• What is "I+D"?​ Dec 26 '14 at 19:23
• With an oscilloscope you can determine the bitrate and if the CAN bus signals are actually present at the CAN bus shield. Dec 27 '14 at 0:34
• Can you post the code you are using? Dec 27 '14 at 0:41

The Arduino CAN shield is pretty cool if you want to build an embedded computer to play with CAN. However, if I understand correctly, you are building a one-off tool for your personal use (or will merely use an off-the-shelf tool if one exists for the right price). For that reason, I urge you to consider writing PC software rather than embedded software to interface with existing, low-cost CAN hardware interfaces.

Charlie Miller and Chris Valasek used this so called ECOM tool and wrote software which interfaces with it. The ECOM tool appears to have an API and example driver. Their car hacking white paper and software will give a pretty good starting point for interfacing a PC to a car. Softing also makes PC CAN interface hardware, but I am having trouble accessing their website right now, so I won't link it.

There are also several full-fledged, commercial software tools for analyzing and simulating CAN on a PC as well. Vector's CANoe is a well known (and expensive) tool for that purpose.

• Hello @downbeat, first of all sorry for not answering, I didnt see your answer. What specific interface (if it's cheap, better :P, if not, I need it anyways ) can I use for interface with the car with my IDE? What language to use? I know java, a bit of C++, any info or examples for it would be very appreciate. Dec 29 '14 at 21:34
• I do not have the reputation to comment on the EE stack exchange. Most likely there is some sort of driver supplied with any sort of low-cost tool. The ECOM tool I mentioned is $180. That ELM327 is$7-$21. Either one will require some amount of programming. It looks like that ELM device uses an AT command set over RS232. I would interface with that using Python, but it should be pretty well dead simple once you get the hang of the device. Jul 25 '15 at 13:49 • I recently found the USB2CAN (8devices.com/usb2can) tool, which is even cheaper, selling at$65 as of this writing [shop.8devices.com/index.php?route=product/…. I have used it on Linux, but not Windows. I don't know how rich the included software is, but you can certainly write your own scripts to interface with the driver directly. On Linux, there are some pre-existing CAN tools such as cansend, candump, cangen and canplayer. Jul 25 '15 at 13:51

If you're open to buying something off the shelf for a few hundred dollars, Kvaser's Leaf products are pretty easy to use. They let you send pre-recorded sequences of packets and monitor the bus. You can get one with an OBD-2 connector if that's what you need.

Building your own test equipment is fine for a personal project, but if you're making money off of these repairs, it's probably better to start with something you know is reliable.

• thanks for the tips Adam! could you leave me a link? I would prefer making my own as it shouldnt be very hard, so later I can improve my tool for my new needs, regards! Dec 28 '14 at 3:32
• Here's a link to the low-end model: kvaser.com/products/kvaser-leaf-light-v2 Dec 28 '14 at 4:10

Having managed to eventually get numbers from a CAN bus with an embedded controller, I believe the biggest problem you're experiencing are the vendors' examples not properly initializing the controller's registers for CAN quanta and sample timing.

Curbing the popular CAN shields' efforts is the 16 MHz crystal SparkFun and Seeeed use. Then the low-speed Arduino isn't well suited for moving serial data. None of the sample code on the Internet works because they are all canned examples for 1 Mbit/s...

Some microcontrollers have CAN controllers built-in (sadly, almost none have transceivers). I used a ChipKIT Max32 and a MCP2551 IC via breadboard in the circuit below. Additionally, I tapped into the transceivers on the SparkFun and Seeed's CAN shields to get Tx/Rx data. The ChipKIT's Max32 has two CAN controllers and an 80 MHz CPU clock, so it is well suited for CAN experimentation. Using an online calculator, I was able to set up the PIC32's controller on the first try.

I suspended my development on CAN work for other projects, but an affiliate has coaxed an Arduino Uno with CAN shields into reading from a 500 kbit/s bus. I looked at the code he recently shared with me, but I couldn't find how the MCP2515 controller's timing was set or how it differed from the example code.

The next development board I'm trying is Ti's Connected LaunchPad TM4C123GXL. It has CAN controllers, USB OTG, lots of I/O and is US\$13.