Issue with Timer-Based Increment Function in CoDeSys Ladder Logic (LD)

lamine97
2025-03-25
2025-08-12
  • lamine97 - 2025-03-25

    I am trying to implement a Ladder Logic (LD) function block in CoDeSys that increments a value A by B every T time interval. My Structured Text (ST) version works perfectly in simulation, but when I implement it in LD, it does not work.

    The ST code:

    PROGRAM ADDITION

    VAR_INPUT

    A : LREAL ;

    B : LREAL ;

    T : TIME ;

    END_VAR

    VAR

    Timer : TON ;

    END_VAR

    Timer (IN:=TRUE, PT := T);

    IF Timer.Q THEN

    A := A + B ;

    Timer(IN := FALSE ) ;

    END_IF;

     
  • ek-sheep

    ek-sheep - 2025-08-12

    Hi Lamine97, if you are struggling with the LD implementation it would be more helpful for us to see that code in a screenshot.

     

Log in to post a comment.