CAN-BUS Shield

This shield gives the Arduino CAN-Bus capability. It uses the Microchip MCP2515 CAN controller with MCP2551 CAN transceiver. CAN connection is via a standard 9-way sub-D for use with OBD-II cable. Ideal for automative CAN application. The shield also has a uSD card holder, serial LCD connector and connector for an EM406 GPS module. Making this shield ideal for data logging application.

  • Cable not included
  • View the related products for a recommended cable to use with this board

Note: This product is a collaboration with SK Pang Electronics. A portion of each sales goes back to them for product support and continued development.

Features

  • CAN v2.0B upto 1 Mb/s
  • High speed SPI Interface (10 MHz)
  • Standard and extened data and remote frames
  • CAN connection via standard 9-way sub-D connector
  • Power can supply to Arduino by sub-D via resettable fuse and reverse polarity protection.
  • Socket for EM406 GPS module
  • Micro SD card holder
  • Connector for serial LCD
  • Reset button
  • Joystick control menu navigation control
  • Two LED indicator

CAN-BUS Shield Product Help and Resources

CAN-BUS Shield Hookup Guide

October 8, 2015

A basic introduction to working with the CAN-Bus shield.

Getting Started with OBD-II

October 8, 2015

A general guide to the OBD-II protocols used for communication in automotive and industrial applications.

Core Skill: Soldering

This skill defines how difficult the soldering is on a particular product. It might be a couple simple solder joints, or require special reflow tools.

1 Soldering

Skill Level: Noob - Some basic soldering is required, but it is limited to a just a few pins, basic through-hole soldering, and couple (if any) polarized components. A basic soldering iron is all you should need.
See all skill levels


Core Skill: Programming

If a board needs code or communicates somehow, you're going to need to know how to program or interface with it. The programming skill is all about communication and code.

3 Programming

Skill Level: Competent - The toolchain for programming is a bit more complex and will examples may not be explicitly provided for you. You will be required to have a fundamental knowledge of programming and be required to provide your own code. You may need to modify existing libraries or code to work with your specific hardware. Sensor and hardware interfaces will be SPI or I2C.
See all skill levels


Core Skill: Electrical Prototyping

If it requires power, you need to know how much, what all the pins do, and how to hook it up. You may need to reference datasheets, schematics, and know the ins and outs of electronics.

2 Electrical Prototyping

Skill Level: Rookie - You may be required to know a bit more about the component, such as orientation, or how to hook it up, in addition to power requirements. You will need to understand polarized components.
See all skill levels


Comments

Looking for answers to technical questions?

We welcome your comments and suggestions below. However, if you are looking for solutions to technical questions please see our Technical Assistance page.

  • Member #250537 / about 11 years ago / 4

    If you are using this board to actually create a CAN bus system (as I am for a robotic drone vehicle) then the skpang (designer of this board) code is not that helpful and a bit of a mess. It is well and good to be able to read things from your vehicle and log them, but that's not helpful when you are trying to create an actual bus.

    Also, I really find it difficult when sample code does every conceivable thing all at once, forcing you to piece out the parts/understanding you need.

    To create a network of senders and receivers, I tried a few different libraries. I recommend using the CANDUINO one http://code.google.com/p/canduino/downloads/list). Although the boards are not exactly the same, it will work, and you can see a sender and receiver working. Other libraries I tried, such as the one from saeed studios, didn't work for me, even though their boards are pin compatible. Might have something to do with their library using a CAN interrupt which, for me, was not reliable. Receiver would get only a single CAN message and then the interrupt would never fire again. Who knows why. Spent a number of hours on this.

    So just want to save other folks some time if they are looking to build an actual bus system, and not just read data from their vehicles.

    (Really wish a library link was included with this product. Could have saved me a lot of time.)

    • Member #392139 / about 11 years ago / 1

      Hi there, I downloaded the CANDUINO library, but got confused. Actually there were three .pde in it, which one do you use? I loaded the canduino_DEMO.pde but it seems not working good. I only used one CAN and one Arduino, and in Serial Monitor i can see "Recieve ID ONE: 5F Recieve data ONE: 66", but not the one I sent:"64 34". Can you help me? Or should I use two of them to archieve "a sender and receiver working" like you said? Thank you!

  • calvinium / about 13 years ago / 4

    Is it really that hard to find and follow a standard? I understand that there probably isn't any official DB9 CAN pin-out definition, but the de-facto standard seems to be:
    Pin 2 = CAN_L
    Pin 3 = CAN_GND
    Pin 7 = CAN_H
    Pin 9 = CAN_V+(Optional)
    This is as defined on 3 of the top 4 hits when googling "DB9 CAN bus pinout" (2 of the hits were the same site)
    In fact, SKP themselves acknowledge the existence of this pinout in their CAN breakout board:
    http://www.skpang.co.uk/catalog/canbus-breakout-board-p-754.html
    Why reinvent the wheel guys? WHY?

    • Member #545191 / about 10 years ago * / 3

      The DB9 pins on this CAN shield must follow some common standard because they match the OBDII to DB9 cable I bought on Amazon.

      Here are the pin assignments as seen when looking at the tips of the pins in the female DB9 connector on the CAN shield:

      \ 1 2 3 4 5 /
       \ 6 7 8 9 /
        `-------’
      2  Ground
      3  CAN High
      5  CAN Low
      9  V+
      

    • bdwyer / about 13 years ago / 2

      ^^^Holy folding chairs Batman! He's Right! ^^^
      I'm glad you pointed this out

  • c.fowler / about 11 years ago / 3

    For what its worth, I found the library here https://github.com/reeedstudio/CAN_BUS_Shield works the best out-of-the-box with a minor bug with receiving extended IDs. I fixed those along with some baudrate constants and the interrupt handing in the receive example which is located here: https://github.com/coryjfowler/MCP2515_Library

    I would really like to see an updated version of the MCP2515 shield that has the CAN pinout. Continuing on with this false DE9 pinout is a bad idea. Additionally, removing the extras would be nice. I work in R&D where our product uses CAN (J1939) and this is the most bizzare CAN pinout I've seen on a DE9 and the reason for it, to support a pre-manufacture cable, is pretty silly. I could see doing such a thing for the first few revisions but it should be revised. I've not purchased ANY of the shields having this pinout to avoid having a non-standard DE9. I built my own shield mostly because I wanted galvanic isolation of the transceiver, but also because of the odd pin-out of assembled boards.

    Supporting the "standard" pinout and selling an OBDII cable with a more appropriate pinout would be so much more preferred. I would also like to see the board minus the extra, application specific additions. (eg. Joystick & SD card slot)

    • Member #198124 / about 10 years ago * / 3

      Thank you so much for providing this library. I was struggling trying to get this shield to work while logging J1939 DTCs, as the listed library doesn't support the extended ID format necessary for J1939. You saved me a lot of work, sir!

      For the record, I completely agree with you on the standard DB9 pinout. Every type of professional DB9 CAN device I have access to (Kvaser , CANcaseXL) has the 2 & 7 pinout. Just because Sparkfun sells a cable with this odd pinout doesn't suddenly make it an accepted standard.

    • tomsvilans / about 10 years ago / 1

      Hi Cory, I've been having some trouble with setting up the CAN-BUS properly using your library. Maybe it's an issue with my wiring or the other hardware I've got connected, but I can't seem to be able to send any messages through. Would be possible to PM / email you if you have a minute so that I can explain my setup in detail?

    • asd12345 / about 10 years ago / 1

      First of all, thanks man. I really appreciate your library. Second, do you have any examples for message filtering for your library. I want to be able to send 6 messages (6 different ids) extended frame 1Mbs form one arduino and receive those messages with six different arduinos. Every receiving arduino should only get one message.

    • Member #483997 / about 11 years ago * / 1

      Is there any way to change this library for the Arduino Mega?

      Other libraries have this in the "defaults.h" but I can not find it in this library like shown below.

      SPI bus pins 10-13 of the shield to 50-53 of the Mega 2560 as follows:

      Mega CAN bus shield 51 11 (SPI MOSI) 50 12 (SPI MISO) 52 13 (SPI SCK) 53 10 (SPI CS) But, the final trick to get the SKPang software to work properly was to modify the port assignments in file “defaults.h” as follows:

      // Atmega 168/328 pin mapping
      //#define   P_MOSI      B,3 // pin 11
      //#define   P_MISO      B,4 // pin 12
      //#define   P_SCK       B,5 // pin 13
      //#define   MCP2515_CS  B,2 // pin 10
      //#define   MCP2515_INT D,2 // pin 2
      //#define   LED2_HIGH   B,0 // pin 8
      //#define   LED2_LOW    B,0 // pin 8
      
      // Pins remapped to Arduino Mega 2560
      #define P_MOSI          B,2 // pin 51
      #define P_MISO          B,3 // pin 50
      #define P_SCK           B,1 // pin 52
      #define MCP2515_CS      B,0 // pin 53
      #define MCP2515_INT     E,4 // pin 2
      #define LED2_HIGH       H,5 // pin 8
      #define LED2_LOW        H,5 // pin 8
      

      Any help would be appreciated.

      • c.fowler / about 10 years ago / 1

        The SPI library calls on 'pins_arduino.h.' This file exists for every board, this is where the MCP2515_lib library defines those pins. However, you will need to change the '#define SPICS' line from 10 to 53 in the 'mcp_can_dfs.h' file of the MCP2515_lib library to support the chip_select.

  • SimBob_ / about 11 years ago * / 3

    After banging my head against the wall trying to get this board to work with the Arduino Mega 2560, I finally figured it out. As was mentioned previously, you have to wire the SPI bus pins 10-13 of the shield to 50-53 of the Mega 2560 as follows:

    • Mega CAN bus shield
    • 51 11 (SPI MOSI)
    • 50 12 (SPI MISO)
    • 52 13 (SPI SCK)
    • 53 10 (SPI CS)

    But, the final trick to get the SKPang software to work properly was to modify the port assignments in file "defaults.h" as follows:

    // Atmega 168/328 pin mapping
    //#define   P_MOSI      B,3 // pin 11
    //#define   P_MISO      B,4 // pin 12
    //#define   P_SCK       B,5 // pin 13
    //#define   MCP2515_CS  B,2 // pin 10
    //#define   MCP2515_INT D,2 // pin 2
    //#define   LED2_HIGH   B,0 // pin 8
    //#define   LED2_LOW    B,0 // pin 8
    
    // Pins remapped to Arduino Mega 2560
    #define P_MOSI          B,2 // pin 51
    #define P_MISO          B,3 // pin 50
    #define P_SCK           B,1 // pin 52
    #define MCP2515_CS      B,0 // pin 53
    #define MCP2515_INT     E,4 // pin 2
    #define LED2_HIGH       H,5 // pin 8
    #define LED2_LOW        H,5 // pin 8
    

    I did some reading here: http://www.arduino.cc/en/Reference/PortManipulation It discusses the advantage of better speed of controlling I/O pins by writing directly to the ports, but the disadvantage is that it is not a portable design to other processor pin maps. Yup.

    The 2 pin maps I found here, and corrected the mappings: http://arduino.cc/en/Hacking/PinMapping168 (this is what the shield was designed to run with) http://arduino.cc/en/Hacking/PinMapping2560

    This works! Hallelujah!

  • Member #150752 / about 13 years ago * / 3

    If anyone is trying to test this via Bus Pirate do not forget to connect the Reset line to +5V. The board requires voltage to RST or else the MCP2515 will be unresponsive.
    SPI>W
    Power supplies ON
    SPI>[0b11000000]
    /CS ENABLED
    WRITE: 0xC0
    /CS DISABLED
    SPI>[0b00000010 40 1 1 1]
    /CS ENABLED
    WRITE: 0x02
    WRITE: 0x28
    WRITE: 0x01
    WRITE: 0x01
    WRITE: 0x01
    /CS DISABLED
    SPI>[0b00000011 40 r r r ]
    /CS ENABLED
    WRITE: 0x03
    WRITE: 0x28
    READ: 0x01
    READ: 0x01
    READ: 0x01
    /CS DISABLED
    SPI>

  • GeekRedux / about 9 years ago / 2

    Hi. Can someone link to a project or code sample that uses this shield with the CANbus and the SD card at the same time on an Uno?

    I'm working on a project that is to have 3 slave units generate sensor data that they are to save on their own SD cards as well as send via CAN to the master unit. At the same time, the master unit is to receive that data and store it, and based on the data calculate and send via CAN an instruction code back to the one slave unit that controls an actuator.

    We can get the master and one slave to communicate with each other, but not the master and more than one slave, and we can get everything to store stuff to SD cards, but not communicating with each other at all.

    We've been working based off the Seeed Studio CAN-bus code and the Cory Fowler code, and clearly just don't get how to modify these so each board can save data to its own card and communicate with the master unit.

    Thanks.

  • Member #566623 / about 10 years ago / 2

    What is the easiest method to use this shield with the arduino mega?

    • You will have to run jumper wires from the shield to the SPI lines on the Mega. Otherwise, it's just like using it on the Uno.

  • rwilso32 / about 11 years ago / 2

    I have purchased a couple of these shields and they are great. I am wondering if anyone has been able to use these as a CAN to USB adapter to read and write live messages using a GUI similar to http://www.canviausb.com/

  • rmurrish / about 11 years ago / 2

    I used this shield for prototyping a design, and it's all working. Now I'd like to know, if I buy parts to build my own board, is there any programming required for the MCP2515/MCP2551? Or are these chips installed on this board exactly as they come from Microchip. If not, is source code available to make these chips function as they do on this shield?

  • Member #331426 / about 12 years ago / 2

    guys how do i connect the serial lcd?the lcd has three pins, RX, GND, VDD. I have soldered the pinouts in the shield, but i dont know which pinout is gnd, which rx, which vdd. Any help please?

    • vapidr1 / about 11 years ago / 1

      The LCD pinout on this board matches the SF Serial LCD pinout for the 3-pin JST connector. Solder in a JST connector and you should be good. Also, you can look at the traces and see that the pins connect to V, GND, and Rx on Arduino pin D6 (left to right, front face).

  • mwahlman / about 12 years ago / 2

    Let me start by saying that I'm new to this scene, and I'm presently just trying to verify compatibility to make sure that I purchase a product that is capable of meeting my expectations.

    I'm currently looking for a device to communicate with a SEVCON GEN4 Controller (http://www.thunderstruck-ev.com/Manuals/Gen4_Product_Manual_V3.0.pdf). As a bonus, I also hope to be able to communicate with my NMEA 2000 Garmin 17x GPS receiver (http://www8.garmin.com/manuals/2250_TechnicalReferenceforGarminNMEA2000Products.pdf) .

    I'm considering using an arduino with CAN-BUS shield, and eventually also adding in an ethernet shield. I was wondering if anyone has used this product to communicate with a SEVCON GEN4 controller, or NMEA 2000 marine equipment (http://www.interfacebus.com/NMEA-2000_Standard.html)? Should I buy the UNO or MEGA? Does anyone know if the CAN-BUS shield is compatible with the ethernet shield? I hope to to eventually be able to move all the comms between my controller/GPS and my laptop from the direct USB connection to WIFI...

    I appreciate the time anyone chooses to take to answer my questions!

    • lasherone / about 11 years ago / 2

      Hi mwahlman. I am trying to connect the Sevcon GEN4 using the can bus shield for arduino. And maybe I will try to connect the GPS. Could you make them communicate? Do you know how to read the parameters of the Gen4 via CanBus? I would appreciate any information you can provide me. We are trying to connect two Gen4 to drive two motors for a formula e-car.

      • __Tango / about 10 years ago / 2

        I'm also using this shield to talk to a Sevcon Gen4. The Gen4 uses the CANOpen protocol, which is a bit of a pain in the rear to work with as the full protocol is very heavy. Also, you need to know what the "Object Dictionary IDs" that you need are. I'm able to talk to my Gen4 by not implementing all of the CANOpen protocol, i'm only doing the parts that are necessary for me to do some level of communication (only SDOs, not PDOs, no Emergency or NMT either). If i get far enough, i'll put some code on github or something. PM me if you want more info.

        • Member #242458 / about 10 years ago / 2

          _Tango, did you get anywhere with communicating via CANopen?

          • jchernus / about 9 years ago / 1

            Has anyone else made any progress on this? I have just ordered my parts, and I will start designing a datalogger for a vehicle with a Sevcon Gen4 controller. Bit of a noob, so I could use all the help I can get :)

  • jwschmo / about 13 years ago / 2

    Minor note, I believe that left and right on the joystick are reversed Left is actually pin A5 and Right is pin A2. also you need to set up the pull up resistors for the digital inputs for the joystick or it won't work correctly. Example code doesn't do that, actually I'm finding a lot of bugs in this code.....
    pinMode(UP,INPUT);
    digitalWrite(UP, HIGH);
    Also, side note for Arduino Mega users, A0 - A5 aren't the same pin number as in the regular Arduino, so the code will have to be modified accordingly.

    define UP A1

    define DOWN A3

    define LEFT A5

    define RIGHT A2

    define CLICK A4

    • John-o / about 13 years ago / 1

      You saved my bacon after trying to troubleshoot why this shield and keypad wasn't working for hours!
      Also, in case anyone else has issues, I'd suggest changing the can_shield_test demo sketch to point it to the correct LCD pin (6) instead of 14
      NewSoftSerial sLCD = NewSoftSerial(3, 6);

      • jwschmo / about 13 years ago / 1

        Got it working :). So I basically rewrote the Driver for the CAN-bus based off of SKpang's work, you have to access pins 51 through 54 on the mega to get the SPI working, I'm going to be honest here, from a compatibility standpoint, changing the spi to those locations between the uno and the mega was stupid it basically removed that ability for any shields that use SPI. So what I did was hardwired the pins according to the documentation stated on their webpage. (arduino's) Also, the SD card code doesn't work at all, so don't bother, its a mess. I went and grabbed the SDFAT library that is better supported from arduino. note that pin 9 is CS so you are going to have to make that an output and force it low to get communication between the SD card and the micro. Finally, note that you won't be getting 1Mbps out of the card, at least I'm fairly certain you won't as it only has a 16 MHz osc on it so you can't hit the baudrate and still get safe edge detection, if that doesn't make sense don't worry CAN baudrate is a pain to figure out. I think thats about it for now. I'll try and post my code somewhere when I get around to it, work is starting up again so less time for fun :).

        • jwschmo / about 13 years ago / 1

          one more thing, most cars before 2008 in the US don't use CAN bus if you have a German (or other EURO manufacturer) then you probably have it, my 2008 Saturn Astra was built in Belgium so I'm set :). Also, I believe the req for OBDII is 500 kbps so we don't really need the 1 Mbps. That being said note that the manufacturers tend to hide the communication going on "under the hood" so there might be more going on in your car that you can't get access to easily from the OBDII connector.

  • Member #146071 / about 9 years ago / 1

    You've got a problem when you example code fails to compile...

  • Member #631180 / about 9 years ago / 1

    I have just purchased one of the CAN Bus Shield for a 3rd year project for my Degree and already have a Serial 1602 I2C (LCM IIC 1602) LCD Module with VCC, SDA (TX Data), SCL (RX Data), and GND on it.... it currently connects to the analog lines on the Uno R3 that I have, however the CAN Bus shield will connect to this.

    My question is this: Can I connect the LCM I2C Serial module to the three pins on the CAN Bus shield? The Sparkfun shield however only has VCC GND and RX.. Can I connect just the RX VCC and GND pins from the CAN Bus to the respective pins on the current LCD module that I have and if so what happens to the TX line (SDA)?

    thanks in advance

    Paul

    • No, the LCD connection on the CAN-Bus shield is only for LCDs that run off of serial, and is connected to D6 on the Arduino. The I2C pins are connected to the joystick on the shield, so you can cut the traces from that, and use the I2C lines for your LCD screen. This will however, remove the ability for your to read joystick clicks or movement in the right direction. The other functions of the joystick will still work if you only cut the traces to A4 and A5.

  • Member #618656 / about 9 years ago / 1

    This CAN-BUS Shield adopts MCP2515 CAN Bus controller with SPI interface and MCP2551 CAN transceiver to give your Arduino/Seeeduino CAN-BUS capibility. http://www.elecfreaks.com/store/canbus-shield-p-746.html

  • Member #622359 / about 9 years ago / 1

    Does this work with ODB 1?

  • Member #621844 / about 9 years ago / 1

    Is this support for Low Speed Can?

  • Member #605170 / about 10 years ago / 1

    Hallo

    I am working on an home automation project where my task is to communicate between LPC1766(Cortex M3) and LPC11C24(Cortex M0).

    Can anyone tell me or put a sample coding on how to communicate between two different microcontrollers using CAN BUS

  • Member #598134 / about 10 years ago / 1

    Hello everyone

    I have been trying to get some data from my car using this shield and the OBD-II to DB9 Cable. But I can't get the data of the RPMs of the motor, anyone have any advice for me?

    Thank you!

  • airspoon / about 10 years ago / 1

    Can I use the EM506 GPS module with this shield? I have the shield already, bought it a long time ago -but the EM406 seems to no longer be available.

  • Member #540983 / about 10 years ago / 1

    I have connected this shield to an Arduino YUN and is working to a certain extent. I am able to perform the loopback test using this code: https://code.google.com/p/canduino/source/browse/trunk/Source/canduino_DEMO/LoopbackTest.pde

    It works as long as the mode is set to "LOOPBACK". If I try running the test with mode set to "NORMAL", it does not work.

    I realize that messages are not going out on the actual bus when running in LOOPBACK mode, so the only way to test the input/output transceivers is to run the test in NORMAL mode. I believe I have a correctly terminated CAN bus, with 70 ohms across CAN-H and CAN-L.

    Based on the comments in the code, I'm assuming the test should work in NORMAL mode using a single node. Has anyone been able to run a loop back test in NORMAL mode?

  • Member #555237 / about 10 years ago / 1

    Hi guys, I tried the demo sketch on my arduino meda adk but does not work the "read" function. I am not able to read anything. There is someone that can post a simple sketch to read all the data on the bus^ Thanks

  • Member #554329 / about 10 years ago / 1

    Holy sh%&,

    it costed me several hours to find out, that Amazon apparently is setting the standards for the CAN-pinout. At every CAN-Cab, or other gadgets to analyze the CAN, the pinout is 2 Low - 7 High and 3 GND, as mentioned by calvinium. If in doubt, take a look at http://vector.com/ . They set the quasi-standard in CAN-analyzing ( at least in Europe :) ) .

  • Member #553095 / about 10 years ago / 1

    Hi guys, there is someone that can precisely explain which are the steps to follow and which are the library to use to read CAN messages using an Arduino Mega ADk. Thanks

  • JerseyTechGuy / about 10 years ago / 1

    Not finding demo code on the SK Pang Site/

    • M-Short / about 10 years ago / 1

      Its there, they just decided to not make it look like a link. Click where you want a link to be and it should work :)

      • jchernus / about 9 years ago / 1

        Under "Documents" if anyone is still having trouble finding it.

  • Member #544043 / about 10 years ago / 1

    Can I use more than two of these shields to create a net?

  • Member #408370 / about 10 years ago / 1

    Right now, I'm running into a wall with collecting data on the Uno using this shield. I need GPS latitude/longitude and a few things off of a CAN-bus connection on a car, and I need to write these things to a micro SD card. With the Uno, I can do GPS or CAN, but not both at the same time. I'm investigating the Arduino Mega 2560 as a way to solve this problem. Will the Mega allow me to do my file writing, and what adaptations do I have to make in order to do so?

    • GeekRedux / about 9 years ago / 2

      I'm running into the same problem, but can't get it to use the CAN and access the SD card in the same sketch--also on an Uno. Did you find a solution?

  • Arjan Woltjer / about 10 years ago / 1

    I use this shield to get data from an Isobus terminal, and was trying at first with the Arduino Leonardo. This didn't work because the spi pins are on a separate header. Could I suggest for compatibility reasons to move the spi to the icsp header? This way the shield automatically works on Leonardo and mega boards as wel.

    • Member #553095 / about 10 years ago / 1

      did you figure it out? I have an arduino MEGA adk and I would like to know how it works properly with this board thanks

  • hinano2012 / about 10 years ago * / 1

    As anyone succeed to connect this shield on an NMEA 2000 network. I would like to be able to have some data product by my Volvo Penta on my boat via an NMEA2000 : VOLVO BOX The only thing i new is that NMEA 2000 is based on can bus So what must be done :

    • 12V / 5V
    • Common ground, protection, isolation
    • Connectors : I would like to be able to plug the shied like a standard NMEA 2000, that means T cable and micro-c connector
    • Hardware adaptation if any, i expect none
    • Open software for data conversion and analysis

    Old programmer, I start with arduino so, any help would be more than welcome

  • Member #521690 / about 10 years ago / 1

    Hi, I am trying to send messages on a CAN-BUS using this shield but I cannot. I tried with different libraries including the demo code, this one https://github.com/coryjfowler/MCP2515_lib and the one from canduino project. I am using an Arduino UNO R3 and I put a resistance between CAN_L and CAN_H pin. Am I missing something? Do you have any sample code for sending CAN messages?

  • Member #149642 / about 10 years ago / 1

    Can CANOpen be used or implemented with this shield?Guys please let me know.I have a motor controller which speaks over CANOpen and I literally have no idea about CAN or CANOpen.How is CANOpen different from CAN.

    Ranjan

    • Hmm, to be honest, I'm not sure. I haven't personally heard of CANOpen previously, so I'd have to dig into it. Perhaps someone else might have some better information for you!

      • Member #518190 / about 10 years ago / 1

        I just completed a project with Arduino Uno, CANbus shield and using de Seeedstudio CAN library controlling a maxon EPOS2 servodrive via CANopen. Works perfectly for me.

        CANopen is just another way of using the 8 available databytes of an CAN message. Also the CAN ID's used, have to confrom the CANopen specification.

        The Seedstudio CAN library allows to receive messages on interupt, or polled. The interrupt method did not work for me, as I missed messages. Using polled reception and configuring the CAN message filters correctly worked best.

        CANopen also allows messages to be Synced with the CANopen master (in this case my Arduino). You can control teh CAN busload very nicely in using this meganism. I was able to send dat and receive status messages with 100Hz using a pre-stored motion profile on the uSD card.

        I could share my code if you would like?

  • Member #462197 / about 10 years ago / 1

    Hello. I have purchased this shield, but realized that the network i'm trying to connect to is a low speed CAN(fault tolerant CAN). Can you use this as a low speed CAN? I know the termination resistor is setup different in a low speed CAN. Please let me know. Thanks in advance.

    • Member #521690 / about 10 years ago / 1

      Yes, I was missing something. To change the pin-out of the DB9 to the standard as explained in the comment of Calvinium!!

  • c.fowler / about 11 years ago / 1

    Yay changes >> Use the library here: https://github.com/coryjfowler/MCP2515_lib

  • Member #471024 / about 11 years ago / 1

    Have anyone got this shield to read extended (J1939) headers? I got the send part to work, but the read messes up the id. Thank you.

  • mr_hacker90 / about 11 years ago / 1

    i think the coding does not work with arduino IDE 1.0. when compile, the IDE show compile error like below. hopefully someone can tell me what is the problem. TQ.

    file.writeError = 0; 'class SdFile' has no member named 'WriteError'

  • Member #463408 / about 11 years ago / 1

    Has anyone used this shield with a slower (1.0) can bus? I think about using it with an older piece of equipment and would like to know in advance if this shield is downward compatible.

  • Member #462197 / about 11 years ago / 1

    Hello,

    Can this shield run on 100kbaud rate? I am asking because Seeedstudio's CANbus shield, which has both MCP2515 & MCP2551, does not operate at different baud rate other than at 500kbaud. Just wanted to double check if this one can run on different baud rate, in my case 100kbaud, before I buy this. Thank you.

    • c.fowler / about 11 years ago / 1

      That is incorrect, the library is the determination of what the chip can do. Check out my update to the library here: https://github.com/coryjfowler/MCP2515_Library

  • Member #262691 / about 11 years ago / 1

    This shield seems to be incompatible with the Aruino Leonardo:

    SPI: on the ICSP header. These pins support SPI communication using the SPI library. Note that the SPI pins are not connected to any of the digital I/O pins as they are on the Uno, They are only available on the ICSP connector. This means that if you have a shield that uses SPI, but does NOT have a 6-pin ICSP connector that connects to the Leonardo's 6-pin ICSP header, the shield will not work. (from http://arduino.cc/en/Main/ArduinoBoardLeonardo)

    • This current version is not, you are correct. We do have an adapter shield that will allow you to use this shield with the Leonardo, called the TransmogriShield. We are working our way through the catalog and working on revisions for shields to update them to the R3 and Leonardo footprints as needed. Until then though, the TransmogriShield is your best bet.

      • __Tango / about 10 years ago / 1

        Is there any news on getting a R3/Leonardo (SPI-on-ICSP) version of this board?

        • We are still waiting to get the prototypes back on this one. The SPI-on-ICSP gets tricky because of the placement of the DB9 connector. We are working on it though! At the very least, the new version will have the R3 footprint.

      • c.fowler / about 11 years ago / 1

        I have a revision to this shield, who could I get into contact with about getting it put into production?

        • I just emailed you regarding this, but for general knowledge, those emails would go to tech support generally.

  • Member #416792 / about 11 years ago / 1

    FYI, there is something wrong with the schematic link. It is effectively blank.

    • We've been getting reports of problems opening both PDFs we generate in our own code and at least some of the schematics we've got up. I haven't been able to reproduce this anywhere, but I'm starting to suspect a glitch in some widely-deployed PDF viewer (Acrobat? Something that's built in to IE or Windows these days?). We'll eventually figure out what's going on, but in the meantime you might try different software. I haven't used it in ages, but if you're on Windows, Foxit used to be decent.

      • MikeGrusin / about 11 years ago / 1

        I've been having problems like this with Firefox's built-in PDF viewer. That viewer has a "download" button that will reload it in any PDF viewer you have installed (such as the official Adobe viewer or any other option), which always works for me.

        • Member #132879 / about 11 years ago / 1

          Not sure if it helps now, but I corrected this issue by changing the default pdf viewer in FF. To do this: - Click "Tools" - Click "Options" - Click "Applications" - Scroll down to "Portable Document Format (PDF)" and change the Action to "Use Adobe Acrobat (in Firefox)" - Click "OK" to save and your Uncle is now Robert!

  • Member #415673 / about 11 years ago / 1

    I need the CAN bus to run on 1 Mb/s, but no idea how to change that. In the library only speeds up to 500 kb/s are supported. Any ideas? Thank's Thomas

  • Marion Rickard / about 11 years ago * / 1

    Anyone see this dual channel CAN bus adapter for Arduino Due http://store.evtv.me/proddetail.php?prod=DueCANBUS

    Apparently there is a library out for it as well. https://github.com/collin80/due_can

  • Member #444194 / about 11 years ago * / 1

    Hi,

    I am really new into this stuff so this might be a really bad question - I tried installing the default code (v4) from SkPang but for some reason I get an instant "Can't init CAN" message and a blinking green light (I think it says D7 on the PCB) even though I am almost certain that my Clio II uses CAN at 500kbps. There is no delay what so ever - it just instantly goes to the error so I assume the init returns false. I tried digging into the mcp2515_init but I can`t really understand what is going on there.

    I am using an Leonardo if that matters.

  • Member #413114 / about 11 years ago / 1

    Does anyone know about using this to set up a CAN network?

    For the DB-9 connector, I was expecting that CAN_H is on pin 7 and CAN_L on pin 2 like: http://www.kanda.com/images/canpinout.gif

    However what seems to be happening on the eagle file is that CAN_H is on Pin 3 and CAN_L is on pin 5. Is what I am seeing correct? or Have I got an old eagle file? Or is it wired this way for a reason?

    • SimBob_ / about 11 years ago / 1

      Your info implies there might be more than one "standard" for the pinout of the DB-9 connector. If you look at the pinout dwg for the Sparkfun cable, it agrees with the board schematic: https://www.sparkfun.com/products/10087

  • Member #408370 / about 11 years ago / 1

    For those of you out there running SK Pang's version 4 code for this board on an Uno R3, realize that you're probably going to run into the maximum the board can handle if you decide to throw in some debugging code, like Serial.println() statements to see what's going on in more detail than the LCD can provide. The functional limit (using libraries available as of 3/19/2013) seems to float somewhere around 20,000KB sketch size. I'm going to try this again with a Mega 2560 to confirm that more memory helps.

    • SimBob_ / about 11 years ago / 1

      I am just getting started using this shield with the Mega 2560 - any wiring connectivity help would be appreciated. I've seen some discussion about the use of different pins and wiring some pins to other locations, and I'm a noob, so a wiring diagram of what actually works would be great.

  • Marion Rickard / about 11 years ago / 1

    Is this shield compatible with the Arduno Due?

    Jack Rickard

    • bdwyer / about 11 years ago / 2

      The Arduino Due already HAS a CAN controller. You will only need a CAN Transceiver (if Arduino broke out the CAN-Rx and CAN-Tx).

    • Member #191562 / about 11 years ago / 1

      It won't sadly. CAN is running at 5V. You would need a level shifter between the shield and the arduino due to turn those 5V signals into 3V3 signals. I might not be seeing all the possibilities here, and I've got a mind to believe it will kinda work if you just remove the 5V Vcc and put it to 3v3 instead. We'll find out when I try it!

  • Member #389302 / about 11 years ago / 1

    I found a problem with my cable...

    I found that the connections from the OBD connector to the D-Sub are not what I expected. The connections to the Canbus (High and Low) were for a protocol different to my own. The signal wasnt getting to the correct pins on the DSub.

    I soldered the wires to the correct pins. However no improvement...

    Anyone have an idea on the next thing to look at?

  • Reinis Veips / about 11 years ago / 1

    Here is the software and Arduino firmware which I used to communicate with my Volvo S80 '02: https://github.com/festlv/canbus_logger

    It includes GUI frontend on PC which I used to find out which of all the messages (300+ per second) correspond to keys pressed on steering wheel.

    Please keep in mind that you will probably have to re-define some pin #s, as I didn't exactly use this shield (but the CAN-bus schematics was almost identical). It may also not compile in Arduino IDE on the first try- I use Sconstruct for code deployment to Arduino.

  • Member #378166 / about 11 years ago / 1

    Hi All Does any body know if it is possible to use CAN-BUS shield to make communication between arduino uno. and plc(programmable logic control )for automation .If you take in your account my own plc has can-bus capapilty already.

    thnx

  • jwschmo / about 12 years ago / 1

    Just curious folks, but is there any interest in a similar Arduino shield for Single Wire CAN which is usually used by General Motors for GMLAN?

    • Member #462472 / about 11 years ago / 1

      Hi Did you ever find a Shield for Single Wire CAN to use on GMLAN SW-CAN ? I would be interested in one to talk to a Corvette Instrument Cluster.

  • I have made a library for VSCP (http://www.vscp.org for this shiled. Library plus a fully working VSCP over CAN sample is available here https://sourceforge.net/projects/m2m/files/VSCP%20Firmware/

    VSCP is a free and open protocol for home automation and other control tasks If you are intersted to learn more about the protocol can find more information here http://vscp.org/docs.php

    Enyoy! akhe

  • MajorEET / about 12 years ago / 1

    Has anyone tried this with 29bit J1939 extended protocol?

    • Member #115832 / about 12 years ago / 1

      Yes. However the current library does NOT support it. I made some modifications and... voila. Here is an updated library that supports the extended 29-bit identifier.

      http://www.nunoalves.com/open_source/?p=475

  • Member #341612 / about 12 years ago / 1

    Hi there, I have recently bought this shield but there is no way to make it work =( I have commented all SD/GPS/LCD related functions as I dont want to use it (for the moment at least) and have added some code to use a liquidcrystal. By the way it gets stuck in this line “if(Canbus.init(CANSPEED_500))” because nothing else is being displayed (one print before and one after). Any idea about what is happening? Thanks in advance

  • Member #331426 / about 12 years ago / 1

    Guys please i have one question. Can i use this shield to program, not read, but program a brain of a car? Please help! Thanks!

  • Member #328121 / about 12 years ago * / 1

    I am not sure if this is being monitored anymore, but I am having an issue with this shield. I am successfully recording data to the SD card and polling the CAN card. However, the CAN buffer is never being populated. I am trying to record broadcasted CAN communications from another CAN device. I have verified, with another CAN card, that data is going out over the network. I was wondering if anyone has had any issues with this type of problem or if I might be overlooking something obvious.

    I am using skpang's latest ECU code, and using the message_rx function to poll the bus.

    Any thoughts?

    UPDATE : I placed an 120 ohm resistor between the CANh and CANl pins since I am directly connecting with another terminated node. I have verified that the other node is communicating at the same speed and, with another adapter, that it is transmitting data. I have run the loop back test described by some other tutorials and that is successful.

    UPDATE 2 : Ok, so try not to make the same mistake I did with the pinout. This shield doesn't follow any de facto pinouts for CAN connectors. So unless you are using one designed for this shield it is likely that whatever you are connected to won't work out of the box. Everything appears to be working at the moment.

  • Member #26093 / about 12 years ago / 1

    Has anyone been able to get this thing to work???

    I'm having a lot of trouble with it

  • Member #305557 / about 12 years ago / 1

    how can my can-bus interface with a clas II data bus? any idea?

  • ebozlak / about 12 years ago / 1

    Can i use this shield for application except based on "Car". Can i connect this shield to my computer via sub-D connector

    • MikeGrusin / about 12 years ago / 1

      The sub-D connector is for a special ODB-II cable, not RS-232.

      • ebozlak / about 12 years ago / 1

        Thanks Mike,can you suggest me a shield for RS-232?

        • MikeGrusin / about 12 years ago / 1

          If you plug this into a standard Arduino, you'll have a USB connection to the board - would that work for you?

          If you need true RS-232, I'd plug this shield into an Arduino Pro (which gives you a TTL serial port), and use a MAX-232 chip to convert the TTL logic levels to RS-232. The USB port would be much less work, so I'd go with that if you can.

  • yab_77 / about 12 years ago / 1

    I'm trying to connect the CAN-BUS Shield to the Arduino Uno R3. Does anyone have any sample code I can look at or know any good resources to help with coding? any thing relative will help! Thanks!

  • Member #301698 / about 12 years ago / 1

    Hi Guys, Probably I have a silly question, but I was wondering what is the difference between this shield and the OBDII-UART. I am new to electronics and I want to make a trip computer for my car.

    • pgvoorhees / about 12 years ago / 2

      The OBD2 UART abstracts away the CAN interface. If you want vehicle metrics, and you don't want to reverse engineer your Car's CAN protocol and you don't want to learn OBD2, get the OBD2 Uart device, it will be easier. If you want to learn how your car's CAN system works and see what's in your car, get this.

      My suggestion is to get the other device.

      • Member #301698 / about 12 years ago / 1

        Thank you so much! I just want to get some information from my car's CAN system so I will go for the UART.

  • h22 / about 12 years ago / 1

    Still pretty new to the arduino, but I bought this board and downloaded the code and library from SK Pang; http://skpang.googlecode.com/files/Canbus_v4.zip. Listed for use with IDE 1.0. I get all kinds of compiler errors, most of them due to the SD card code, and a few for the use of NewSoftSerial (changed to SoftwareSerial).I really want to play with this, but with all the errors I am not sure i am up to the task of getting the code fixed. Has anyone gotten this to work with a UNO and 1.0? Thanks Joe

    • h22 / about 12 years ago / 1

      Ok, I got the code to compile, had to delete all the files and re-install them. I still get 1 compile error (with arduino uno R2 and arduion 1.0 IDE ): ecu_reader_logger.cpp: In function 'void logging()' ecu_reader_logger:262: error: 'class SdFile' has no member named 'write error'

      I am assuming that this is an issue with the SD library?

      • SK Pang Electronics / about 12 years ago / 1

        Make sure you have the SD library installed. Download from https://github.com/adafruit/SD

  • SK Pang Electronics / about 12 years ago / 1

    There is a new version of the sketch for Arduino 1.0 on the product page now: http://www.skpang.co.uk/catalog/arduino-canbus-shield-with-usd-card-holder-p-706.html

  • risc / about 12 years ago / 1

    Is there any code working with Arduino UNO v1?

    • Member #304526 / about 12 years ago / 1

      Hi all, I am also looking for the code that working with Arduino UNO. Is there anyone can help ? Thank you.

  • Member #297585 / about 12 years ago / 1

    Can someone confirm the schematic in the Eagle file? the schematic shows that Pin 18 (Vdd) on the MCP2515 is open. The photo of the board shows the pin to +5V. Am I missing something?

    • qzshush / about 12 years ago / 1

      It's connected tp +5V. Eagle file also shows it, although the passing line might be confussing. Best Stefan

  • denizen08 / about 12 years ago / 1

    I'm a bit confused about OBDII and some proprietary protocols like Multi-User Tester (MUT). Will this board be able to interpret MUT II protocol like that of a Mitsubishi Mini Pajero, 1994-1997 model?

    This website (http://www.obdtester.com/carinfo/mitsubishi/all_models/) tells me all 1996 models and up supports ISO-9141, part of the OBD II suite. But I am unsure if ISO-9141 is compatible or compliant with MUT II.

  • nntendopower454 / about 13 years ago / 1

    Im trying to read data using a Mega with jwschmo's modified code and it begins recording before actually getting the response from the car which is a 2006 Buick Rendezvous. Also it when it actually is connected it does not write anything except the initial header. Any ideas?

  • SysGiy / about 13 years ago / 1

    Guys - love the shield, but can't seem to get it to function on either of my cars - both Mercedes.
    I suspect that the CAN-D accessible via the ODBC port requires something to tell it to "start". Still digging for that, anyone with any advice, mucho appreciated.
    Second, I can tap the CAN-B - internal CAN - which runs at 83kbps, but I'm not sure how to configure the shield to support 83.333kbps!?

  • InBigTrouble / about 13 years ago / 1

    HELP! I have a terrible problem at work, that I need to build a CAN bus gateway for, which means I need 2 CAN busses. Can I have an Arduino board read messages on one port and send them out the other?

    • Keija / about 13 years ago * / 1

      Yes you can - you need to rewire the CS and INT pin, define the new pins and change the mcp_2515 library - but it's possible, I'm currently exploring the possibilities and will report on how responsive it is.
      I connected pin 2 and pin 10 of the second can shield to pin 3 and pin 5 of the arduino, added these two lines to defaults.h:
      #define MCP2515_CS_2 D,5 (pin 5)
      #define MCP2515_INT_2 D,3 (pin 3)
      and currently i created a copy of the mcp2515.c and .h, renamed it to mcp2515_2 and replaced the conflicting names and values with a suitable name_2 ... and it works :)
      I'll try to write a wrapper class, that you instantiate in code and tell it, which ports are used for which node

      • Member #402904 / about 11 years ago / 1

        Have you managed to get working two CAN bus controller together? When I've changed definitions of MCP2515_CS and MCP2515_INT to other pins (and of course reroute MCP2515 connection to correct pins of Arduino) program stucks at Canbus.init function....

  • Jauru / about 13 years ago / 1

    Is the "9-way sub-D standard OBD-II connection cable" included with this shield, or listed as a "suitable" choice as an add-on?
    Also, does the serial LCD connector supply 5V or 3.3V?

    • Member #545191 / about 10 years ago / 1

      The LCD connector puts out 5V power and 5V TTL serial (very annoying that isn't listed anywhere in the specs or description). I was able to run it with one of the Sparkfun 3.3V LCDs by connecting the LCD's power to the 3.3V pin on the arduino. Trying to run the 3.3V LCD at 5V freezes it. Ground can be connected to LCD ground or arduino ground. Interestingly, although the 3.3V LCD description says it must also receive 3.3V TTL serial, the 5V TTL serial output by the CAN bus shield seems to work. However, I was worried about it getting damaged over time so I added a 100 and 200 ohm resistor to divide the voltage to 3.3. Actually it ended up at 2.5V for some reason but it's been working fine.

  • Member #124041 / about 13 years ago / 1

    Is this shield CAN bus only or is it backwards compatible with the other ODB-2 protocols, SAE-J1850 VPW, ISO 9141, KWP2000 and SAE-J1850 PWM?

  • paimon.soror / about 13 years ago / 1

    Hey guys, was wondering if you could help me out. I started using some of the code listed here for my canbus application, and the code has been working flawlessly. What I want to be able to do next is to just "sniff" the canbus just to see what messages are currently being passed back and forth. I started a thread here:
    http://forum.sparkfun.com/viewtopic.php?f=14&t=28999
    Thanks guys

  • Valerun / about 13 years ago / 1

    Hi Guys - just got this one. Have anyone used it to BROADCAST data into CANbus (as opposed to just listening)? Anyone has code examples? The message_tx() function in the SKPang library seems to be just a placeholder...
    What I am trying to do: we have some aux equipment running in the car and I'd like to push some operational parameters from that equipment into the CANbus so it can be picked up by the Android-based CAN visualization app we are using (Torque).
    Thanks!
    Valery.

  • josefodunga / about 13 years ago / 1

    I have a CAN Bus Network from which I want to read messages but I cannot under any circumstances write any messages. And I need to take this messages and write them to another CAN Bus network. Does anybody have any ideas on how to do this.
    Thanks

    • becker / about 13 years ago / 1

      Make certain that you understand your requirements. From simplicity of the question, it is pretty clear that you don't.
      Do you need to avoid transmitting frames? Or do you need to not transmit anything e.g. ACK and error bits. What about overload frames? Error frames?
      Do you want to receive frames which are correct except for the ACK bit? (Possible with some CAN controllers in passive monitoring mode.)
      How many packets do you want to queue for the second CAN bus? What happens the queue overruns? (It is possible.)
      You must understand the options to pick the right one. Make certain that everyone involved understands the implications, and that Quiet mode is different than Silent mode.

  • folco75 / about 13 years ago / 1

    Hi,
    I bought the CAN-BUS Shieldand I'd like to use it with mu arduino mega 2560 board.
    I tried to use your "8 March" code (http://code.google.com/p/sparkfun-arduino-can-shield-code/downloads/detail?name=CANInterface.zip&can=2&q=) but when I power my board after the "sparkfun" screen nothing appear.
    I connect (Pin 13 -> Pin 52 Pin 12 -> Pin 50 Pin 11 -> Pin 51 Pin 10 -> Pin 53) and de-connect pin 13, 12, 11, 10 from the Arduino mega board.
    Can you help me please ???
    Thank you,
    Stefano.

  • Member #216889 / about 13 years ago / 1

    what lcd can i use with this? seems the 5 v one is popular since they are always sold out. i see there are the 3.3v ones ,but the shcematic looks like vcc for the lcd could be 5 v.

  • jwschmo / about 13 years ago / 1

    Ok, code is posted here:
    http://code.google.com/p/sparkfun-arduino-can-shield-code/downloads/detail?name=CANInterface.zip&can=2&q=
    should only have to take what is in there and paste it in your library and you should be all set, I'll double check here in a minute. good luck

    • jwschmo / about 13 years ago / 1

      One other thing, for the Arduino Mega to work with my code you are going to have to connect pins together using jumper wires of some sort. Specifically:
      Pin 13 -> Pin 52
      Pin 12 -> Pin 50
      Pin 11 -> Pin 51
      Pin 10 -> Pin 53

  • Member #100426 / about 13 years ago / 1

    Does anybody know if it is possible to connect two of these to each other to form an Arduino-to-Arduino communication link? This could provide a good connection for long distance communication or to connect multiple nodes and form a network.

    • Keija / about 13 years ago / 1

      Yes, you definately can. You just need to "terminate" the bus (connect can h and can l over a 120 Ω resistance - but better inform yourself about this, before you proceed!) and write the appropriate code for message handling.
      But when your done, it works like a charm

  • Member #205575 / about 13 years ago * / 1

    If you want play with CAN in arduino you can also use the OLIMEX AT90CAN128 Eval board:
    http://www.sparkfun.com/products/8279
    Works out good value as you get a whole dev board for almost the cost of this sheild. And you get native CAN support.
    Only catch is you need to program the arduino bootloader to it, some instructions here:
    http://arduino.cc/forum/index.php/topic,53309.0.html

  • rleto577 / about 13 years ago / 1

    Save you hair. They have a tendancy to fall off on their own as time goes on... Anyway, I'm not sure what you mean by pastebin, I assume it's the comments box at the top. I'll put the code in there again assuming you have a way to reformat the code. Here it is: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    /* Welcome to the ECU Reader project. This sketch uses the Canbus library. It requires the CAN-bus shield for the Arduino. This shield contains the MCP2515 CAN controller and the MCP2551 CAN-bus driver. A connector for an EM406 GPS receiver and an uSDcard holder with 3v level convertor for use in data logging applications. The output data can be displayed on a serial LCD. SK Pang Electronics www.skpang.co.uk v1.0 28-03-10 Modified by: R. Letourneau VE3MPV for the Arduino MEGA - Feb 18th, 2011 Pin assignment: CAB-BUS MEGA ------- ----- RST Reset +3.3 3V3 +5V 5V GND GND 13 52 SCK/PB1 12 50 MISO/PB3 11 51 MOSI/PB2 10 53 SS/PB0 9 9 PH6 8 8 PH5 7 7 6 16 TX2 5 18 TX1 4 19 RX1 A4(18) 25 A3(17) 23 A2(16) 24 A1(15) 22 / // #include #include #define COMMAND 0xFE #define CLEAR 0x01 #define LINE0 0x80 #define LINE1 0xC0 #define sGPS Serial1 // NewSoftSerial mySerial = NewSoftSerial(4, 5); #define sLCD Serial2 // Repalces: NewSoftSerial sLCD = NewSoftSerial(3, 6) #define LED2 8 #define LED3 7 #define D9 9 #define UP 22 #define DOWN 23 #define LEFT 24 // Should be the RIGHT #define ENTER 25 #include #include #include #include #include #include #include #include #include FAT TestFile; char buffer[512]; int read_size=0; int count=0; #define COMMAND 0xFE #define GPSRATE 4800 #define BUFFSIZ 90 char *parseptr; char buffidx; uint8_t hour, minute, second, year, month, date; uint32_t latitude, longitude; uint8_t groundspeed, trackangle; char latdir, longdir; char stat; void setup() { Serial.begin(9600); sGPS.begin(GPSRATE); sLCD.begin(9600); pinMode(LED2,OUTPUT); pinMode(LED3,OUTPUT); pinMode(UP,INPUT); pinMode(DOWN,INPUT); pinMode(LEFT,INPUT); pinMode(ENTER,INPUT); digitalWrite(UP,HIGH); digitalWrite(DOWN,HIGH); digitalWrite(LEFT,HIGH); digitalWrite(ENTER,HIGH); pinMode(D9,OUTPUT); // Used for SD_CS in file: sd_raw_config.h // macros: select_card() & unselect_card() // Canbus/defaults.h pin assigment changed for MEGA Serial.println("ECU Reader"); sLCD.print(COMMAND,BYTE); sLCD.print(CLEAR,BYTE); if (Canbus.init(CANSPEED_500)) { sLCD.print("CAN Init ok"); } else { sLCD.print("CAN Init Failed!"); while (1) ; } delay(1000); sLCD.print(COMMAND,BYTE); sLCD.print(CLEAR,BYTE); sLCD.print(COMMAND,BYTE); sLCD.print(CLEAR,BYTE); sLCD.print("Mode: CAN GPS SD"); sLCD.print(COMMAND,BYTE); sLCD.print(LINE1,BYTE); sLCD.print("Push: Dwn Up Rt"); } void loop() { if (digitalRead(UP) == 0) { Serial.println("GPS..."); sLCD.print(COMMAND,BYTE); sLCD.print(CLEAR,BYTE); sLCD.print("GPS..."); gps_test(); } if (digitalRead(LEFT) == 0) { sLCD.print(COMMAND,BYTE); sLCD.print(CLEAR,BYTE); sLCD.print("SD..."); Serial.println("SD..."); sd_test(); } if (digitalRead(DOWN) == 0) { Serial.println("CAN..."); sLCD.print(COMMAND,BYTE); sLCD.print(CLEAR,BYTE); sLCD.print("CAN..."); while(1) { Serial.print('.'); // Mind pacifier if(Canbus.ecu_req(ENGINE_RPM,buffer) == 1) { sLCD.print(COMMAND,BYTE); sLCD.print(LINE0,BYTE); sLCD.print(buffer); } digitalWrite(LED3, HIGH); if(Canbus.ecu_req(VEHICLE_SPEED,buffer) == 1) { sLCD.print(COMMAND,BYTE); sLCD.print(LINE0 + 9,BYTE); sLCD.print(buffer); } if(Canbus.ecu_req(ENGINE_COOLANT_TEMP,buffer) == 1) { sLCD.print(COMMAND,BYTE); sLCD.print(LINE1,BYTE); sLCD.print(buffer); } if(Canbus.ecu_req(THROTTLE,buffer) == 1) { sLCD.print(COMMAND,BYTE); sLCD.print(LINE1 + 9,BYTE); sLCD.print(buffer); } digitalWrite(LED3, LOW); delay(50); if (digitalRead(ENTER) == 0) break; } dispMsg(); } delay(1000); } void sd_test(void) { Serial.println("ready..."); TestFile.initialize(); Serial.println("Starting..."); TestFile.create_file("rej7.txt"); TestFile.open(); while(1) { TestFile.write("This is test data."); TestFile.close(); while(1) { TestFile.open(); read_size=TestFile.read(buffer); Serial.println(read_size, DEC); for(int i=0; i '9') || (str[0] < '0')) return d; d *= 10; d += str[0] - '0'; str++; } return d; } void dispMsg() { sLCD.print(COMMAND,BYTE); sLCD.print(CLEAR,BYTE); sLCD.print("Mode: CAN GPS SD"); sLCD.print(COMMAND,BYTE); sLCD.print(LINE1,BYTE); sLCD.print("Push: Dwn Up Rt");; Serial.println("ECU Reader"); / For debug use */ }

    • kactus / about 13 years ago / 1

      Hi rleto577
      Yeah it looks like the form on this side ate a bunch of the code. Can you please post it either in the forum that Tempest2k8 suggested or in paste bin please?
      Thanks in advanced.
      Kactus

      • jwschmo / about 13 years ago / 1

        Ok kids, just got this working not only with the baud rates provided by skpang, but also using 95kbps, this is using my modified library based off of skpang's library, I'll post in the forum and put the link here, for those that are interested 95kbps is the baudrate for GMLAN medium CAN. One other note, I'm using the Arduino Mega, with both CODE and HARDWARE WIRING modifications, its the only way to do it, I'll try and get that stuff laid out as well.

    • Tempest2k8 / about 13 years ago / 1

      How about pasting the code into the CAN-BUS forum. The format will be retained.
      CAN-BUS Forum

    • kactus / about 13 years ago / 1

      Hi rleto577 thanks for this. I'll go through this tomorrow and see if I can get it to compile since its thrown a bunch of errors (looks like it has stripped out anything in angled brackets so I'll work out which includes it needs) and messed up the comments.
      From a glance it looks like its based off the can_shield_test pde so I should be able to work out what you changed.
      And I was referring to : http://pastebin.com/ :)
      Thanks again
      Kactus

  • rleto577 / about 13 years ago * / 1

    I had no luck using the demo code with the duemilanove and the NSS library. So I ported the code to the MEGA board and my problems are solved, no more hang-ups ! As suspected, the NewSoftSerial library is causing the sketch to behave strangely and my level of expertise doesn’t allow me to delve into the library code to see what’s wrong with it. My guess is a problem with resources and/or interrupts. I added a copy of my code for your testing: >>>>>>>>>>>>>>>>>>>>>>>
    OOps, I appended my code here but the format looks awful. I have to find another way to add the code...

    • kactus / about 13 years ago / 1

      Hi rleto577
      Would you be able to post your code in pastebin? I'm been banging my head against the wall trying to get the canbus working with the mega, it always locks up on initialization. I've rewired the spi as per http://mcukits.com/2009/04/06/arduino-ethernet-shield-mega-hack/ but as far as I can see its using the avr io definitions that take into account the mega.
      I'll be bald by the end of the week at this rate ;)

  • rleto577 / about 13 years ago / 1

    After extensive testing, I found out that my microSD problem has nothing to do with the SPI configuration. In the following code from the can_shield_test.pde demo program, if I remove the else{...} section in the: if(Canbus.init(CANSPEED_500)) block, it works fine. Strange…??? So I suspect it has something to do with the NewSoftSerial object (nss). I searched the nss online and found similar lockup problems with the nss. I need to do more testing with the nss. Anyone experienced similar problems ?
    if(Canbus.init(CANSPEED_500)) /* Initialise MCP2515 CAN controller at the specified speed */
    {
    sLCD.print("CAN Init ok");
    } else
    {
    sLCD.print("Can't init CAN");
    }

    • DHP / about 13 years ago / 1

      One thing you might look at is the CS pin that is shared between the SD and MCP2515. In the demo it gets set high for the microSD but I don't see that it is ever set back low for the 2515 which is active low.

  • rleto577 / about 13 years ago * / 1

    I have a canbus_shield dated: 8/31/10 and noticed that D10 (SPI/SS) is used to select the MCP2515 via the CAN_CS line. This causes SPI bus problems when both the CANBUS and microSD are used in the same sketch, i.e., demo code. Any suggestions on how I can get both the microSD & MCP2515 working via the common SPI bus without bus issues ?

  • Pavel2 / about 13 years ago * / 1

    Hi all,
    I have same problem with using of this shield.
    Resistor 120R is fitted, but I still receive complete buffer with 0.
    I try to use Canbus v.1 and v.2 same result
    Thx for help
    But I didn't use original OBD-II connector because on tested car there is only CAN in engine area so I think that I will check correct conection there tomorrow because now is here night...

    • Pavel2 / about 13 years ago / 1

      So today I tried to use this shield together with Arduino Uno and was used with in Octavia 2 manufactured 2010 so it is OBDII ready car. I tried both versions of code v1 and v2 and both was not working. Do you have any idea what to test now. I will also test Lawicel CAN232 and if it will work so there will be some problem with cable, board or Arduino.
      Thank you for your your help with fixing it.

  • Member #202681 / about 13 years ago / 1

    Got it working with this Library / Sketch:
    http://code.google.com/p/skpang/downloads/detail?name=Canbus_v2.zip
    greetings Sunny

  • Member #202681 / about 13 years ago / 1

    Got anyone a working Arduino Library for this shield? I´ve downloaded the one from skpang, it says "CAN Init ok" but i didn´t get any message back. taking a deeper look, mcp2515_check_message() always returns false. Don´t know why it doesn´t return a message. I´m connected it to a 2010 Volkswagon OBDII.

  • TaYpworm / about 13 years ago * / 1

    I would like to network three Arduinos over CAN-bus. How can this be accomplished with this shield?

  • HangaS / about 13 years ago / 1
    • Power can supply to Arduino by sub-D via resettable fuse and reverse polarity protection.
      Does this mean that the Arduino can be powered by this shield from the +12V of the OBD interface? No external power needed?
      That's just awesome!
  • becker / about 13 years ago / 1

    The schematics show a 16MHz crystal.
    That is the most flexible clock rate for the MCP2515. The clock can be as low as 10MHz for 1Mbps CAN, but the receiver can do a much better sample with 16MHz.
    Internally the chip divides the input clock by two to get a symmetrical internal clock, and then uses these time period to look for incoming signal edges. With only 5 time periods, the chip takes a single sample 3 ticks after the bit period start e.g. 60% into the bit period. With 8 time periods it can take three samples and use the majority count.
    Higher clock rates allow finer-grained sampling, but this barely improves the error rate.
    A MCP2515 controller is very easy to utilize with a prototype shield. I run my MCP2515 implementation off of a timer output set to "count to zero". This gives a 8MHz clock and a 500Kbps maximum rate -- the highest standard speed for automotive use, but less than the max 1Mbps rate used industrial and lab equipment.
    If you are designing your own board, add in a jumper selectable 120 ohm terminator. With this board you could always solder it into the 4 pin header position, but that is inconvenient.
    You probably also want to provide an option to use the interrupt output. My software uses polling mode for regular operation, but still needs the interrupt to allow the system to go into low-power sleep mode.
    Finally, have you considered connecting to the ISP header? I think this gives the correct SPI pin wiring for most types of Arduino boards. The Chip Select and interrupt pin assignment will still vary, but those are easier to handle.

    • jwschmo / about 13 years ago / 1

      becker, good points, I think the shield that is provided is perfectly fine for the type of automotive applications it can be used for. The SPI issue is an easy fix by just using some jumper cables,(and setting up pins 10 through 13 as inputs) and SKpang's CAN code is spot on, its just the FAT16 library included that falls short.

  • Tempest2k8 / about 13 years ago / 1

    Setup a section in the Forum for CAN-BUS Shield. Copied some of the fixes & uploaded a working version of the JoyStick Demo.
    Forum Link

  • AnilD / about 13 years ago / 1

    Beginner Cry for Help!! - Got the UNO + CanBUS Sheild+OBD connector and sLCD
    Not planning on using the GPS function just yet..ONLY the CAN
    1. What software from SKPANG Sample Code do I load ? All of them or ...
    2. Where do I load them ? All in the Sketch Folder Do I just drag and drop the hold CANBUS folder into the Sketch Folder?
    3. Which File do I then compile/verify to be loaded into the UNO to kick things off?
    I'm currently awaiting Massimos book Getting started w Arduino but decided to jump ahead...

  • Member #128776 / about 13 years ago / 1

    It is possible baurate=1000Kbit/s ?
    I only find in the sample code(Canbus.h):
    "#define CANSPEED_125 7// CAN speed at 125 kbps"
    "#define CANSPEED_250 3// CAN speed at 250 kbps"
    "#define CANSPEED_500 1// CAN speed at 500 kbps"

    • DaveAK / about 13 years ago / 1

      The MCP2515 will do 1000kbps. You'll need to figure out the bit timing as shown in the datasheet if the code you have doesn't have it calculated for the speed you need.

      • sprawl / about 13 years ago / 1

        Simple - just add the line:
        #define CANSPEED_1000 0 // CAN speed at 1 Mbps

  • Tempest2k8 / about 13 years ago / 1

    Will PRT-09919 mate up to the LCD connector on this board?

  • MarcoCorrea / about 13 years ago / 1

    I found a very interesting link at SKPang's website to Marco Guardigli's blog.
    He told me he was able to read data like engine rpm and temperature from an Audi A6 but he couldn't get any data from different cars like VW Fox and Mercedes E270.
    Does anyone know something about this issue?

    • DaveAK / about 13 years ago / 1

      They may not use the CAN protocol for the OBD-II implementation. It's all dependent on manufacturer and year of manufacture.
      Check out the wikipedia link I posted above. You should be able to determine what protocol your vehicle uses by looking at the connections on the OBD-II plug.

  • kaipyroami / about 13 years ago / 1
  • DaveAK / about 13 years ago / 1

    The features list a "9-way sub-D standard OBDII connection cable". Is this included? Your pictures are usually pretty clear as to what you get and what you don't.

  • DaveAK / about 14 years ago / 1

    Have you guys considered a "Coming soon!" page? I have a PCB on it's way from BatchPCB to build my own shield. I would have saved myself all this effort if I knew you guys were on it. I have an MCP2515 Arduino Library that I'm working on, unless you want to post some code for that too? :D
    Is that a male or female sub-D?
    And a word of caution about OBD-II. It is my understanding, (and I could be wrong), that OBD-II is not necessarily CAN based until 2008 model vehicles, (in the US at least).

    • clever / about 14 years ago / 1

      CAN bus requires a termination resistor on both ends of the buss
      if you put an ohm meter across the D+ and D- pins, you should see the resistance of them (i forget the exact value)
      that will prove the presence of a can bus, but not how much the system actually provides over the interface (more might be on the other interfaces)

      • jwschmo / about 13 years ago / 1

        You shouldn't need a termination resistor if you are interfacing with a CAN bus that is already built, as they shouldn't make that linkage point an end point in the bus, also I believe its around 120 ohms resistance per end, and it is dependent on length of the cable and the impedance of the cable.

      • DaveAK / about 14 years ago / 1

        Got my limited knowledge from the wikiest of pedias:
        http://en.wikipedia.org/wiki/On-board_diagnostics#OBD-II_Signal_Protocols
        Still, my application isn't OBD-II and is specifically CAN. Just putting it out there as a word of caution for others.

  • Duke3k / about 14 years ago / 1

    Presumably the Arduino communicates to the shield via the SPI Interface pins.
    So Is there any sample Arduino code for this shield?
    This shield has a mini Joystick & Serial LCD pins - this would require Arduino code to use these yes? or is there Software already loaded on the board to use these devices?

  • CAB-10087 was specifically sourced for this shield.

  • ahmetatakan / about 14 years ago / 1

    it may compatible with CBL-10087 OBDII to DB9 Cable (products_id=10087)
    this products pins 2,3,5,9 are compatible with obdii cables pins
    is this true?

  • Member #572910 / about 10 years ago / 0

    Hello everyone, I just started using this CANBus shield but I'm having lots of trouble in using the demo code from the SK Pang Site. It doesn't compile and I can't find the reason why. I tried to use the canduinoV2 library but it doesn't compile either. It says that 'CAN' was not declared in this scope and the library can.h is included :/

    I just need to setup a simple network between two shields using two Arduinos UNO. Can anyone post or send/post a library and a simple Arduino sketch that works and allows to send a simple message and to receive it ? I would be very thankful. Thanks

    • Sounds like you don't have the library files nested properly in your Arduino files. The error you are getting with 'CAN' not being declared is usually due to the library files being in the wrong location.

      If you are still having trouble after that, please contact techsupport@sparkfun and they should be able to help you further.

Customer Reviews

4.7 out of 5

Based on 7 ratings:

Currently viewing all customer reviews.

1 of 1 found this helpful:

Best shield ever

We are using canbus shields for our industrial products, no problem so far. Worths every penny....

2 of 3 found this helpful:

Works very well, pin 9 selects SD card and pin 10 is CAN bus chip

This device works very well... Just be sure to define 'chipSelect' as pin 9 when using any sd card example code for this board. Also, the sd card and can-bus cannot be active simultaneously. Just be sure to switch back and forth between them via pins 9 and 10 when trying to access each device.

Fun easy to use shield

The CAN shield worked out really well for me! Was able to build a bus with a national instruments can interface within minuets! It sends and receives messages with easy to use software. The only thing I don't care for is the additional hardware for data logging and lcd display is not useful to me. it's a small complaint.

Exceeds expectations.

I'm using this to datalog can-bus messages on my 125Kbps Jeep Interior bus. I can easily log messages to serial and sdcard. Despite what another review said, you can use both can-bus and sdcard card together. Also the header pads behind the DB9 connector are helpful for bench testing. I'll post example code on irixbox.com if anyone is interested.

Great combo of transceiver + controller for Arduino

This product is great if you want to get started with CAN bus. The learning curve is kinda steep. I think this board has everything you need. Quality is great as usual. Haven't used the mini-joystick yet.

Great combo of transceiver + controller for Arduino

This product is great if you want to get started with CAN bus. The learning curve is kinda steep. I think this board has everything you need. Quality is great as usual. Haven't used the mini-joystick yet.

Goodie

Good build quality, too bad my car didn't have can bus, recalled wrongly, well it happens....