Search by Tags

How to use CAN library

 

Compare with Revision




Subscribe for this article updates

CAN (controller area network) is a multi-master broadcast serial bus standard communication. CAN is a message-based protocol, designed specifically for automotive to allow communication between devices within a vehicle without a host computer.

Use Cases:

  • Automotive
  • Aerospace
  • Industrial automation
  • Medical equipment
  • and much more.

Setting up CAN on Colibri Evaluation Board

Take two Colibri Evaluation Board V3.1 and connect using CAN bus at CAN connector (X2).

To make CAN bus

  • Take two different colored wires (for example Red and Green) of length around 40 cm and twist them.
  • Terminate both ends of a twisted pair with 120 Ohm resistor.
  • Solder Red and Green wire to pin 2 and pin 7 of Female D-Type connectors respectively in both sides.
  • Connect Female D-Type CAN connector (X2) to respective D-Type CAN connector (X2) on Colibri Evaluation boards.

Precautions

  • On Evaluation Board V3.1, SPI Lines SODIMM_73 (CAN_INT), SODIMM_86 (SSP_FRM), SODIMM_88 (SSP_SCLK), SODIMM_90 (SSP_RXD), SODIMM_92 (SSP_TXD) are directly connected with MCP2515 CAN controller. So you must ensure that jumpers are fixed and these lines are not used for other purposes.
  • To use the CAN-Lib on a PXA310 you have to connect X12 pin 41 with X12 pin 31 on the Colibri Evaluation Board 3.0.
  • You must run receive at first device then before starting the transmit in another device.

Demo application

  1. Setup the development environment for Colibri module on Windows CE by following this guide.
  2. Download the free CAN Demo code and library from here.
  3. Build and Deploy project on Colibri device.
  4. This program uses ISR (CANLibMCP2515ISRDll.dll), copy it into Windows directory of Colibri device.
  5. Repeat the step 3 and 4 for second Colibri device.
  6. Run the application on both devices and follow the steps in the console window thereafter.

Output

After executing the .exe file you will see the following window.


  • CanMenu

    CanMenu

After selecting Baudrate Press 'R' for Receive.


  • CanReceive

    CanReceive

Enter "T" will transmit Demo message.


  • CanTransmit

    CanTransmit

Output of CAN analyser showing Received and Transmit message.For more information on CANdo analyser click here


  • CAN

    CAN