[etherlab-users] Read / Write PDOs & PDO Mapping

BUSSIERES Vincent vincent.bussieres at hemeria-group.com
Tue Jan 28 11:51:57 CET 2020


Hello

I am a beginner in EtherCAT technology.
I try to control a servodrive using PDOs. I succeded in settings parameters like homing mode using SDOs.
Now, I'd like to send command and read status using PDOs. I tried to make PDO mapping like in « examples/user/main.c » example.

[cid:image006.jpg at 01D5D5D1.4F59E430]

[cid:image007.jpg at 01D5D5D1.4F59E430]

You can see my source code below :

static unsigned int off_ctl_word;
static unsigned int off_status;
static unsigned int off_position_value;

const static ec_pdo_entry_reg_t domain1_regs[] = {
    {0, 0, 0x0000009A, 0x00030924, 0x6040, 0, &off_ctl_word},
    {0, 0, 0x0000009A, 0x00030924, 0x6041, 0, &off_status},
    {0, 0, 0x0000009A, 0x00030924, 0x6064, 0, &off_position_value},
    {}
};

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

ec_pdo_info_t slave_0_pdos[] = {
    {0x160a, 1, slave_0_pdo_entries + 0},
    {0x1a0a, 1, slave_0_pdo_entries + 1},
    {0x1a0e, 1, slave_0_pdo_entries + 2},
};

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_ENABLE},
    {3, EC_DIR_INPUT, 2, slave_0_pdos + 1, EC_WD_DISABLE},
    {0xff}
};


static ec_master_t *master = nullptr;
static ec_domain_t *domain1 = nullptr;
static ec_slave_config_t *sc_elmo = nullptr;
static ec_slave_info_t slaveInfo;

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);


    master = ecrt_request_master(0);
    if ( !master ) {
        exit( EXIT_FAILURE );
    }

    domain1 = ecrt_master_create_domain(master);
    if ( !domain1 ) {
    exit( EXIT_FAILURE );
    }

    if ( !(sc_elmo = ecrt_master_slave_config(master, 0, 0, 0x0000009A, 0x00030924)) ) {
        fprintf(stderr, "Failed to get slave configuration for AKD.\n");
        exit( EXIT_FAILURE );
    }

                   uint32_t abort_code = 0;
    uint8_t lHomingMethod[] = {33};
    uint8_t lModeOfOperation[] = {6};

    if(ecrt_master_sdo_download(master, 0, 0x6098, 0, (const uint8_t*)lHomingMethod, sizeof(lHomingMethod), &abort_code)<0)
    {
        exit( EXIT_FAILURE );
    }

    if(ecrt_master_sdo_download(master, 0, 0x6060, 0, (const uint8_t*)lModeOfOperation, sizeof(lModeOfOperation), &abort_code)<0)
    {
        exit( EXIT_FAILURE );
    }

    if (ecrt_slave_config_pdos(sc_elmo, EC_END, slave_0_syncs))
    {
        exit( EXIT_FAILURE );
    }

    if (ecrt_domain_reg_pdo_entry_list(domain1, domain1_regs))
    {
        exit( EXIT_FAILURE );
    }

     if ( ecrt_master_activate( master ) ) {
     exit( EXIT_FAILURE );
     }

     ecrt_release_master(master);

    return a.exec();
}


I have no error, but PDO mapping doesn't seem to be done when I compare it with command lines tool below :

[cid:image010.jpg at 01D5D5D1.4F59E430]


Did I miss anything ?
Moreover I don't know how to read and write in PDOs. In user example, I only see how to write in PDO using EC_WRITE_XX, but I don't know how to read ? Is it with EC_READ_XX ?
We don't know if data are available, is there a callback function to be notified is data has been updated ?
What is the period of EtherCAT cycle ? Is it the period of the while loop in the cyclic task ?

Best regards

Vincent BUSSIERES
Responsable Technique Logiciel

[1572337113342]
24 Avenue de Pasleck
16400 LA COURONNE
-----------------------------------
www.hemeria-group.com<https://webmail.nexeya.fr/owa/redir.aspx?C=GK_BqKCZef7LtPZnqnd_LGYr1NG9sz4Smy3iKIwO-pXqtJC7VgzXCA..&URL=http%3a%2f%2fwww.hemeria-group.com%2f>
P Afin de contribuer au respect de l'environnement, merci de n'imprimer ce courriel qu'en cas de nécessité.
Ce message et les fichiers pouvant être attachés sont confidentiels, réservés à l'usage unique des destinataires et n'engagent HEMERIA sous aucune forme que ce soit.
This email and any files transmitted with it are confidential, intented solely for the unique use of the recipients and don't commit HEMERIA.



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20200128/1741cbca/attachment-0002.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 5034 bytes
Desc: image001.png
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20200128/1741cbca/attachment-0003.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image006.jpg
Type: image/jpeg
Size: 22742 bytes
Desc: image006.jpg
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20200128/1741cbca/attachment-0009.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image007.jpg
Type: image/jpeg
Size: 26838 bytes
Desc: image007.jpg
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20200128/1741cbca/attachment-0010.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image010.jpg
Type: image/jpeg
Size: 44174 bytes
Desc: image010.jpg
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20200128/1741cbca/attachment-0011.jpg>


More information about the Etherlab-users mailing list