I too have been having problems sending and receiving data using 8MHZ MCP2515 boards connected to two arduinos and using Mr Fowler’s library and example sketches. The loop back sketch works fine on both arduinos but the send sketch initialises but returns an error on sending data and therefore nothing gets through to the receive sketch. I’ve tried all the suggestions given in previous posts, swapped over boards, checked and rechecked the wiring all to no avail.
Yesterday, having ordered some 16mhz boards, I was checking through the library files and noticed that the 8MHZ constant in the keywords file was spelt with a lowercase z, i.e 8MHz. Everywhere else it was always MHZ. Didn’t think it would matter as I would have expected a compilation error still it was a “straw” so I changed it to an uppercase Z, recompiled the sketches and WOW, my serial monitors were flooded with successful send and receive messages.
I was wondering if anyone has been able to get this to read data back? I have checked what I am sending and it matches the code I am intending to send. I have verified that the ecu is responding back using Vector, however I only getting message successfully sent, no data
So guys saying on these Nirem boards 8MHz Q should be replaced with 16MHz Q and then it should work?
I can get the communication running between two arduino uno's but not with the car. Thanks for reply
Sorry for late reply, forgot to subscribe to topic. I used MCP_8MHZ but nothing comes from the car, guess I am doing something else wrong. Has anyone successfully connected with the car over OBD2 with this Nirem board?
turbozob:
Sorry for late reply, forgot to subscribe to topic. I used MCP_8MHZ but nothing comes from the car, guess I am doing something else wrong. Has anyone successfully connected with the car over OBD2 with this Nirem board?
Can you try changing 8MHz
to 8MHZ
in the keywords file? I just changed it on github per this message above and I am curious if that has been the issue plaguing some users.
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.
coryjfowler:
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: Arduino Interface with OBD-II - Project Guidance - Arduino Forum
[ 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
laoadam:
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...
coryjfowler:
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.
-
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 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.
-
The error "'CAN_38K4BPS' was not declared in this scope" , why?
-
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.
-
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
laoadam:
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.
- 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.
laoadam:
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.
laoadam:
3. The error "'CAN_38K4BPS' was not declared in this scope" , why?
Looks like you missed adding 'CAN_38K4BPS' to the enum.
laoadam:
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).
laoadam:
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.
coryjfowler:
Thank you for your patience coryjfowler.
- 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?
-
I modified the library files and the 38k4bps compiling errors disappeared . The ELM327 and MCP2515+TJA1050 module still can't communicate.
-
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.
-
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
laoadam:
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?
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:
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
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.
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.
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:
which has worked for others on thread.
-H
hugo_a_garcia:
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.
coryjfowler:
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
Small update on the Joy-It board:
The company has confirmed that the crystal on the board is 16MHz.
-H
I remember that loopback worked even if wrong MHz was selected. Did you make any progress?
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.