Go Down

Topic: Can not receive CAN DATA from Arduino UNO with MCP2515 Module. (Read 34209 times) previous topic - next topic

turbozob

Command 8MHZ works, while 8MHz not ('MCP_8MHz' was not declared in this scope)

Eventually I got it working but not in the car but on a bench with ECU(EDC15VM+) from scrapyard which is the same as in my car. It seems like my car does not support CAN, although the CAN wires are present at the OBD2 connector (pins 6,14) tested with oscilloscope.

So what I did on the bench:

- Wired "Nirem" with Arduino
- Wired CAN H&L ECU to "Nirem"
- Connected power to ECU and trimmers for sensor simulation
- Opened "CAN Receive Example" from your library  "MCP_CAN Library"
- Setup MCP to 8MHZ
- Upload to Arduino and open Serial
- Data traffic seen from engine ECU with different IDs
- Decode data with oscilloscope

Later I modified code for readable value calculation as temperature, acc pedal sensor with the help of ecu documentation and useful forum posts. Compared data from diagnostic tool VCDS and recieved from Arduino were almost the same.
The man who asks a question is a fool for a minute, the man who does not ask is a fool for life. -Confucius

laoadam

The code should work with a MCP2510, MCP2515, and an MCP25625, but I have only confirmed it on the latter two ICs.  Additionally, I have tested the library with that very module you linked to and recently infact. 

When you tried the receive example, did you have it connected to the vehicle with the key-switch ON (engine OFF)?
There is mention message of reply the topic or a new one, my question is exactly here so.

Thank you coryjfowler  to confirm the use of the code, my question is if the code only works for CAN BUS shield made by MCP2515 and MCP2510 or MCP25625? Can the code work for the CAN BUS shield made by MCP2515 and TJA1050 like oasis's post mentioned?

I used Arduino+MCP2515+TJA1050 + ELM327 unit without an ECU.

I guess this is the point, because that's two kinds of CAN BUS shield. and McNeight posted at: https://forum.arduino.cc/index.php?topic=228758.0 

[ No, the MCP2551 (or MCP2515) won't work with ELM327 protocol ].

seems the code doesn't work for the CAN BUS shield mentioned, if not how to modify?

Thanks
Adam




coryjfowler

seems the code doesn't work for the CAN BUS shield mentioned, if not how to modify?

If the board has an MCP2515, MCP25625, or MCP2510, the library should work for those protocol controllers.

The TJA1050 is a common CAN transceiver and is only used to translate the CAN_RX and CAN_TX into CAN_H and CAN_L for use on an actual bus.


While I have not tried it, an ELM327 acting as a second CAN device may work.  Regardless, any CAN testing needs to have at least two active devices.  If the ELM327 does not actively participate on CAN, it might cause an erroneous send failure.

I do not recommend ELM products outside of explicit OBD-II applications, it is a horrible CAN interface...
"Taking the time to make a proper, punctuated, post is a mark of courtesy and respect."  http://forum.arduino.cc/index.php?topic=149022.0

laoadam

If the board has an MCP2515, MCP25625, or MCP2510, the library should work for those protocol controllers.

The TJA1050 is a common CAN transceiver and is only used to translate the CAN_RX and CAN_TX into CAN_H and CAN_L for use on an actual bus.
Thank you coryjfowler for your reply.
Yes like you said the ELM327 USB1.5 seems a surplus if do the diagnosis to a car. I used it here only try to get the communication between ELM327 USB1.5 and MCP2515+TJA1050 module. I have some novice questions need help please, sorry about.
1. Should I set the ELM327 USB1.5's Baudrate same as the other device , guess YES, do you know how to do it? it was default set 38400 bps.

2. If it is hard to set ELM327's Baudrate, may easy to set the other device say MCP2515+TLA1050 can module, I modified the mcp_can.cpp and mcp_can_dfs.h added 38k4BPS 3 lines into the library used, still not work. I'll attached the modifications below. Maybe cause of the 38k4BPS s not a standard number, it doesn't like the other numbers say 250/500 change the color in the sketch.

3. The error "'CAN_38K4BPS' was not declared in this scope" , why?

4. I saw your advice about the ELM327, the purpose I'm doing this is try to make a ECU simulator with the Arduino+MCP2515 module work as a fake ECU, sure refer to Techthink.

5. I also tried the sketch you posted on #11 to reynard80, I got the same result with Arduino and MCP2515+TJA1050 MODULE, I tested it on two separately two sets of, all Error sending message ... , is it possibly to run the sketch without a real ECU unit connected ?

Thanks

Adam

coryjfowler

Thank you coryjfowler for your reply.
Yes like you said the ELM327 USB1.5 seems a surplus if do the diagnosis to a car. I used it here only try to get the communication between ELM327 USB1.5 and MCP2515+TJA1050 module. I have some novice questions need help please, sorry about.
1. Should I set the ELM327 USB1.5's Baudrate same as the other device , guess YES, do you know how to do it? it was default set 38400 bps.
If this is the CAN baud, yes.  If this is the serial interface baud, no.  I have not used any ELM stuff, that is on you to figure out.

2. If it is hard to set ELM327's Baudrate, may easy to set the other device say MCP2515+TLA1050 can module, I modified the mcp_can.cpp and mcp_can_dfs.h added 38k4BPS 3 lines into the library used, still not work. I'll attached the modifications below. Maybe cause of the 38k4BPS s not a standard number, it doesn't like the other numbers say 250/500 change the color in the sketch.
I feel like 38,400 baud is the ELM's serial link.  OBD-II CAN spec is 250 or 500.

3. The error "'CAN_38K4BPS' was not declared in this scope" , why?
Looks like you missed adding 'CAN_38K4BPS' to the enum.

4. I saw your advice about the ELM327, the purpose I'm doing this is try to make a ECU simulator with the Arduino+MCP2515 module work as a fake ECU, sure refer to Techthink.
In that regard, you should set the Arduino with CAN to 500k, and have it listen for the OBD-II functional ID (0x7DF).  When it receives that ID, the Arduino should transmit using one of the ECM's IDs (0x7E8).

5. I also tried the sketch you posted on #11 to reynard80, I got the same result with Arduino and MCP2515+TJA1050 MODULE, I tested it on two separately two sets of, all Error sending message ... , is it possibly to run the sketch without a real ECU unit connected ?
No, CAN needs at least TWO active devices or you will have an error sending.
"Taking the time to make a proper, punctuated, post is a mark of courtesy and respect."  http://forum.arduino.cc/index.php?topic=149022.0

laoadam

Thank you for your patience coryjfowler.

1. Firstly I would say I may misunderstand the Baudrate from the ELM327 manufacture default of 38400bps, this number should be the Baudrate for the USB communicate to computer?  and the ELM327 is just a physics converter convert the received CAN DATE into USB compatible, am I right? same as you answered at #2 ?

Because if the 38400bps is a CAN BUS Baudrate, how can the ELM327 take a 500kbps?

2. I modified the library files and the 38k4bps compiling errors disappeared . The ELM327 and MCP2515+TJA1050 module still can't communicate.

3. at answer #5 you said "CAN needs at least TWO active devices", that means the ELM327 is not a  active devices itself, right? I have tried two sets of Arduino+MCP2515 connected together and sending / receiving well. 

4. Here what I'm doing is let the computer read date from Arduino+MCP2515 through the ELM327,  the ELM327 just works as a CAN interface, and the Original project used SeeedStudio CAN-BUS shield which made up by MCP2515+MCP2551, and it was succeed.
What's the key difference between TLA1050 and MCP2551? any solution on sketch?

Best
Adam

 


coryjfowler

What's the key difference between TLA1050 and MCP2551? any solution on sketch?
The vendor for starters.  Do both boards have terminations enabled when you are testing this?
"Taking the time to make a proper, punctuated, post is a mark of courtesy and respect."  http://forum.arduino.cc/index.php?topic=149022.0

hugo_a_garcia

Hi

I am responding to this post since at some point many of your have tested various CAN boards.

I am not having success with the JOY-IT CAN Module:

https://joy-it.net/en/products/SBC-CAN01

Corey's loopback works well but the send/receive example is failing with sending message error. The board has a 16MHz crystal. I have tried various baud rates and also turning on/off the 120 ohm resistor on both boards.

The setup is [ UNO - CAN - CAN - MEGA ]

Comments, suggestions or questions are welcome.

-H

turbozob

hugo,

your board has MCP2515 controller, so I it not any different from other boards with the same controller. I guess you have a wiring or code issue.
The man who asks a question is a fool for a minute, the man who does not ask is a fool for life. -Confucius

hugo_a_garcia

hugo,

your board has MCP2515 controller, so I it not any different from other boards with the same controller. I guess you have a wiring or code issue.
I did connectivity test with a multimeter on the CAN H/L [ H -> H, L -> L] and it is OK. I have not checked the individual wires for connectivity but I assumed the loopback program would not work if the SPI wires are not all working properly???

Also, both boards have their own independent power supply.

The program is the example from:

https://github.com/coryjfowler/MCP_CAN_lib


which has worked for others on thread.

-H

coryjfowler

I assumed the loopback program would not work if the SPI wires are not all working properly???
You would be correct with that assumption, the loopback sketch would test SPI and /INT connectivity.


The link you provided for the Joy-It module suggests the crystal is 8MHz, did you replace this or confirm that it is running at 16MHz as you suggest earlier?

Are the CAN boards both Joy-It modules or is one a Seeed Studio shield?  Have you tried connecting grounds between the two?  What sketches are you testing with?

If both microcontroller setups work with the loopback program, there is no good reason that going on bus would not work assuming the hardware is good.
"Taking the time to make a proper, punctuated, post is a mark of courtesy and respect."  http://forum.arduino.cc/index.php?topic=149022.0

hugo_a_garcia

You would be correct with that assumption, the loopback sketch would test SPI and /INT connectivity.


The link you provided for the Joy-It module suggests the crystal is 8MHz, did you replace this or confirm that it is running at 16MHz as you suggest earlier?

Are the CAN boards both Joy-It modules or is one a Seeed Studio shield?  Have you tried connecting grounds between the two?  What sketches are you testing with?

If both microcontroller setups work with the loopback program, there is no good reason that going on bus would not work assuming the hardware is good.
I am using your example sender and reader from github with 8MHX set as the clock.

Boyj boards are Joy-iy and at least electrically, the CAN bus is set up properly.

I agree is should work so maybe the hardware is faulty.

---

I opened a ticket with Joy-it. I also, have an extra board so... myabe test that one too. Will do an update when possible.

Thanks for comments

-H

hugo_a_garcia

Small update on the Joy-It board:

The company has confirmed that the crystal on the board is 16MHz.

-H

turbozob

I remember that loopback worked even if wrong MHz was selected. Did you make any progress?
The man who asks a question is a fool for a minute, the man who does not ask is a fool for life. -Confucius

johnstylez

question, i am trying to use mcp2515 + coryjfowler's library with nano, i was able to send fuel level request to my 2019 toyota obd can bus, and i have checked it with another usb can analyzer , but i wasn't able to get any response from the car can bus. however when i send request using the usb can analyzer i was able to get the response.

Go Up