CAN Bus Messages

I am completely new to Arduino and wanted some help and guidance on a CANBUS project I want to do. Any help and advice would be very much appreciated.

I want to connect to CAN-H and CAN-L wires of my car that is already has the correct 60 ohm resistance and I want to filter and listen for certain messages/frames (whatever it is called). I want to be listening in a mode that doesn’t send any data back so the car doesn’t detect it as a rogue node. Once a message/frame matching my filter is received I want to somehow convert that to a equivalent message to send to a completely different CANBUS. So basically the listening CANBUS and the transmitting CANBUS are two different networks not connected together.

I’ve read a lot of mention about CAN shield and Arduino. There seems to be a few different models of Arduino. Will a Arduino UNO work? how does CAN Shield and Arduino link up?

Any suggestions or guidance will be much appreciated.

Thanks

What data rate (baud) is the CAN bus, 500 kbps or something else?
Do you have a CAN bus analyser?
Do you have an oscilloscope?

I suspect that an Uno with two CAN bus adaptors such as the MCP2515 is going to be too slow for your application.
Perhaps investigate the Due or Teensy as faster alternatives.

The DUE embeddes 2 CANs. All you have to do is adding 3.3V CAN transceivers and upload the CAN library for the DUE from collin80.

Note that for short cables (length < 2 meters) and for first tests, you don’t even need transceivers (see Application Note 2921 from Siemens).

I've had my fair share of CAN-BUS and arduino already and here's my 2 cents:

I'm using arduino nano and MCP2515's from ebay. Yes, it is fast enough for two CAN-Transceivers and this is the library I am using: GitHub - coryjfowler/MCP_CAN_lib: MCP_CAN Library

You need to find out the speed of the CAN-Bus you are trying to listen to. What year/make/model is your car? I might give you a headstart for what I know.

Cars don't notice rogue nodes even if you send weird ID's and bytes that your car does not understand.

Causing Errors would be shorting High or Low to Ground or 12V or disconnecting an ECU entirely.

Termination-Resistors are only needed if you create your own CAN-Network. The MCP2515 (which you can find on the internet) has these included if you connect the two Pins at J1.

mikb55:
What data rate (baud) is the CAN bus, 500 kbps or something else?
Do you have a CAN bus analyser?
Do you have an oscilloscope?

I suspect that an Uno with two CAN bus adaptors such as the MCP2515 is going to be too slow for your application.
Perhaps investigate the Due or Teensy as faster alternatives.

data rate of the bus is 500kbps
I have a CAN bus logger and no oscilloscope.

So a Teensy is faster than an Uno?

ard_newbie:
The DUE embeddes 2 CANs. All you have to do is adding 3.3V CAN transceivers and upload the CAN library for the DUE from collin80.

This sounds interesting. I will read up on this. How does adding the transeivers work? Is it something like a CAN shield?

john2k:
So a Teensy is faster than an Uno?

Yes, Teensy and the Due use 32bit ARM Cortex-M processors and provide a lot more computational power than an 8bit Arduino.

john2k:
This sounds interesting. I will read up on this. How does adding the transceivers work? Is it something like a CAN shield?

The transceiver is an “analog” component. It implements the physical layer, so converts the microcontroller pin signals to the voltage required for the cables. For a standard <=1Mbit CAN you can use a transceiver like the MCP2551 from Microchip. There are plenty of similar devices from other manufacturer. The advantage of the older versions is that you can get big old packages even DIPs. You just connect the device according to the datasheet and you are done. No additional programming.

https://www.microchip.com/wwwproducts/en/MCP2551

Can transceivers can be found on breakout boards like this one:

And, as I said in my previous reply, you don't need transceivers for relatively short cables (I tried, it works fine). Replace +5V by +3.3V in the Siemens application note 2921, a diode and a resistor and you are done.

Edit : You can find a DUE for $12

TheLexoPlexx:
I've had my fair share of CAN-BUS and arduino already and here's my 2 cents:

I'm using arduino nano and MCP2515's from ebay. Yes, it is fast enough for two CAN-Transceivers and this is the library I am using: GitHub - coryjfowler/MCP_CAN_lib: MCP_CAN Library

The CAN-Bus speed is 500k. Will the UNO work? The UNO is much cheaper than getting a Due or Teensy which seem to be more costly. I'm completely new to this. How exactly would I go about it?

How exactly does the Uno and rest of the Ardruinos work? When powered up does it just continously run a program etc? it's not like computer where you need to set a script to run etc?

I use a Freemantics ESP32 based CAN bus device to do the CAN bus read thing and then use a ESP32 to read the what not i want being sent from the Freemantics. If you go the Freemantics route then do order the right angle adapter along with the Freemantics order. There are other completed CAN BUS modules for the Arduino uConstrollers.

I went this route cause, in the end it was far cheaper to get a nicely boxed device that saved me quite a number of hours trying to get at the info I wanted.

Could I use a Ardruino Mega instead of a UNO and instead of a Teensy or something more high end? Where do I begin? Some guidance would be much appreciated.

I want to connect to a existing cars can bus and filter and listen for certain CAN Messages and I have created a seperate CANBUS which is just two wires with terminating resistors going to a speedo cluster. I've drawn a basic exampe of what i'm trying to achieve in the picture below.

Just don't know where to begin. All I have currently is a standalone easy to use CANBUS logger which lets me record and playback messages on a can bus etc.

Go for the Arduino Due. It has the same price as the Arduino Mega board, and it has two build in CAN peripherals. So, you only need two CAN transceivers.

The Arduino Due is totally overpowered for what you want to do initially. It has a modern 32bit ARM processor and loads of peripherals. So, you can waste memory, processor cycles to your hearts content.

If you want to develop an application that is sold in the millions and needs to be cheap to produce, you need to think about saving every penny. But this cost saving only works for the final device not for the development board.

The basic problem with a 500 kbps bus is that messages can arrive at intervals of less than a millisecond whereas the uno/mega and MCP2515 combination requires about 1.6 milliseconds to read each message.

However, you may (no guarantee) be able to configure filters within the MCP2515 to only receive specific messages. Whether or not this is possible depends on how many IDs you need to monitor and whether there is any commonality in the bit patterns. If you have more than 6 IDs this is likely to be a complex process. If you struggle with binary arithmetic then you will struggle with filters.

The advantage of using something faster than a uno/mega and MCP2515 combination is that you can do your own filtering inside the Arduino which is easier and offers more flexibility than trying to do it inside the MCP2515.

mikb55:
The basic problem with a 500 kbps bus is that messages can arrive at intervals of less than a millisecond whereas the uno/mega and MCP2515 combination requires about 1.6 milliseconds to read each message.

However, you may (no guarantee) be able to configure filters within the MCP2515 to only receive specific messages. Whether or not this is possible depends on how many IDs you need to monitor and whether there is any commonality in the bit patterns. If you have more than 6 IDs this is likely to be a complex process. If you struggle with binary arithmetic then you will struggle with filters.

The advantage of using something faster than a uno/mega and MCP2515 combination is that you can do your own filtering inside the Arduino which is easier and offers more flexibility that trying to do it inside the MCP2515.

That makes a lot of sense. Thank you. I've just been reading up on the Due and looking on eBay. I read something about the Due being end of life or something? On eBay most of the Due's seem to be chinese replica's. I found 1 genuine. How reliable is the Due? What about the chinese replicas, do they work with the Arduino IDE and stuff? if the Due was lets say running 24/7 do they burn out or damage?

No problem with DUE clones, I use them on a daily base.

john2k:
That makes a lot of sense. Thank you. I've just been reading up on the Due and looking on eBay. I read something about the Due being end of life or something? On eBay most of the Due's seem to be chinese replica's. I found 1 genuine. How reliable is the Due? What about the chinese replicas, do they work with the Arduino IDE and stuff? if the Due was lets say running 24/7 do they burn out or damage?

The company behind Arduino doesn't seem to have a long term strategy for any of its products, except perhaps the Uno as that is what the education market buys because it's the cheapest. Picking a more modern 'supported' Arduino board is no guarantee that it'll still be available from the Arduino store 18 months from now.

Microchip, the manufacturer of the microcontroller used in the Due is still advertising it as "in production", which means that supplies aren't going to run out any time soon. Due clones are still readily available because it fills a niche that other boards don't fulfill. If you are worried about supply then buy a bunch. The clones are only $US 14 each including shipping from China.

Reliability wise for the clones, If you don't cycle them through temperature extremes or shake them to bits then expect a life of 3+ years just like any other piece of Chinese 'consumer grade' electronics.

Thank you. I've ordered a chinese Due which seem to be really cheap. Funny thing is that the pics of the item show the back of the board with writing saying made in italy and the arduino.cc website LOL. Below are a few pics of the item I ordered

@ard_newbie You mention that for short cable lengths I wont need transceivers . I plan to place the arduino within 1meter of both CAN BUS networks. Is it just for testing that I dont need the transceivers or can final installation run without transceivers? are there any risks or limitations? Is it safer to just have transceivers? What exactly is the job of the transceivers if its not needed in this application? what creates the CAN signals?

It's all right for your tests, but a better solution is obviously the one with transceivers (3.3V Only !)

ard_newbie:
https://www.mikrocontroller.net/attachment/28831/siemens_AP2921.pdf

It's all right for your tests, but a better solution is obviously the one with transceivers (3.3V Only !)

Do you mean a better solution is to get 3.3V transceivers and put it on the DUE that i bought?

Will the following 3.3V transceivers work for the DUE application? where do I connect it to on the DUE?