I have tried many example sketches and none of them give results.... I am not getting the ID and the date in serial monitor.
I use this simple code and nothing:
#include <SPI.h>
#include <mcp2515.h>
struct can_frame canMsg;
MCP2515 mcp2515(10);
void setup() {
Serial.begin(115200);
mcp2515.reset();
mcp2515.setBitrate(CAN_125KBPS, MCP_8MHZ);
mcp2515.setNormalMode();
Serial.println("------- CAN Read ----------");
Serial.println("ID DLC DATA");
}
void loop() {
if (mcp2515.readMessage(&canMsg) == MCP2515::ERROR_OK) {
Serial.print(canMsg.can_id, HEX); // print ID
Serial.print(" ");
Serial.print(canMsg.can_dlc, HEX); // print DLC
Serial.print(" ");
for (int i = 0; i<canMsg.can_dlc; i++) { // print the data
Serial.print(canMsg.data[i],HEX);
Serial.print(" ");
}
Serial.println();
}
}
My CAN in car Ford Focus MK3 have MS-CAN 125Kbps and HS-CAN 500Kbps, tried these speeds and nothing.
Im tried too program CanHacker V2 with this code and added canHacker->setClock(MCP_8MHZ);
: https://github.com/autowp/can-usb/blob/master/can-usb.ino
With enable_loopback i see in program that what i transmit and receiving this what i send, i tried once transmit data all 0 (that was bad, i know) when was connected with car and cluster shows me a lot of faults from different systems, then sending data working. BUT WHY NO RECEIVING ANY DATA :(((
Please guys i want ur help.
Do you have a budget for a sub $100 10MHz oscilloscope?
This will tell you if you are connecting the correct wires, what baud rate to use and if the transceiver on the CAN interface board is functioning correctly.
Since you used Cory Fowler's library follow its guidelines. The first thing I would is build a second unit. The code is in the library. Get them to communicate first before expecting data from the car. Be sure to properly terminate the bus which should be at least 1 meter long. They should work fine without loopback first. The reason for two is CAN (Control Area Network) requires an in-frame response, without a receiving unit you will not get one and it will fault out.
I used loopback mode in the Canhacker program, in the transmit I entered the ID and various data and in the Receive (monitor) window I got the same data that I sent. Do I understand correctly that this is what you mean?
That indicates that the chip is probably working properly. What it is doing is monitoring itself. In this mode if it works as you indicate you have the chip connected properly and is is working. It did not check the bus as the transmitter to receiver connection happens in the chip. However you need to turn that diagnostic mode off otherwise nothing will be sent or received from the bus. That is why I was suggesting a second unit to completely validate your setup.