Car dashbord communication with MCP 2515

HELLO from Portugal

After reading many topics here, I still have a problem that has been reported several times but that is not being solved in my case.

I am developing a device to communicate with car dashboards in order to do some tests after repairs that are made. Like a car signal simulador to test the dashboard.

My equipment:

UNO+WiFi-R3-AT328-ESP8266-32MB-CH340G for PC conection

MCP 2515 with 8MHZ for CAN BUS interaction

These modules are connected in the usual way:

VCC – 5V from Arduino

GND – GND from Arduino

CS – D10 from Arduino

SO - D12 from Arduino

SI - D11 from Arduino

SCLK - D13 from Arduino

INT - D2 from Arduino

Without jumper on MPC2515

The dashboard is from a FIAT Punto (works at 500kb/s), is powered by a external 12v power supply and is monitored by an oscilloscope. So I am sure there is a signal at CAN low and CAN high after the key contact (+15).

These two CAN signals appear coherent and arrive at the MCP2515 module.

I installed several libraries, tested several files to read and write in CAN protocole but nothing worked.

I even installed a program called CANHacker, following all the requested steps to interact that with the MCP module… but nothing works.

I'm starting to question if the MPC2515 is not damaged. I tested the connection cables between modules and the connections on Pin…

In order to start at the right way, could anyone help with an up-to-date library and program that you know that works in order to troubleshooting where is the error?

I promise to put pictures of each step tried and explanations of what was done in order to be a kind of tutorial for those who have the same type of problem.

Thanks in advance.

Why not begin now?

Welcome to the forum.

To test your CAN module you can:

  • configure the CAN settings with a test sketch
  • send one CAN message without connecting to a CAN bus

This will cause the CAN module to repeat the message over and over again because no node on the bus will acknowledge the message. This will give you time to look at the signal with your oscilloscope. You should see a nice differential signal with the same bit timing as your car.

Check to see if you have a 8 or 16MHz crystal on the MCP2515 board and do a loopback test to prove that the MCP2515 SPI communication to the Arduino works.

Thanks for the quick answers!
01 _ About the circuit:


A) this is the FIAT Punto Dashboard
B) this is my UNO
C) this is my MCP2515 with osciloscope probes to test it.
D) this is the signal when the dashboard is not powered.
E) this is the signal when i power the dashboard in key contact (+15)

02 _ About the crystals:


A) MCP2515 - it is a 8MHz with no doubt

B) MEGA328P - I think the ECS 160 EX crystal is to work with ESP and the other one that works with MEGA has no marking. I bought it as a 16MHz

C) in the dashboard, near the TJA1054A transceiver there is a crystal with a different marking of 8 and 16 MHz. Could this be a problem?

Next will test my CAN at put the results.

So I follow the link to that code
CAN_loopback.ino

I put some annotations in the code to verify that this is what has to be done so that others with the same problem will also notice.
If there are other changes to be made for this specific case, please identify them.

to download mcp_can.h

to download SPI.h

I downloaded both libraries and didn't make any changes to them.
Is it necessary to adjust any lines of code in them?

Now I wil test the sketch.

I ran the can loop procedure and I'll leave all the steps behind so I can help other people understand the procedure.

To check if MCP2515 is ok.

by steps:
1_ I copied the code text to the arduino software.
2_ I made the changes only in the code that I marked (16 for 8MHZ).
3_ I loaded the sketch onto my arduino with the USB cable on COM3 and with keys 3 and 4 turned ON to establish communication between the USB and ATMEGA.
4_ the sketch was successfully loaded onto the board.
5_ with the oscilloscope connected to the CANL and CANH ports, I see a different signal than when the board is off without the message. I don't know if these are the expected values ​​but it displays these values ​​from the image.
6_ with the serial monitor open, I see the following message in a loop:

So the message loops!

it concluded that the UNO, the MCP2515 board and the connection cables are ok or this test is not enough??

If everything is ok, what would be the next step to receive CAN communication coming out of the dashboard through the arduino??

thanks in advance!

Try the CAN_receive.ino and set the 8 MHz option. Make sure there is a ground wire linking the dashboard to the MCP2515 module.
If you get nothing try swapping the High and Low wires.
If that doesn't work then use the oscilloscope to measure the width of a single bit and use that to calculate the actual baud rate.

So I followed the recommendation and:

1_ copied the sketch coryjfowler Update CAN_receive.ino

2_ according to the image, I went back to following the same steps in the code change.

3_ connected the GND of the source that supply the dashboard in connection with the arduino that supply the MCP. So the GNDs are all connected.

4_ loaded the program to UNO with the same keys turned on (3 & 4) All ok with the loading.

5_ I turned on the power supply and the oscilloscope started to detect CAN communication measured on the MCP board.

6_ I opened the "serial monitor" with 115200baud, just like what was written on the sketch. The result is this (see the image): no communication appears.

7_ changed the CAN L & CAN H cables but it stayed the same. I am sure that the cables are right connected because I have the dashboard wireframe and the pin function.

8_ seeing the oscilloscope, I check the data I send in the image. It may not be 100% strict. I would like to know how to calculate the baud to confirm that 115200 value. If the measure of a single bit is the same in both CAN (High and Low), I think it's 4,5V = VPP??

9_ if the crystal in dashboard has not the same value, why we use 8MHZ?

10_ I read that this dashboard follows the FIAT CAN B protocol.
CAN B is a low speed protocol (125Kbps).
The signal follows the same pattern as the signal I get from the oscilloscope as you can see in the link:

Do I have to change the communication speed where it says 500kbps? Or elsewhere?

thanks in advance

Please follow mikb55 advice and measure the CAN bitrate with your oscilloscope. Pick the narrowest bit. Measure the time and take the inverse to get the bitrate. e.g.,

20 µs -> 20 / 1,000,000 -> 0.00002 s -> 1bit / 0.00002 s = 50,000 kbit/s

Reply #5 E looks like 50-60 kbits/s CAN. It is hard to tell from the picture and the resolution.
Reply #10 looks like 50 kbits/s CAN.

A 16MHz crystal is the only one that allows all CAN standard baudrates to be created by the MCP2515 (and a few in between). The 8MHz allows all CAN standard baudrates up to 500kbits/s to be created.

But my question about the crystals is:
in post #6 I published a photo with all the crystals of the 3 devices.
they are not all the same value. Why not choose the crystal from dashboard (5MHZ) as the default value instead the crystal of MCP (8MHZ) ??

about measuring the CAN bitrate:


in fact i have a network with 50kbps because the value of a unit is 20µs.

So what should be changed in the code besides CAN 500kbps - 50kbps ??
The baudrate changes to??

thanks in advance

The dashboard CAN controller creates the CAN bitrate from the 5MHz crystal. This is done by the internal hardware and you do not need to worry about it. Only the 50kbits/s you measured are important.
Your MCP2515 needs to use 50kbits/s. To configure the MCP2515 correctly you will need to tell the library the frequency of the crystal. If you tell the library the wrong frequency the bitrate will be wrong. e.g., 16MHz vs 8MHz will cause 100kbits/s instead of the 50kbits/s.

The serial baudrate is independent from the CAN bitrate.

Sounds promising. Can you receive CAN messages now?

I understand but: if the dashboard crystal is the one that sends the message, and if the message is sent by a 5MHZ crystal at 50Kbps, how is the MCP crystal at 8MHZ also configured to read at 50Kbps?
Do you recommend any article that better explains this issue of frequencies versus transmission speed?

The crystal serves to receive and transmit right? So it could be transmiting messages at the same speed but with different frequency rates?

I already configured the code of the CAN_receive file and I leave here the comments of what I changed.

so what should i change in the mcp_can.h library?

in SPI.h it is not necessary to change anything?

(I only tested the sketch with changing the file, without changing the libraries and I couldn't see any communication on the serial monitor).

CAN has a specified way to create the bit timing. You could read the MCP2515 datasheet to get all the details. Here is one example. 8MHz to 50kbits/s

  • MCP2515 divides the clock by 2 internally ( cannot be changed ) -> 4MHz
  • MCP2515 divides the clock by 4 ( user choice in CNF1 register ) -> 1MHz
  • 1MHz creates a 1µs Time Quanta ( that is what the CAN specification calls them )
  • take 20 of these time quanta ( user choice CNF2 and CNF3 register ) to get 20µs
  • 20µs creates 50kbits/s CAN bitrate

Yes, with CAN the bitrate is fixed.

Please do not post code as images. Use code tags and copy the code from the IDE.

When you click on this icon </> you get.

```
type or paste code here
```

thanks Klaus_k

I just put the code in an image to make it easier to mark what I changed from the original code.

So if everithing is ok, where is the problem of my cofiguration?

What needs to be changed in libraries?

I've already scanned the library and I can't find references to 16MHZ or speed that have to be swapped.
Does anyone have any idea what might be wrong here? Anyone recommend another type of test to check the equipment?

Or the problem could be the lack of resistance in the two modules? I only have two modules to communicate and none has resistance. Should I add the jumper on the MCP2515 and put another equal resistance on the dashboard terminals?
Thanks in advance

Check to see if pin 4 on the TJA1050 chip has a signal that follows the CAN bus signal. If not then the transceiver Rx may be broken.

Check to see if pin 2 on the MCP2515 has the same signal as pin 4 on the TJA1050. If not then there may be a soldering problem.

(The chips are aligned in opposite directions, hence the pin numbering looks strange.)
With these small components you may find it easier to grasp a sewing pin or needle with the oscilloscope probe and then use the sharp tip to make electrical contact with the chip.

Yes, good catch. I thought your dashboard is inside a life system. CAN needs 120 Ohm termination resistors on each end. Close Jumper J1 and add another one at the other end. I doubt there is a resistor on the dashboard because CAN only needs two and usually has many more nodes.

Then please do the test described in reply #3. First just the module with jumper 1 closed and another at the end of your CAN bus. Send one message. It should be repeated continuously. Measure the CAN bitrate with your oscilloscope and confirm it is 50kbits/s.

Then connect the dashboard you should see the CAN message you send is no longer repeated because the dashboard acknowledges the message as valid. This is a CAN hardware function. All active nodes will acknowledge any valid CAN message.

thanks mikb55
so these are the results:

When the arduino is off, the only pin that receives CAN communication from the dashboard is the pin marked in green.

These chips are not the same of your image. they are compatible but not equals. Could this is a problem ?
thanks in advance

thanks Klaus_k
so I put the jumper on MCP2515.
I repeated the test of loop just with MCP module (without connecting to dashboard).
50Kbps at 8MHZ so these are the results.


It comunicates??
There are two signals very close to CANL and CANH. They look like constant voltages but actually have a slight variation of 20mV. Are they normal?