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

How to read time from signals

  • IzitoI

    IzitoI - 2019-11-29

    Hi everyone,

    I'm quite new to CodeSys. I'm dealing with an OPC DA project. The scenario is as follows:

    I have a PID block. I want to store in an array the timestamp of each output value, whenever it changes. In this case the OP.

    How can I achieve that?

    Thank you.

  • i-campbell

    i-campbell - 2019-11-30

    DTUtil library has a get time function.
    You might need to setup the timezone if you don't want to use UTC. (Although, you should always use UTC for control!)

    Then you just need some data compare logic. Perhaps you will have some minimum change value?
    So, here is a typical data change detector..

    IF (PID_0.OP > (lastOP + deadband)) OR 
           (PID_0.OP < (lastOP - deadband)) THEN
         //store the array...
         lastOP := PID_0.OP;

    Let us know how you go with your code.


Log in to post a comment.