Now I understand that there are a few CAN implementations out there, but the more the merrier, right?

This one uses the MCP2515/MCP2551 chips like most of them do. It has a switchable CS pin so that you can use other SPI shields with it that might have hardwired D10 as CS. It has a switch to draw power from the CAN Bus if desired, if you wanted to add a WiFi or Bluetooth shield for example. And for newbies like me it's an entirely through hole design making it an easy DIY project.

I've also written a library that's a complete implementation of the MCP2515 SPI command set. It doesn't yet have any wrappers for filters or masks, but these are all accessible through the read and write commands. I have a simple Init function that takes a bus speed and clock frequency and calculates out all the necessary bit timing parameters, which makes it pretty straightforward to setup and use.

Now all I need is something to connect it to ...... (I actually have a need for this in another project that has been temporarily sidelined.)

Developing against an ECU is no fun if you have to sit in the garage with your laptop while you're coding! I've spent way too long out in the driveway with a lappie and a long extension cable. Much nicer to be able to sit at your bench and twiddle the knobs to simulate different behavior.--JonVehicle Telemetry Platform: www.practicalarduino.com/projects/vehicle-telemetry-platform

It's actually going to be used to interface to an Electric Vehicle controller, so no OBD-II needed. Of course, it's a proprietry system that I've got to hack, so we'll see how that goes. Should be fun though.

http://ww1.microchip.com/downloads/en/DeviceDoc/21801e.pdf http://en.wikipedia.org/wiki/CAN_bus The MCP2515 Library files also contain important information

This sketch shows the most basic of steps to send and receive CAN messages.

It has been tested with a Microchip MCP2515DM-BM Demo Board, which consists of two identical boards that pass messages between each other. There is a connector available so that another CAN device can be connected to the bus. Using this I was able to read the messages passed between the two boards, and also introduce my own messages to the bus, which are then displayed by the software supplied with the demo kit.

NOTE!!! If you use this sketch to test on a live system I suggest that you comment out the send messages lines unless you are certain that they will have no detrimental effect! */

// CAN message frame (actually just the parts that are exposed by the MCP2515 RX/TX buffers)Frame message;

void loop() {

message.id = 0;

// This implementation utilizes the MCP2515 INT pin to flag received messages or other events if(CAN.Interrupt()) { // determine which interrupt flags have been set byte interruptFlags = CAN.Read(CANINTF);

// Send out a return message for each one received // Simply increment message id and data bytes to show proper transmission // Note: Please see explanation at top of sketch. You might want to comment this out! message.id++; for(i=0;i<message.dlc;i++) { message.data[i]++; } CAN.LoadBuffer(TXB0, message); CAN.SendBuffer(TXB0); }}

The above is the latest revision of my code. I've added in an AutoBaud rate feature that works, but is a little clunky code wise. It requires that there are at least two active nodes on the bus, (not including the one you're using), and they must send messages at least every half second. It starts at a baud rate of 5kbps and goes up in increments of 5kbps until it reaches 1000kbps, (max rate for CAN V2.0B). This means that it could take nearly two minutes to detect the baud rate being used by the bus.

It does have a simple to use initialization routine though that simply requires a baud rate, (zero for AutoBaud), and a clock frequency, (frequency of MCP2515 oscillator, not Arduino). It then calculates out the proper bit timing for you.

Any comments or suggestions on the code would be welcome. Right now I'm waiting for a version 1.1 PCB, but I have the v1.0 shield pictured up and running just fine connected to SepEx motor controller at 125kbps. It happily streams data all day long. If the code doesn't work for you I'd be interested to know so that I can make it more universal.

From what I can gather from a quick glance at the data sheet and your code the filter works on the first two data bytes of a standard frame, not the message ID. I think you're trying to filter on the message ID, but you're using a standard frame, so this won't work.

If you use an extended frame then the mask applies to the full 29 bit ID field.

The mask you have requires an exact match between the message ID and the filter - i.e. only one specific message ID will be received. I think your test code is correct, (i.e. you're right and the message should be rejected), but again, it comes down to using a standard ID instead of an extended ID.

My prototype is a small (2,5 x 5 cm) shield for the arduino, which just fits the mcp2515 and a can tranceiver (both can be sampled from TI afair). All is done with smd components and pinheaders through hole, as i think thats easiest. The shield's size makes all the analog and half of the digital i/o pins available when the shield is on.