TIME() function not available?

Mehr
5 Monate 1 Woche her #277 von 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?

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
5 Monate 1 Woche her #278 von Walter Zögernitz
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

Haushaltsqualität ist für mich zu wenig!

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
5 Monate 4 Tage her - 5 Monate 4 Tage her #279 von 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.
Letzte Änderung: 5 Monate 4 Tage her von Sergey Romanov.

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
4 Monate 4 Wochen her #281 von Sergey Romanov
Can you place here an example how TON is made inside?

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
4 Monate 4 Wochen her #283 von Walter Zögernitz
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

Haushaltsqualität ist für mich zu wenig!

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
4 Monate 6 Tage her #290 von Walter Zögernitz
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

Haushaltsqualität ist für mich zu wenig!

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

logi.cals Österreich

Adresse

Europaplatz 7/1,
3100 St. Pölten

logi.cals Deutschland

Adresse

Postfach 1306,
40738 Langenfeld

Benutzer

Registrieren
© 1987 - 2018 logi.cals GmbH