Go Down

Topic: Arduino to control EPOS2 50/5 with CAN communication (Read 367 times) previous topic - next topic

Jeffrey1121

Hi,
I'm new to using CAN communication and also the first time using EPOS2 50/5. My project is to use Arduino with CAN communication through EPOS2 50/5 to do positioning control of a motor. So the problem I'm having right now is that I seem to be able to initialize the CAN but after showing initializing success, I couldn't receive any datas from it.

The CAN bus shield I'm using is from the following website:
http://wiki.seeedstudio.com/CAN-BUS_Shield_V2.0/#hardware-overview

And the manuals for EPOS2 50/5 could be found through here:
https://www.maxonmotor.com/maxon/view/product/control/Positionierung/347717

I've also looked into some other's work:
http://forum.arduino.cc/index.php?topic=225789.0
But it couldn't help solve my problem

I've already checked the CAN baudrate for both Arduino and EPOS2, and also added the terminal resistor for the EPOS2; however, I am still able to receive messages from it. Since there's not a lot of resources for this kind of application, I'm not very sure what else could I try.

Jeffrey1121

This is the code I have for testing.

sherzaad

Hi,
couple of things:

- The CAN message some of the can msg structures do not make sense to me e.g.:
CANOpen PositionMode =  (CANOpen){0x601, (CANMessage){0x2F, 0x6060, 0x00, 0x01}};

I get that ID =0x601 but the data frame does not make sense! IMHO it should be 0x2F, 0x60,0x60, 0x00, 0x01.

Also I do not think the init_Mask is really needed here. you could remove all of those (could be a reason why you think you are not receiving anything!)

- ID 0x601 is the ID for you EPOS2, Are you sure you set that up correctly on the hardware (the datasheet does show how to set that up)?

- do you have a tool that can read the CAN bus? it would be handy for debugging as you could see what your arduino is actually transmitting... alternatively you could have a second arduino with a CAN shield to monitor the bus.


Jeffrey1121

Hi,

1. I believe that I used 0x6060 instead of 0x60, 0x60 is because of the datatype I used, I had 2 bytes for the index. The manual also showed 0x6060 for the index instead of 0x60, 0x60. Another thing that I checked is that the binary code for 0x6060 is the same as 0x60, 0x60, so do you think that is still going to be an issue?

2. The node I'm using for the EPOS2 is node 1, and I've checked the hardware manual for the settings already.

3. I just ordered one which should come in a few days, but I did try to use two Arduino boards sending CAN messages and check the messages through the Serial monitor, and it did work pretty well.

Thanks for the response!

sherzaad

#4
Jul 05, 2018, 08:42 pm Last Edit: Jul 05, 2018, 08:43 pm by sherzaad
Hi,

1. I believe that I used 0x6060 instead of 0x60, 0x60 is because of the datatype I used, I had 2 bytes for the index. The manual also showed 0x6060 for the index instead of 0x60, 0x60. Another thing that I checked is that the binary code for 0x6060 is the same as 0x60, 0x60, so do you think that is still going to be an issue?

2. The node I'm using for the EPOS2 is node 1, and I've checked the hardware manual for the settings already.

3. I just ordered one which should come in a few days, but I did try to use two Arduino boards sending CAN messages and check the messages through the Serial monitor, and it did work pretty well.

Thanks for the response!
Ok let start simple then; according to the datasheet if you reset the EPOS2 it sends a boot up message (Boot up message:CAN-ID = 0x700 + Node ID,DLC=1, Data = 0x00)

So... try this code to only receive CAN data and output to serial monitor. do you get anything?

Code: [Select]
#include <SPI.h>
#include "mcp_can.h"

// the cs pin of the version after v1.1 is default to D9
// v0.9b and v1.0 is default D10
const int SPI_CS_CAN    = 9;

MCP_CAN CAN(SPI_CS_CAN);                                    // Set CS pin

unsigned char len = 0;
unsigned char buf[8];
unsigned long id= 0;

void setup()
{
    Serial.begin(115200);

    while (CAN_OK != CAN.begin(CAN_500KBPS))              // init can bus : baudrate = 500k
    {
        Serial.println("CAN BUS Shield init fail");
        Serial.println("Init CAN BUS Shield again");
        delay(100);
    }
    Serial.println("CAN BUS Shield init ok!");
}

void loop()
{
        if (CAN_MSGAVAIL == CAN.checkReceive())
        {
            // read data,  len: data length, buf: data buf
            CAN.readMsgBufID(&id, &len, buf);
 
            Serial.print(id);
            Serial.print(",");
           
            for(int i = 0; i<len; i++)
            {
                Serial.print(buf[i]);
                Serial.print(",");
            }
            Serial.println();
        }
       
}

Jeffrey1121

Thanks sherzaad!!
I had it work now, it seems that there's some problem with the CAN shield I'm using, I changed some of the circuits and made it work.

Go Up