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

Gavin Lambert gavin.lambert at tomra.com
Tue Jan 28 23:09:32 CET 2020


Not all slaves will let you reconfigure and/or reassign PDOs.

Enable "ethercat debug 1" and then look at the syslog output after starting your app.


Gavin Lambert
Senior Software Developer

[cid:logo_compac_5dcf97ef-52f5-498c-8b9b-728410ddffaf.png]
[cid:compacicon_82e8a8c7-154a-4a32-9720-a5badb6258e0.png]<http://www.compacsort.com> [cid:facebook_fa85b924-53b9-45cc-8162-0564f64ec3a3.png] <https://www.facebook.com/Compacsort>  [cid:linkedin_4ec016ad-84fa-443c-85a3-b9615a4ccef8.png] <https://www.linkedin.com/company/compac-sorting-equipment/>  [cid:youtube_32142163-fc27-4aed-b14d-e8a377f98a6d.png] <https://vimeo.com/compacsort>  [cid:twitter_d89338d8-98c8-4b65-9a9e-7b1333160b0d.png] <https://twitter.com/compacsort>  [cid:insta2_1cd85de9-b3a2-4971-9904-52b2481a7c82.png] <https://www.instagram.com/compacsort/>

COMPAC SORTING EQUIPMENT LTD | 4 Henderson Pl | Onehunga | Auckland 1061 | New Zealand
Switchboard: +64 96 34 00 88 | tomra.com<http://www.tomra.com>

The information contained in this communication and any attachment is confidential and may be legally privileged. It should only be read by the person(s) to whom it is addressed. If you have received this communication in error, please notify the sender and delete the communication.

From: BUSSIERES Vincent
Sent: Tuesday, 28 January 2020 23:52
To: etherlab-users at etherlab.org
Subject: [etherlab-users] Read / Write PDOs & PDO Mapping

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:image003.jpg at 01D5D694.051D5550]

[cid:image005.jpg at 01D5D694.051D5550]

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:image007.jpg at 01D5D694.051D5550]


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

[cid:image008.png at 01D5D694.051D5550]
24 Avenue de Pasleck
16400 LA COURONNE
-----------------------------------
www.hemeria-group.com<https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwebmail.nexeya.fr%2Fowa%2Fredir.aspx%3FC%3DGK_BqKCZef7LtPZnqnd_LGYr1NG9sz4Smy3iKIwO-pXqtJC7VgzXCA..%26URL%3Dhttp%253a%252f%252fwww.hemeria-group.com%252f&data=02%7C01%7Cgavin.lambert%40tomra.com%7C114cd0ac38c54d1fc5e908d7a3e01ede%7C4308d118edd143008a37cfeba8ad5898%7C0%7C1%7C637158055294741739&sdata=9Lv9HBRmeqG1Vxf7H6i5mOuuB0KDsGqWSPDzn7M7Wbc%3D&reserved=0>
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/6c2a2d96/attachment-0004.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image003.jpg
Type: image/jpeg
Size: 14634 bytes
Desc: image003.jpg
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20200128/6c2a2d96/attachment-0015.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image005.jpg
Type: image/jpeg
Size: 19160 bytes
Desc: image005.jpg
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20200128/6c2a2d96/attachment-0016.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image007.jpg
Type: image/jpeg
Size: 30300 bytes
Desc: image007.jpg
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20200128/6c2a2d96/attachment-0017.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image008.png
Type: image/png
Size: 5034 bytes
Desc: image008.png
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20200128/6c2a2d96/attachment-0040.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: logo_compac_5dcf97ef-52f5-498c-8b9b-728410ddffaf.png
Type: image/png
Size: 11438 bytes
Desc: logo_compac_5dcf97ef-52f5-498c-8b9b-728410ddffaf.png
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20200128/6c2a2d96/attachment-0041.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: compacicon_82e8a8c7-154a-4a32-9720-a5badb6258e0.png
Type: image/png
Size: 1629 bytes
Desc: compacicon_82e8a8c7-154a-4a32-9720-a5badb6258e0.png
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20200128/6c2a2d96/attachment-0042.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: facebook_fa85b924-53b9-45cc-8162-0564f64ec3a3.png
Type: image/png
Size: 1750 bytes
Desc: facebook_fa85b924-53b9-45cc-8162-0564f64ec3a3.png
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20200128/6c2a2d96/attachment-0043.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: linkedin_4ec016ad-84fa-443c-85a3-b9615a4ccef8.png
Type: image/png
Size: 1855 bytes
Desc: linkedin_4ec016ad-84fa-443c-85a3-b9615a4ccef8.png
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20200128/6c2a2d96/attachment-0044.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: youtube_32142163-fc27-4aed-b14d-e8a377f98a6d.png
Type: image/png
Size: 1970 bytes
Desc: youtube_32142163-fc27-4aed-b14d-e8a377f98a6d.png
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20200128/6c2a2d96/attachment-0045.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: twitter_d89338d8-98c8-4b65-9a9e-7b1333160b0d.png
Type: image/png
Size: 20278 bytes
Desc: twitter_d89338d8-98c8-4b65-9a9e-7b1333160b0d.png
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20200128/6c2a2d96/attachment-0046.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: insta2_1cd85de9-b3a2-4971-9904-52b2481a7c82.png
Type: image/png
Size: 1506 bytes
Desc: insta2_1cd85de9-b3a2-4971-9904-52b2481a7c82.png
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20200128/6c2a2d96/attachment-0047.png>


More information about the Etherlab-users mailing list