LogRecord Sample ST

Snoopy354
2015-06-03
2015-06-05
  • Snoopy354 - 2015-06-03

    Hello,

    can somebody help me with a sample for the LogRecord function in Codesys.
    1. i have created a DataLogManager and a Dataprotcol (Test).

    Test.xExecute := FALSE;
    Test.wsRecord := wconcat("Test", UINT_TO_WSTRING(Global_State)); 
    Test.xExecute := TRUE;  
    WHILE (Test.xBusy = TRUE) DO
        IF (Test.xDone = TRUE AND Test.xError = TRUE) THEN
            Test.xExecute := FALSE;
        END_IF
    END_WHILE
    

    if i set Test.xExecute := TRUE xDone and xError are not going to TRUE?

    so what make i worng?

    Thanks
    Bruno

     
  • TimvH

    TimvH - 2015-06-05

    Several things might go wrong:
    1) It seems you are not calling Test. Maybe you want to call the FB like:
    Test();
    Otherwise nothing is executed.
    2) In PC programming it might work that you stay in the WHILE loop, but this is pretty dangerous in PLC programming, because your I/O will not be updated. Besides that, most FB's are acyclic, which means it might take several scans before the Test() FB is Done, or an Error will happen.
    Therefore you might want to consider using another way of calling this, and not staying in the while loop.
    3) xDone, xBusy, xError will never be TRUE at the same time. Normally you keep xExecute TRUE untill xDone OR xError is TRUE. Then you can set xExecute to FALSE.

     

Log in to post a comment.