Because it does not work two macchina per can

hello, I have two macchina connectors on a cable Y obd, in a macchine I send messages and in the other I want to receive them, but it does not work. I guess can0 are pins 6 and 14, right?

macchina 1:
void loop(){
CAN_FRAME incoming;
if (Can0.available() > 0) {
Can0.read(incoming);
printFrame(incoming);
}
}

macchina 2:
void loop(){
CAN_FRAME outgoing;
outgoing.id = 0x405;
outgoing.length = 8;
outgoing.extended = 15;
outgoing.priority = 0; //0-15 lower is higher priority
outgoing.data.byte[0] = 0xDD;
outgoing.data.byte[1] = 0xDD;
outgoing.data.byte[2] = 0xDD;
outgoing.data.byte[3] = 0x55;
outgoing.data.byte[4] = 0xDD;
outgoing.data.byte[5] = 0xDD;
outgoing.data.byte[6] = 0xDD;
outgoing.data.byte[7] = 0x55;
Can0.sendFrame(outgoing);
}

Are the M2’s the only items connected? If so you may need a 120 ohm resistor in the circuit.

I have not tried this configuration to know if it should work. But it SHOULD work.

The CANBUS protocol requires a 120 ohm resistor at each end for it to work. If 1 doesn’t work try to put two on there.

If that doesn’t work try adding a 12 volt DC power supply to the circuit. I don’t know if the 12 volt is required to work or not but I know on other devices it is and I have not tried to communicate over the CANBUS without power on the +12 volt lead.

I concur with @redheadedrod, it is most likely that you have not terminated the bus correctly.

You can either stick 120ohm resistors over the ends of the network cable, or you can use Split Termination (2 x 60ohm) which allows you the opportunity to add a filtering cap
OR
You can (with a couple of blobs of solder) activate the terminators built in to the M2
…If you look in the “CAN” section here http://docs.macchina.cc/m2/technical-references/interfaces.html you can see that you can terminate CAN0 by bridging J6 and J7 (yes, two bridges to terminate one bus) …iirc, CAN1 is J8 and J9, but probably worth hunting around for the datasheet to be sure

I personally have CAN1 terminated on both my M2s to resolve this exact problem (ie. two M2’s talking to each other) …a bit of solder wick and you can “undo” the mod in a few seconds :slight_smile:

BC

If it’s true, with 120 ohm resistors it works correctly, thank you very much.