Unable to make CAN communication work

Hello,

I have following setup: UNO -> CAN Shield -> CAN BUS -> CAN Shield -> UNO Can shield is using MCP2515 chip and it comunicates via SPI with Arduino board. It's this one http://www.amazon.co.uk/MCP2515-Module-TJA1050-receiver-controller/dp/B00SKGHD2E CAN BUS is in fact just two wires.

I've used some libraries found on Google (mostly some libraries from github). E.g. this one: https://github.com/reeedstudio/CAN_BUS_Shield and some others, but i guess it was just older versions of this one. I've run examples from libraries. On first UNO board it was send example, on second it was receive (with intertupt, and also with check). But none of them worked.

Initialization went OK, even in debug mode there was no error. I've checkd CAN BUS on osciloscope. It seems that on CAN BUS is some traffic. But it was just zeroes with stuffed ones, so no useful data and it was sent repeatedly as fast as it was possible. As far as i know this shoudn't be happening on CAN BUS. But still, receiving part should at least receive message from ID 0 with zeroes and write it to serial, which wasn't happening.

What can I do to make this work, I have no idea what steps should i make next. It just doesn't work and I don't even know why. Any help apreciated, thanks.

But it was just zeroes with stuffed ones, so no useful data

The first part of that statement may be true (I have no idea what you mean by "stuffed ones"), but the second part is completely false.

Bit stuffing for time synchronization.

I have the same problem with this kind of module, could be only can receiver?

Hi guys, I changed the crystal to a 16MHz one and the board worked fine.

Regards,

Amauri

Hello! I also have that Can-Bus board and an Arduino Pro Mini 5v 16Mhz.. I canĀ“t make it work... To which pins did you connected the CAN-Bus board? Can you help me? Should i switch the crystal on the Can board to 16Mhz? Plaese Help! Thanks!!

Hi all,

I stumbled across this thread while trying to get my MCP2515 CAN module to work and it helped me solve my problem so I thought I'd follow up.

amaurial: Hi guys, I changed the crystal to a 16MHz one and the board worked fine.

The above post made me realise that my MCP2515 module has an 8MHz crystal on board, but most libraries are configured for boards with 16MHz crystals.

Rather than changing the crystal as amaurial did, I used a fantastic bit timing calculator (http://www.kvaser.com/en/support/bit-timing-calculator.html) to calculate new MCP2515 register values based on an 8MHz clock rather than a 16MHz clock.

I'm using the Seeed Studio CAN library, so then it was just a matter of adding the the new register values to mcp_can_dfs.h to get it all working.

Since then I've come across a fork of the original library that includes support for 8MHz based MCP2515 boards (https://github.com/Flori1989/MCP2515_lib). I haven't tried it but it might be helpful to others.

Cheers,

Rob

robwerner: Hi all,

I stumbled across this thread while trying to get my MCP2515 CAN module to work and it helped me solve my problem so I thought I'd follow up.

The above post made me realise that my MCP2515 module has an 8MHz crystal on board, but most libraries are configured for boards with 16MHz crystals.

Rather than changing the crystal as amaurial did, I used a fantastic bit timing calculator (http://www.kvaser.com/en/support/bit-timing-calculator.html) to calculate new MCP2515 register values based on an 8MHz clock rather than a 16MHz clock.

I'm using the Seeed Studio CAN library, so then it was just a matter of adding the the new register values to mcp_can_dfs.h to get it all working.

Since then I've come across a fork of the original library that includes support for 8MHz based MCP2515 boards (https://github.com/Flori1989/MCP2515_lib). I haven't tried it but it might be helpful to others.

Cheers,

Rob

This is it. It works!!! Thanks!

Thanks robwerner! Thanks mariusrak!

It works!

I had just change CAN0.begin(CAN_500KBPS); for CAN0.begin(CAN_500KBPS,MCP_8MHz); using the library that robwerner posted.

Thanks guys, now I can proceed to make the Telemetry of our FormulaSAE car!

I'm also unable to get this module to work. I have switched the crystal crom 8Mhz to a 16Mhz one (http://www.maplin.co.uk/p/16mhz-low-profile-crystal-rr89w).

I'm connecting my module to the CAN lines in the OBD2 ports, using the 500KBPS speed as an OBD2 bluetooth adapter I used suggested this was the speed it was using.

I'm using pin 10 for CS. I've tried Corey's libraries to no success, and now attempting to use seeedstudio's. from what I can tell pin 2 for the interrupt never seems to go low to signal CAN data to be read? Any thoughts?

hi,

I am trying to read the buttons pressed on steering wheel remote control in Volkswagen Vento. The remote messages are sent over CAN bus in the car and I want to pass this messages to after market stereo system. I am having Arduino board interfaced with MCP2515. CAN messages are being transmitted @ 100KBPS rate. When I tried connecting CANalyzer I am able to see the stream of messages that are going on the bus. But I am not able to see the same on Serial Port. I am using CAN_BUS_shield library for MCP arduino right now.

We used the library given here (https://github.com/Flori1989/MCP2515_lib),and made no changes to the example code, we used a CAN module with a 8MHz clock and set the speed to 500kbps, and on the CAN USB we set the speed to 250kbps, and it worked perfectly.

Hello people good night. I'm with this Mcp2515 module with the 8Mhz crystal, but I'm not succeeding to get communication with the hub of a Toyota Corolla 2009. I'm using the "READ" example from the library that colleague sent above from Flori1969 Can. I have already included the CAN_8MHz as quoted, but I did not succeed either. Including the CAN_8MHz command, it says that the variable was not declared. After running the sketch on the mega arduino 2560, I open the serial monitor and the only thing that appears is the texts and the Ids are displaying 0 as value. Has anyone managed to make it work that can give us their code? Txs

I've also got the same shield with MCP2515 and TJA1050 transceiver, with 8MHz crystal. I'm also not able to read any messages on the CAN bus of my Peugeot 207. The arduino Uno does succesfully connect to the MCP2515, but I just don't get any messages via serial.

I have set the 8MHz parameter..

eliasfsantos:
Thanks robwerner!
Thanks mariusrak!

It works!

I had just change CAN0.begin(CAN_500KBPS); for CAN0.begin(CAN_500KBPS,MCP_8MHz); using the library that robwerner posted.

Thanks guys, now I can proceed to make the Telemetry of our FormulaSAE car!

THANK YOU! This (adding the MCP_8MHz) solved my issue.

USE 5V!

I spent several hours trying all the various libraries and different boards. I monitored the CAN BUS on an oscilloscope and had activity but nothing proper. I got loop back messages just fine - the reason is... there are two chips on the board.

the MCP2515 runs from 2.8V to whatever.. the TJA1050 runs from 4.75V to 5.25V - not immediately clear and incredibly frustrating when it sporadically reads CAN messages, but never sends them

Use 5V, USE 5V!!!!!

(also use the correct speed as indicated already in this thread)

Dan

Having some trouble here. Maybe you guys can help. Arduino ProMini MCP2515 (8MHz board, w/TJA1050 transceiver) Using 5V switched to CAN0.begin(CAN_500KBPS,MCP_8MHz);

My goal is to connect this to the Canbus in my truck as another OBD module and give it an address like 0x7ef that TorquePro can access via an ELM327 bluetooth adapter to read PIDs unavailable from the existing ECU (oil pressure, temperature etc) I tried the "mechanic" code with the specified library and kept getting an init error. I think it's set up for 16MHz. So I've got the receive example from the MCP_CAN library. It compiles and writes, but when I try to connect it to TorquePro it just keeps saying "Not connected to ECU"

Am I missing something? I'd appreciate a little help. Thanks.

Go git fixed at least partially. The SeeedStudio newer library and their example code does work. It's just Torque being finicky about when it sees an "ECU".

Turn out it wasn't Torque. When editing the example, I changed 0x7E8 to 7E8. Of course it didn't work. With that correction, Torque connects and sees an "ECU" and proceeds normally. Works fantastic.