TIME() function not available?

More
1 year 5 months ago #277 by Sergey Romanov
I am trying to create my own TON block with additional features. In Codesys I used to use TIME() function.
FUNCTION_BLOCK TON
    VAR_INPUT
        IN: BOOL;
        PT: TIME;
    END_VAR
    VAR_OUTPUT
        Q:  BOOL;
        ET: TIME; 
    END_VAR
    VAR
        M: BOOL;          
        StartTime: TIME;  
    END_VAR

    IF (IN) THEN
        IF (NOT M) THEN
            StartTime := TIME();
        END_IF
        IF (NOT Q) THEN
            ET := TIME() - StartTime;
            IF (ET >= PT) THEN
                Q := TRUE;
                ET := PT;
            END_IF
        END_IF
    ELSE
        Q := FALSE;
        ET := t#0s;
    END_IF
    M := IN;
END_FUNCTION_BLOCK

Pretty much straightforward. But function TIME() gets underlined. DO you have support for TIME()? What can I use?

Please Log in or Create an account to join the conversation.

  • Walter Zögernitz
  • Visitor
  • Visitor
1 year 5 months ago #278 by Walter Zögernitz
Replied by Walter Zögernitz on topic TIME() function not available?
Hello Sergey,

"time" in logi.CAD 3 is a reserved word for the data type "time".
For writing down the current time value into a variable in your PLC program you have to get sure, that your target system supports a (system)clock.

For getting the value of the system time into a PLC variable you can use a C-function block like the one in this link:
github.com/rpoisel/lc3-lib/tree/master/System
Please note, that this code is only supported in linux systems.

kind regards
Walter

Please Log in or Create an account to join the conversation.

More
1 year 5 months ago - 1 year 5 months ago #279 by Sergey Romanov
It is not exactly what I want. I do not want to get current RTC. TIME() in codesys returns amount of milliseconds passed from controller starts. And this information should not depend on controller but on RTS, RTS should measure ticks and update that time. It is like Step1.T internal variable of STEP ... END_STEP. Counts time passed from step become active. We need something like PROGRAM.T. Internal programm variable that will return time passed from program started to run.

In Codesys TIME also reserved for TIME data type, but TIME() function return time value.

I am sorry that I always compare you to Codesys, but I think this is what users who already have experience any try to use your system will also try to solve.
Last edit: 1 year 5 months ago by Sergey Romanov.

Please Log in or Create an account to join the conversation.

More
1 year 4 months ago #281 by Sergey Romanov
Can you place here an example how TON is made inside?

Please Log in or Create an account to join the conversation.

  • Walter Zögernitz
  • Visitor
  • Visitor
1 year 4 months ago #283 by Walter Zögernitz
Replied by Walter Zögernitz on topic TIME() function not available?
Hello Sergey,


sorry for my late reply.
You can use logi.CAD 3's "GET_EP_TICKS" block for your time reference. This is not directly based on the system clock.
Please see the description for this block in our online help:
help.logicals.com/display/LC3UserDocuEN/GET_EP_TICKS-Baustein

logi.CAD 3's TON in the standard library is coded internally so that there is no fbd code available for it.
I can give you some further tipps a little later.


kind regards
Walter

Please Log in or Create an account to join the conversation.

  • Walter Zögernitz
  • Visitor
  • Visitor
1 year 4 months ago #290 by Walter Zögernitz
Replied by Walter Zögernitz on topic TIME() function not available?
Hello Sergey,

As promised, here please find a sample code for an quick made "my_TON" POU using the timer ticks:

using logicals.standard.util.schedule;

FUNCTION_BLOCK MY_TON

VAR_INPUT
PT: ULINT;
ACTIVE: BOOL;
END_VAR

VAR_OUTPUT
ET: ULINT;
Output:BOOL; 
END_VAR

VAR
  currentvalue,startvalue:ULINT;
  R_TRG: R_TRIG;
END_VAR

GET_EP_TICKS(GET_EP_TICKS=>currentvalue);
R_TRG(CLK:=ACTIVE);
IF R_TRG.Q THEN startvalue:=currentvalue; END_IF;
IF startvalue+PT<currentvalue AND ACTIVE THEN Output:=TRUE;
ELSE Output:=FALSE; END_IF;
IF ACTIVE THEN ET:=currentvalue-startvalue;
ELSE ET:=0; END_IF;

END_FUNCTION_BLOCK



kind regards
Walter

Please Log in or Create an account to join the conversation.

LOGI.CALS AUSTRIA

Address

Europaplatz 7/1,
3100 St. Pölten

LOGI.CALS GERMANY

Address

Postfach 1306,
40738 Langenfeld
© 1987 - 2019 logi.cals GmbH