canMsg1.can_id = 0x01; canMsg1.can_rtr = 1; canMsg1.can_ide = 0; canMsg1.can_dlc = 8; canMsg1.data = 0x00; canMsg1.data = 0x00; canMsg1.data = 0x00; canMsg1.data = 0x00; canMsg1.data = 0x00; canMsg1.data = 0x00; canMsg1.data = 0x00; canMsg1.data = 0x00;
I am new to CAN and having trouble getting my CAN device to answer. Can you help?My Arduino is connected to an MCP2515 board. This communication is verified working with another Arduino with another MCP2515. One Arduino sends data and the other prints it to serial monitor, no problems. I have been using the mcp2515.h library.I am now trying to ask for data from a MCP2505 programmable CAN node but cant figure out how to do it. What should I send to MCP2505 to get it to send me for example the control regs? Attached is a snip from the data sheet with the sequences.As I see it, Arduino sends first "Read Control Regs" and then listens for the device to send back "Read Control Regs" from the lower table.The big question is: How should my struct look like in the Arduino sketch? Something like below or not? My MCP2505 node has the address 0x01. Im confused about the address part. Does MCP2505 only use 7 bit addresses and the rest 4 bits of the addresses are for telling the registry?The full datasheet is here: http://ww1.microchip.com/downloads/en/DeviceDoc/20001664E.pdf
If using non-RTR messages for information request messages (IRM), the RTR bit = 0, DLC bit field = 0, and bit 3 of the IRM ID = 1. Also, bit 3 of the output message ID = 0.If using RTR messages for IRMs, the RTR bit = 1, DLC bit field = number of bytes in corresponding output message, and bit 3 of the IRM ID = x (don't care), also, bit 3 of the output message = x (don't care).
canMsg1.can_id = 0x09; //IRM for 'read control reg. output message shuold be 0x01canMsg1.can_rtr = 0;canMsg1.can_ide = 0;canMsg1.can_dlc = 0;
so IMHO, the CAN frame you share or the following should work assuming you set the baudrate correctlyCode: [Select]Code: [Select]canMsg1.can_id = 0x09; //IRM for 'read control reg. output message shuold be 0x01canMsg1.can_rtr = 0;canMsg1.can_ide = 0;canMsg1.can_dlc = 0;hope that helps....
Thanks for this idea. It sounds good... But the mcp2515.h library does not know the member can_rtr. I have a strong feeling that RTR and IDE should be implemented in the can_id field. But would like to hear how this is really done.
There are may MCP2515 libraries out there... please share the link to the library you are using.
I have been using msp2515.h. You can find it here: https://github.com/autowp/arduino-mcp2515