I have been trying to build an Arduino dashboard for an F-SAE project that displays ECU data from the CAN-BUS, but can't find any good code to base it off of to get me started. My setup is an UNO, connected to an MCP2515 module:
These have an 8Mhz crystal, which I have read can change a number of parameters.
I've found a few "CAN-BUS read" examples from libraries I'm using, like this: MCP_CAN_lib/CAN_receive.ino at master · coryjfowler/MCP_CAN_lib · GitHub
which somewhat works, but lists off a bunch of PID's in the Serial Monitor, and I'm not sure how to narrow it down to specifics like engine RPM or temperature.
I'm worried about screwing something up, as I've tried testing some code on my personal vehicle (a 13' Chevy Volt), and the SparkFun ECU demo code from their library made my car give off a bunch of error messages, get 40+ fault codes, and the engine started on its own. The code in question, only change I made was to delete the parts about the GPS and LCD:
Would anyone have a working sample code, or can steer me in the right direction? I'm familiar with PID assignments, and if I can at least get something like RPM data working I could figure out the rest. Thank you for any help.
Thanks for the code, that has gotten a better response from my vehicle. The coolant numbers don't seem right though as they vary quite a bit in the Serial Monitor, and the engine isn't even running yet. (See screen shot).
The engine RPM doesn't return either, even with the engine running. Granted, my car is a hybrid, so it may not have one, as I don't see it's PID in the data output.
Allen42B:
Thanks for the code, that has gotten a better response from my vehicle. The coolant numbers don't seem right though as they vary quite a bit in the Serial Monitor, and the engine isn't even running yet. (See screen shot).
The engine RPM doesn't return either, even with the engine running. Granted, my car is a hybrid, so it may not have one, as I don't see it's PID in the data output.
Thank you so much again!
something's not right there.... can you confirm you made the recommended changes tothe code to match your setup?
you are reading multiple CAN IDs in that screenshoot when I expected only 0x7xx CAN ids since in the code the CAN filter is initialised. so the code is bascially decoding the wrong messages hence the wierd results.anyway...
if you check the wiki link in the code comments, under "CAN (11-bit) bus format" it mentioned a range of reply CAN IDs
if you can confirm that reply ID you are getting from that range you can adjust the code to only read and decode that particular CAN ID which should then fix the issue
I see what I did wrong. At Line 122, I had made sure the crystal and Can-Bus speed was right, but didn't change the filtering. I switched it to "MCP_STDEXT" which filtered down the results. I ran the engine and confirmed real time data changes that seemed accurate. "MCP_STD" showed no results initially, so I'm assuming it is filtering at "MCP_EXT" now. My car isn't the final destination for this product, so I'll have to keep track of which to use in the future. One last question, if I wish to read additional parameters from the ECU, is there anything else I need to change, other than adding the send and receive commands into the loop?
Thank you again so much, this is exactly what I needed to get started.
Allen42B:
is there anything else I need to change, other than adding the send and receive commands into the loop?
you should not have to change anything in the 'send' routine but you will need to update the 'receive' routine to include the new parameter you would be reading/decoding.