In an attempt to interface a motor controller, battery management system and maximum power point tracking device on a CAN bus, I used the MCP2515 and TJA1050 CAN breakout board. All these devices send out CAN messages at the same bit rates. When interfacing with the motor controller, the messages were properly interpreted by Arduino. However, with both the other devices, there is an issue with the SPI read function. I am using the Seeed library, the documentation for which can be found here: https://github.com/Seeed-Studio/CAN_BUS_Shield/blob/master/mcp_can.cpp
The following function returns the code that suggests that there is no message. The readStatus condition fails.
byte MCP_CAN::checkReceive(void)
{
byte res;
res = mcp2515_readStatus() // RXnIF in Bit 1 and 0
return ((res & MCP_STAT_RXIF_MASK)?CAN_MSGAVAIL:CAN_NOMSG);
}
The readStatus function is as follows:
byte MCP_CAN::mcp2515_readStatus(void)
{
byte i;
#ifdef SPI_HAS_TRANSACTION
SPI_BEGIN();
#endif
MCP2515_SELECT();
spi_readwrite(MCP_READ_STATUS);
i = spi_read();
MCP2515_UNSELECT();
#ifdef SPI_HAS_TRANSACTION
SPI_END();
#endif
return i;
}
The i value returns a 0. Each of the devices has a termination resistor, so a 100 ohm resistor was added at the CAN module end. The voltages were measured with respect to CAN ground, around 2.7 and 2.1 on CANH and CANL lines respectively.