[etherlab-users] I cannot proceed with configuration of PDOs using Libethercat.

j.sikorski at utwente.nl j.sikorski at utwente.nl
Tue Jun 14 20:39:35 CEST 2016


Dear EtherLab Users,


I installed the IgH EtherCAT master, and to educate myself how to implement the communication, I set up a small network comprising of IgH master and one Technosoft Motion iPOS4808 drive.

The ./ethercat slaves command detects it.

The ./ethercat cstruct gives me the following configuration:

ec_pdo_entry_info_t slave_0_pdo_entries[] = {
    {0x6040, 0x00, 16},
    {0x607a, 0x00, 32},
    {0x6041, 0x00, 16},
    {0x6064, 0x00, 32},
    {0x6077, 0x00, 16},
    {0x60f4, 0x00, 32},
    {0x60fd, 0x00, 32},
};

ec_pdo_info_t slave_0_pdos[] = {
    {0x1600, 2, slave_0_pdo_entries + 0},
    {0x1a00, 3, slave_0_pdo_entries + 2},
    {0x1a01, 2, slave_0_pdo_entries + 5},
};

ec_sync_info_t slave_0_syncs[] = {
    {0, EC_DIR_OUTPUT, 0, NULL, EC_WD_DISABLE},
    {1, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE},
    {2, EC_DIR_OUTPUT, 1, slave_0_pdos + 0, EC_WD_DISABLE},
    {3, EC_DIR_INPUT, 2, slave_0_pdos + 1, EC_WD_DISABLE},
    {0xff}
};


Now I want to use C++ functions, to change the value outputted at 0x1a00 x02 to the object 0x2058 x00 with size 16 bit.

Hence, based on the cstruct file, as well as ~/ethercat-1.5.2/example/user/main.c , I write the following code (spread over main.h and main.cpp) to achieve this.


#include "auxfun.h"

// Application parameters

#define FREQUENCY 100

#define PRIORITY 1


// Optional features

#define CONFIGURE_PDOS  1

#define SDO_ACCESS      0



// EtherCAT

static ec_master_t *master = NULL;

static ec_master_state_t master_state = {};


static ec_domain_t *domain1 = NULL;

static ec_domain_state_t domain1_state = {};


static ec_slave_config_t *sc_iPOS0 = NULL;

static ec_slave_config_state_t sc_iPOS0_state = {};


// Timer

static unsigned int sig_alarms = 0;

static unsigned int user_alarms = 0;


/****************************************************************************/


// process data

static uint8_t *domain1_pd = NULL;


#define AxisBotPos  0, 0 //Bottom frame iPOS Alias


#define IPOS4808BX_CAT 0x000001a3, 0x019f418d // Vendor ID, Product Code



const static ec_pdo_entry_reg_t domain1_regs[] = {

    {AxisBotPos,  IPOS4808BX_CAT, 0x6060, 0x00, &off_iPOS0_Rx},

    {AxisBotPos,  IPOS4808BX_CAT, 0x2058, 0x00, &off_iPOS0_Tx},

    {}

};



// Analog in --------------------------

ec_pdo_entry_info_t iPOS0_pdo_entries[] = {

    {0x6040, 0x00, 16},

    {0x6060, 0x00, 8},

    {0x6041, 0x00, 16},

    {0x2058, 0x00, 16},

    {0x6077, 0x00, 16},

    {0x60f4, 0x00, 32},

    {0x60fd, 0x00, 32},

};


ec_pdo_info_t iPOS0_pdo[] = {

    {0x1600, 2, iPOS0_pdo_entries + 0},

    {0x1a00, 3, iPOS0_pdo_entries + 2},

    {0x1a01, 2, iPOS0_pdo_entries + 5},

};


ec_sync_info_t iPOS0_syncs[] = {

    {0, EC_DIR_OUTPUT, 0, NULL, EC_WD_DISABLE},

    {1, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE},

    {2, EC_DIR_OUTPUT, 1, iPOS0_pdo + 0, EC_WD_DISABLE},

    {3, EC_DIR_INPUT, 2, iPOS0_pdo + 1, EC_WD_DISABLE},

    {0xff}

};






#include "main.h"


/****************************************************************************/

int main(int argc, char **argv)

{

??

    struct itimerval tv;


    master = ecrt_request_master(0);

    if (!master)

        return -1;

?

    domain1 = ecrt_master_create_domain(master);

    if (!domain1)

        return -1;


    if (!(sc_iPOS0 = ecrt_master_slave_config(

                    master, AxisBotPos, IPOS4808BX_CAT))) {

        fprintf(stderr, "Failed to get slave configuration.\n");

        return -1;

    }

    printf("Configuring PDOs...\n");

    if (ecrt_slave_config_pdos(sc_iPOS0, 4, iPOS0_syncs)) {

        fprintf(stderr, "Failed to configure PDOs.\n");

        return -1;

    }

    cout << "Done" << endl;

return 0;


}?



I run the code above. It executes with no problem.

Now, I checked, using:

sudo ethercat upload -a 0 0x1a00 01

whether the introduced mapping modification worked. Unfortunately it seems that it is not the case and I get the same variable that was in ./ethercat cstruct at that position.

Then I tried to change the variable manually using ./ethercat download -a 0 0x1a00 01 0x20580010. This worked, at least in the console (confirmed by ./ethercat upload). However, cstruct still outputs previous values. I also tried the same procedure with other PDO variables to the same effect, my C++ code changes nothing in the mapping.

If anyone of you could look into the code and tell me whether what I am doing is correct (or wrong), I would be exteremely grateful. I mostly do not know where even to start debugging right now.

Thank you a lot in advance.

Yours faithfully,
Jakub Sikorski




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20160614/8919926b/attachment-0002.htm>


More information about the Etherlab-users mailing list