[etherlab-users] Beckhoff EL2809 (16 digital outputs) initialization issue

BUSSIERES Vincent vincent.bussieres at hemeria-group.com
Fri Apr 24 00:08:10 CEST 2020


I solve my issue.
Gavin as you told ùe, I pass a second pointer in ec_pdo_entry_reg_t to capture bit offset, and error -14 returned by « ecrt_domain_reg_pdo_entry_list » disappeared.
Then I can drive digital outputs using EC_WRITE macro.

Thanks a lot

Vincent BUSSIERES
Responsable Technique Logiciel

[1572337113342]
ZE Ma Campagne
36, Impasse Félix Nadar
16000 ANGOULEME
Tel: 33 (0)9.72.40.35.08
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.



De : Gavin Lambert <gavin.lambert at tomra.com>
Envoyé : jeudi 23 avril 2020 01:17
À : BUSSIERES Vincent <vincent.bussieres at hemeria-group.com>; etherlab-users at etherlab.org
Objet : RE: [etherlab-users] Beckhoff EL2809 (16 digital outputs) initialization issue

If ecrt_domain_reg_pdo_entry_list returns an error, it has nothing to do with the slave itself, it means you're passing inconsistent data.

Having said that, at a glance I don't see any obvious issues with the code you've posted (except that you probably should have the watchdog enabled, but that's an unrelated issue).  When the error occurs, have a look at the syslog output; it should tell you more.  If that's not enlightening enough, then set "ethercat debug 1" before running your code and check the syslog again.

There is an EC_WRITE_BIT as well.  In addition to the byte offset (which is stored in &offOutput[x] in your example), you need to pass a second pointer in ec_pdo_entry_reg_t to capture the bit offset, when using data smaller than 1 byte.

(Alternatively, while this is technically not robust and may potentially break due to other network layout, given the total size of the SMs it's reasonably safe to assume that the 16 outputs will be mapped to two physical bytes, so you can just use EC_WRITE_U8 at the byte address of outputs 1 and 9, respectively.  Or even EC_WRITE_U16 just to the address of output 1.  You will have to be careful about potential bit ordering differences between your master and slave, however.)


Gavin Lambert
Senior Software Developer


[cid:image002.png at 01D619CC.2C2E8F80]
[TOMRA]<http://www.compacsort.com>[Facebook]<https://www.facebook.com/Compacsort>[Linkedin]<https://www.linkedin.com/company/compac-sorting-equipment/>[Youtube]<https://vimeo.com/compacsort>[twitter]<https://twitter.com/compacsort>[instagram]<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: Thursday, 23 April 2020 08:50
To: etherlab-users at etherlab.org<mailto:etherlab-users at etherlab.org>
Subject: [etherlab-users] Beckhoff EL2809 (16 digital outputs) initialization issue

Dear Etherlab users,

I am working with a Beckhoff EL2809 module (16 digital outputs module) and I have some difficulties to register pdo entries.
I think that for this module pdo are not assignable.

You can find some informations about this product below :

=== Master 0, Slave 3 ===
Device: Main
State: PREOP
Flag: +
Identity:
  Vendor Id:       0x00000002
  Product code:    0x0af93052
  Revision number: 0x00120000
  Serial number:   0x00000000
DL information:
  FMMU bit operation: no
  Distributed clocks: yes, delay measurement only
  DC system time transmission delay: 885 ns
Port  Type  Link  Loop    Signal  NextSlave  RxTime [ns]  Diff [ns]   NextDc [ns]
   0* EBUS  up    open    yes             2   2053620480           0         145
   1  EBUS  up    open    yes             4   2053621070         590         140
   2  N/A   down  closed  no              -            -           -           -
   3  N/C   down  closed  no              -            -           -           -
General:
  Group: DigOut
  Image name:
  Order number: EL2809
  Device name: EL2809 16K. Dig. Ausgang 24V, 0.5A
  Flags:
    Enable SafeOp: no
    Enable notLRW: no
  Current consumption: 140 mA

SM0: PhysAddr 0x0f00, DefaultSize    1, ControlRegister 0x44, Enable 9
  RxPDO 0x1600 "Channel 1"
    PDO entry 0x7000:01,  1 bit, "Output"
  RxPDO 0x1601 "Channel 2"
    PDO entry 0x7010:01,  1 bit, "Output"
  RxPDO 0x1602 "Channel 3"
    PDO entry 0x7020:01,  1 bit, "Output"
  RxPDO 0x1603 "Channel 4"
    PDO entry 0x7030:01,  1 bit, "Output"
  RxPDO 0x1604 "Channel 5"
    PDO entry 0x7040:01,  1 bit, "Output"
  RxPDO 0x1605 "Channel 6"
    PDO entry 0x7050:01,  1 bit, "Output"
  RxPDO 0x1606 "Channel 7"
    PDO entry 0x7060:01,  1 bit, "Output"
  RxPDO 0x1607 "Channel 8"
    PDO entry 0x7070:01,  1 bit, "Output"
SM1: PhysAddr 0x0f01, DefaultSize    1, ControlRegister 0x44, Enable 9
  RxPDO 0x1608 "Channel 9"
    PDO entry 0x7080:01,  1 bit, "Output"
  RxPDO 0x1609 "Channel 10"
    PDO entry 0x7090:01,  1 bit, "Output"
  RxPDO 0x160a "Channel 11"
    PDO entry 0x70a0:01,  1 bit, "Output"
  RxPDO 0x160b "Channel 12"
    PDO entry 0x70b0:01,  1 bit, "Output"
  RxPDO 0x160c "Channel 13"
    PDO entry 0x70c0:01,  1 bit, "Output"
  RxPDO 0x160d "Channel 14"
    PDO entry 0x70d0:01,  1 bit, "Output"
  RxPDO 0x160e "Channel 15"
    PDO entry 0x70e0:01,  1 bit, "Output"
  RxPDO 0x160f "Channel 16"
    PDO entry 0x70f0:01,  1 bit, "Output"

I don't know if I need to map PDOs because they are already mapped.
At the initialization, « ecrt_domain_reg_pdo_entry_list » return error -14. You can find below a part of my code for the initialization.
Moreover, each output is written on 1 bit, we can only write PDO with macro EC_WRITE_U8, how can I do to drive only one output ?

static unsigned int offOutput[16];
static ec_domain_state_t domain1_state = {};
static ec_master_state_t master_state = {};

const static ec_pdo_entry_reg_t domain1_regs[] = {
    {0, 3, 0x00000002, 0x0af93052, 0x7000, 1, &offOutput[0]},
    {0, 3, 0x00000002, 0x0af93052, 0x7010, 1, &offOutput[1]},
    {0, 3, 0x00000002, 0x0af93052, 0x7020, 1, &offOutput[2]},
    {0, 3, 0x00000002, 0x0af93052, 0x7030, 1, &offOutput[3]},
    {0, 3, 0x00000002, 0x0af93052, 0x7040, 1, &offOutput[4]},
    {0, 3, 0x00000002, 0x0af93052, 0x7050, 1, &offOutput[5]},
    {0, 3, 0x00000002, 0x0af93052, 0x7060, 1, &offOutput[6]},
    {0, 3, 0x00000002, 0x0af93052, 0x7070, 1, &offOutput[7]},
    {0, 3, 0x00000002, 0x0af93052, 0x7080, 1, &offOutput[8]},
    {0, 3, 0x00000002, 0x0af93052, 0x7090, 1, &offOutput[9]},
    {0, 3, 0x00000002, 0x0af93052, 0x70a0, 1, &offOutput[10]},
    {0, 3, 0x00000002, 0x0af93052, 0x70b0, 1, &offOutput[11]},
    {0, 3, 0x00000002, 0x0af93052, 0x70c0, 1, &offOutput[12]},
    {0, 3, 0x00000002, 0x0af93052, 0x70d0, 1, &offOutput[13]},
    {0, 3, 0x00000002, 0x0af93052, 0x70e0, 1, &offOutput[14]},
    {0, 3, 0x00000002, 0x0af93052, 0x70f0, 1, &offOutput[15]},
    {}
};

ec_pdo_entry_info_t slave_0_pdo_entries[] = {
    {0x7000, 0x01, 1},
    {0x7010, 0x01, 1},
    {0x7020, 0x01, 1},
    {0x7030, 0x01, 1},
    {0x7040, 0x01, 1},
    {0x7050, 0x01, 1},
    {0x7060, 0x01, 1},
    {0x7070, 0x01, 1},

    {0x7080, 0x01, 1},
    {0x7090, 0x01, 1},
    {0x70a0, 0x01, 1},
    {0x70b0, 0x01, 1},
    {0x70c0, 0x01, 1},
    {0x70d0, 0x01, 1},
    {0x70e0, 0x01, 1},
    {0x70f0, 0x01, 1},
};

ec_pdo_info_t slave_0_pdos[] = {
    {0x1600, 1, &slave_0_pdo_entries[0]},
    {0x1601, 1, &slave_0_pdo_entries[1]},
    {0x1602, 1, &slave_0_pdo_entries[2]},
    {0x1603, 1, &slave_0_pdo_entries[3]},
    {0x1604, 1, &slave_0_pdo_entries[4]},
    {0x1605, 1, &slave_0_pdo_entries[5]},
    {0x1606, 1, &slave_0_pdo_entries[6]},
    {0x1607, 1, &slave_0_pdo_entries[7]},
    {0x1608, 1, &slave_0_pdo_entries[8]},
    {0x1609, 1, &slave_0_pdo_entries[9]},
    {0x160a, 1, &slave_0_pdo_entries[10]},
    {0x160b, 1, &slave_0_pdo_entries[11]},
    {0x160c, 1, &slave_0_pdo_entries[12]},
    {0x160d, 1, &slave_0_pdo_entries[13]},
    {0x160e, 1, &slave_0_pdo_entries[14]},
    {0x160f, 1, &slave_0_pdo_entries[15]},
};

ec_sync_info_t slave_0_syncs[] = {
    {0, EC_DIR_OUTPUT, 8, slave_0_pdos + 0, EC_WD_DISABLE},
    {1, EC_DIR_OUTPUT, 8, slave_0_pdos + 8, EC_WD_DISABLE},
    {0xff}
};


static ec_master_t *master = nullptr;
static ec_domain_t *domain1 = nullptr;
static uint8_t *domain1_pd = nullptr;
static ec_slave_config_t *sc_el2809 = nullptr;
static ec_slave_config_state_t sc_el2809_state = {};
static ec_slave_info_t slaveInfo;


bool Worker::init()
{
    master = ecrt_request_master(0);
    if ( !master )
        return false;
    domain1 = ecrt_master_create_domain(master);
    if ( !domain1 )
        return false;
    if ( !(sc_el2809 = ecrt_master_slave_config(master, 0, 3, 0x00000002, 0x0af93052)) )
    {
        fprintf(stderr, "Failed to get slave configuration for AKD.\n");
        return false;
    }
    if (ecrt_slave_config_pdos(sc_el2809, EC_END, slave_0_syncs))
        return false;
    //----------- return -14 ?
    if (ecrt_domain_reg_pdo_entry_list(domain1, domain1_regs))
        return false;
    //-----------------------
    if ( ecrt_master_activate( master ) )
        return false;
    if (!(domain1_pd = ecrt_domain_data(domain1)))
        return false;

    return true;
}

dmesg doesn't seem report any errors.

Best regards

Vincent BUSSIERES
Responsable Technique Logiciel

[1572337113342]
ZE Ma Campagne
36, Impasse Félix Nadar
16000 ANGOULEME
Tel: 33 (0)9.72.40.35.08
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%7Cf091907ede00490bbc1008d7e6febd35%7C4308d118edd143008a37cfeba8ad5898%7C0%7C0%7C637231854094445603&sdata=xvkywGyCJdixGyXCXpkIDXCsnTJxOsVY9eZnaRuH3SU%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/20200423/766aab90/attachment-0004.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/20200423/766aab90/attachment-0040.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image002.png
Type: image/png
Size: 11438 bytes
Desc: image002.png
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20200423/766aab90/attachment-0041.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image003.png
Type: image/png
Size: 1629 bytes
Desc: image003.png
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20200423/766aab90/attachment-0042.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image004.png
Type: image/png
Size: 1750 bytes
Desc: image004.png
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20200423/766aab90/attachment-0043.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image005.png
Type: image/png
Size: 1855 bytes
Desc: image005.png
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20200423/766aab90/attachment-0044.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image006.png
Type: image/png
Size: 1970 bytes
Desc: image006.png
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20200423/766aab90/attachment-0045.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image007.png
Type: image/png
Size: 20278 bytes
Desc: image007.png
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20200423/766aab90/attachment-0046.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image008.png
Type: image/png
Size: 1506 bytes
Desc: image008.png
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20200423/766aab90/attachment-0047.png>


More information about the Etherlab-users mailing list