matteodigani - 2025-10-01

Hi,
I've got a problem using the function block "Write alias address" (ETCStack library 4.9.0.0).

this is the code:

EtherCAT_1();

IF EtherCAT_1.ConfigRead AND enable THEN

CASE seq OF

    0:
    exec := FALSE;
    T.IN := TRUE;
    T.PT := T#10S;
    T();
    IF T.Q THEN
        seq := 1;
        T.IN := FALSE;
    END_IF
    ;

    1:
    T.IN := FALSE;
    T();

    //THIS ONE WORK CORRECTLY!
    WrAliasAdd.xAbort := FALSE;
    WrAliasAdd.usiCom := DWORD_TO_USINT(EtherCAT_1.InstanceNumber);
    WrAliasAdd.wSlaveAddress := 1002;
    WrAliasAdd.xAutoIncAdr := FALSE;
    WrAliasAdd.uiAliasAddress := 19;
    WrAliasAdd.udiTimeOut := 3000;

    IF start THEN
        exec := TRUE;
    ELSE
        IF NOT error THEN
            start := TRUE;
        END_IF
    END_IF
    IF WrAliasAdd.xDone THEN
        start := FALSE;
        done := TRUE;
        error := FALSE;
        exec := FALSE;
        seq := 5;
    END_IF
    IF WrAliasAdd.xError THEN
        start := FALSE;
        done := FALSE;
        error := TRUE;
        exec := FALSE;
    END_IF
    ;

    5:

    exec := FALSE;
    T.IN := TRUE;
    T.PT := T#1S;
    T();
    IF T.Q THEN
        seq := 10;
    END_IF

    ;

    10:
    T.IN := FALSE;
    T();

    //THIS ONE GIVES ME AN ERROR!
    WrAliasAdd.xAbort := FALSE;
    WrAliasAdd.usiCom := DWORD_TO_USINT(EtherCAT_1.InstanceNumber);
    WrAliasAdd.wSlaveAddress := 1006;
    WrAliasAdd.xAutoIncAdr := FALSE;
    WrAliasAdd.uiAliasAddress := 25;
    WrAliasAdd.udiTimeOut := 1000;

    IF start THEN
        exec := TRUE;
    ELSE
        IF NOT error THEN
            start := TRUE;
        END_IF
    END_IF
    IF WrAliasAdd.xDone THEN
        start := FALSE;
        done := TRUE;
        error := FALSE;
        exec := FALSE;
        seq := 99;
    END_IF
    IF WrAliasAdd.xError THEN
        start := FALSE;
        done := FALSE;
        error := TRUE;
        exec := FALSE;
    END_IF
    ;

ELSE
    ;
END_CASE


WrAliasAdd(xExecute := exec);

END_IF

The first one slave ethercat works correctly, but the other one gives me an error.
Attached the ethercat configuration of the devices.
All the devices are set "Optional".

So my idea is to enable only the first one (1002) and the fifth one (1006).