CAN-BUS Shield

From ELECFREAKS-WIKI
Jump to: navigation, search

Introduction

TheCAN-BUSis a common industrial bus because of its long travel distance, medium communication speed and high reliability. It is commonly found on modern machine tools and as an automotive diagnostic bus. This CAN-BUS Shield adopts MCP2515 CAN Bus controller with SPI interface and MCP2551 CAN transceiver to give your Arduino/Seeeduino CAN-BUS capibility. With an OBD-II converter cable added on and the OBD-II library imported, you are ready to build an onboard diagnostic device or data logger.

Model: EF02037

CAN-USB-F.jpg Asd.jpg CAN-USB-D.jpg

Feature

  • Implements CAN V2.0B at up to 1 Mb/s
  • SPI Interface up to 10 MHz
  • Ariduino/ Freaduino Completely compatible
  • Standard (11 bit) and extended (29 bit) data and remote frames
  • Industrial standard 9 pin sub-D connector
  • Two receive buffers with prioritized message storage
  • Operating voltage: DC5-12V
  • Size: 78mmx53.5m


Application

  • Industrial control
  • Car control field


Electronic Properties

CAN-USB-G.jpg

Interface Description

CAN-USB-H.jpg


CAN-USB-I.jpg

Specification

Module Description

CAN-USB-J.jpg

Dimensions

CAN-USB-K.jpg

Step 1

Get Tools Prepared:

  • UNO *2
  • CAN-BUS_Shield *2
  • USB *1
  • Adapter *1
  • Jumper Wire *2

Step 2

First, the CAN-BUS Shield into the UNO, then plug wiring diagram press.

CAN-USB-L.jpg


Step 3

1. Download the CAN-BUS Source code and release it in the libraries file in the Arduino-1.0 program.: ..\arduino-1.0\libraries.

2. Open the Arduino-1.0, and you will find two examples: "receive" and "send". Open both of them, you should get two programming windows now

CAN-USB-M.jpg


3. Upload two examples to two boards separately. Choose the board via the path: Tools -->Serial Port-->COMX. Note down which board is assigned as a "send" node and which board is assigned as a "receive" node.

4. Open the "Serial Monitor" on the "receive" COM, you will get message sent from the "send" node. Here we have the preset message "0 1 2 3 4 5 6 7" showing in the following picture


CAN-USB-N.jpg


Note: Note: Make clear of the transmit/receive modules when burning codes.



Programming

Includes important code snippet. Demo code like : <syntaxhighlight lang="php">

Demo code { // demo: CAN-BUS Shield, receive data

  1. include <mcp_can.h>
  2. include <SPI.h>

unsigned char Flag_Recv = 0; unsigned char len = 0; unsigned char buf[8]; char str[20];

void setup() {

 CAN.begin(CAN_500KBPS);                       // init can bus : baudrate = 500k
 attachInterrupt(0, MCP2515_ISR, FALLING);     // start interrupt
 Serial.begin(115200);

}

void MCP2515_ISR() {

   Flag_Recv = 1;

}

void loop() {

   if(Flag_Recv)                           // check if get data
   {
     Flag_Recv = 0;                        // clear flag
     CAN.readMsgBuf(&len, buf);            // read data,  len: data length, buf: data buf
     Serial.println("CAN_BUS GET DATA!");
     Serial.print("data len = ");
     Serial.println(len);
     
     for(int i = 0; i<len; i++)            // print the data
     {
       Serial.print(buf[i]);Serial.print("\t");
     }
     Serial.println();
   }

}

/*********************************************************************************************************

 END FILE
                                                                                                                                                                                                                  • /

}

</syntaxhighlight>

Example

The projects and application examples.

Version Tracker

Revision Descriptions Release
v0.9b Initial public release date

Bug Tracker

Bug Tracker is the place you can publish any bugs you think you might have found during use. Please write down what you have to say, your answers will help us improve our products.

Additional Idea

The Additional Idea is the place to write your project ideas about this product, or other usages you've found. Or you can write them on Projects page.

Resources

How to buy

Click here to buy:

http://www.elecfreaks.com/estore/can-bus-shield.html

See Also

Other related products and resources.

Licensing

This documentation is licensed under the Creative Commons Attribution-ShareAlike License 3.0 Source code and libraries are licensed under GPL/LGPL, see source code files for details.

External Links

Links to external webpages which provide more application ideas, documents/datasheet or software libraries