I have set up my project, using CAN bus with 5 nodes, 2 x FEz Panda, 1x ChipKit and 1 x Arduino Uno. and i am using a PEAK CAN usb module to communicate to my PC. I know each node is set up correctly, and when a message is sent to a specific node, the correct reply is generated and received from that node, i have verified this using the PEAK can bus monitor.
The problem i am having is that i want to send out a general message, where i need all the nodes to respond, (a general ping to see how many nodes exist and asking the nodes for their unique address), i only receive responses from the ChipKit and the Uno, but not the Fez Panda’s.
I suspect that it could be something to do with clashing of messages, but i am not sure.
Here is the set up code for the Fez Can bus, (as per the Beginners Guide to .NET Micro Framework)
int T1, T2, BRP;
BRP = 6;
T1 = 15;
T2 = 8;
// 500Kbps
// Use channel 1
CAN can = new CAN(CAN.Channel.Channel_1, (uint)(((T2 - 1) << 20) | ((T1 - 1) << 16) | ((BRP - 1) << 0)));
//can events
can.DataReceivedEvent += new CANDataReceivedEventHandler(can_DataReceivedEvent);
can.ErrorReceivedEvent += new CANErrorReceivedEventHandler(can_ErrorReceivedEvent);
//board 1
static int BoardID = 0x05;
//board 2
static int BoardID = 0x03;
the other ID’s are
0x03
and 0x02
the PC being 0x00
and 0x01 reserved for a general call.
So when i do a general call the board checks the ID, if it is 0x01 then its a general call so i need it to reply with certain data.
I know it is all set up correctly, because if i physically disocnnect one Fez node, then i get 3 responses ( 1x FEz Panda, 1x ChipKit and 1 x Arduino Uno). similarly if i disconnect the other Fez node i get 3 replies aswell. The problem is that when both Fez nodes are connected, i dont get any replies from the Fez Panda’s, but i do get replies from the ChipKit and Arduino Uno.
You cant use same CAN ID on two devices, id 0x03 is already used.
The lowest CAN id has the highest prio on the bus, you need to make sure the nodes doesn’t send the responce at the same time otherwise it could happen that the message is lost because of the CAN bus arbitration when having the same ID.