Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

Exception with ReadNbrSlaves function

paulpotat
2021-09-16
2021-09-24
  • paulpotat

    paulpotat - 2021-09-16

    Hello,
    I'm trying to scan an ethercat network to compute the number of slaves on it with CodeSys.
    My ethercat configuration look like this :

    Ethercat Master
    β”œβ”€ Ethercat Slave A
    β”œβ”€ Ethercat Slave B
    └─ Ethercat Slave C

    I'm using a function called "ReadNbrSlaves" from the EtherCATStackLibrary (documentation here). I tried with the provided code example from the documentation which is :

    PROGRAM PLC_PRG
    VAR
       readnbr : ReadNbrSlaves;
       xRead : BOOL := TRUE;
       wNbrSlaves : WORD;
    END_VAR
    
    IF xRead THEN
       readnbr.usiCom := DWORD_TO_USINT(Ethercat_Master.InstanceNumber);
       readnbr(xExecute := TRUE, udiTimeOut := 1000);
       IF readnbr.xDone THEN
          xRead := FALSE;
          wNbrSlaves := readnbr.wNumberSlaves;
          readnbr(xExecute := FALSE);
       END_IF
    END_IF
    

    I can flash this code on the PLC without errors.
    However as soon as I try to run the program I get a message saying "No source code available for this object because it is in the compiled library 'caa behaviour model 3.5.11 (caa technical workgroup)'. Do you want to browse for the original library in order to display the source code ?"

    If I say "Yes" the file browser pops up but I have no idea what CodeSys is expecting me to point at... If I say "No" another error message pops-up and I get an exception that stops the program.

    Now the really weird part is that if I add a 50 ms timer before starting the execution of "ReadNbrSlaves" it works just fine (the result of the function is correct and there is no more exceptions).
    I should also say that the program runs in a task with a 3ms cycle time.

    Does somebody know why this happens ? By the way I'm using CodeSys 3.5.16 and the program is running on a raspbian.
    Thank you for your help

    Best regards

     

    Last edit: paulpotat 2021-09-16
  • paulpotat

    paulpotat - 2021-09-24

    Please any help is appreciated, even if it's not a full solution to my issue (;-;)

     

Log in to post a comment.