Go Down

Topic: MCP25050 can message from MCP2515 (Read 162 times) previous topic - next topic

NusNus

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

Code: [Select]
canMsg1.can_id  = 0x01;
  canMsg1.can_rtr = 1;
  canMsg1.can_ide = 0;
  canMsg1.can_dlc = 8;
  canMsg1.data[0] = 0x00;
  canMsg1.data[1] = 0x00;
  canMsg1.data[2] = 0x00;
  canMsg1.data[3] = 0x00;
  canMsg1.data[4] = 0x00;
  canMsg1.data[5] = 0x00;
  canMsg1.data[6] = 0x00;
  canMsg1.data[7] = 0x00;






Klaus_K

I suspect you will need to pre-program the MCP25050 with the correct settings for the CAN bus speed and some CAN message IDs. Otherwise it would not know which speed to set and what IDs to look for. Did you do that?

Just out of curiosity, if yes, what tools did you use for that?

Did you note the "Not Recommended for New Designs" at the beginning of the datasheet?

NusNus

The MCP25050 is programmed already. Its an old device that I need to communicate with.

So cant answer any of your other questions, sorry.

sherzaad

#3
Oct 17, 2020, 08:49 am Last Edit: Oct 17, 2020, 08:50 am by sherzaad
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
Looking at the comments to those table:
Quote
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).
so IMHO, the CAN frame you share or the following should work assuming you set the baudrate correctly
Code: [Select]

canMsg1.can_id  = 0x09; //IRM for 'read control reg. output message shuold be 0x01
canMsg1.can_rtr = 0;
canMsg1.can_ide = 0;
canMsg1.can_dlc = 0;


hope that helps....

NusNus

Quote
so IMHO, the CAN frame you share or the following should work assuming you set the baudrate correctly
Code: [Select]
Code: [Select]

canMsg1.can_id  = 0x09; //IRM for 'read control reg. output message shuold be 0x01
canMsg1.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.

sherzaad

#5
Oct 18, 2020, 07:40 pm Last Edit: Today at 05:12 am by sherzaad
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 many MCP2515 libraries out there... please share the link to the library you are using.

NusNus

#6
Oct 20, 2020, 10:07 pm Last Edit: Oct 20, 2020, 10:08 pm by NusNus
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

sherzaad

I have been using msp2515.h. You can find it here: https://github.com/autowp/arduino-mcp2515
Had a look at the library and you are right about it. It does not allow you to modify rtr. However since as suggested in reply #9, rtr=0, IMHO you should be able to still use this library; just specify the CAN ID and dlc. By default, the library sets rtr=0.
if you want to play about with the rtr bit you can alway try to use the MCP2515 library I put together.
hope that helps....

Go Up