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

CTU

tomoklc
2013-01-09
2013-01-09
  • tomoklc - 2013-01-09

    Please can anybody tell me how to create counter up with math instructions??

     
  • TimvH

    TimvH - 2013-01-09

    Hi, do you mean structured text?
    If yes, you can use it like this:

    PROGRAM PLC_PRG
    VAR
       fbCTU1: CTU;
       xCountUp1: BOOL;
       uiCounter1: UINT;
       xReset1: BOOL;
       xCountUp2: BOOL;
       uiCounter2: UINT;
       xReset2: BOOL;
    END_VAR
    
    // CTU Function-block
    fbCTU1(
       CU:= xCountUp1, 
       RESET:= xReset1, 
       PV:= 100, 
       Q=> , 
       CV=> uiCounter1);
       
    // Or
    IF xCountUp2 THEN
       uiCounter2 := uiCounter2 + 1;
       xCountUp2 := FALSE;
    END_IF
    IF xReset2 THEN
       uiCounter2 := 0;
    END_IF
    
     
  • tomoklc - 2013-01-09

    Thank for that, but I must do CTU in ladder diagram only with math and compare instruction!

     
  • tomoklc - 2013-01-09

    Everytime when I put "1" on my firt input some memory registar must increase for 1.

     
  • TimvH

    TimvH - 2013-01-09

    See screenshot for an example

    IMG: ScreenShot.jpg

     

Log in to post a comment.