Skip to main content

定数:TIME、LTIME

使用できます TIME 標準タイマーモジュールを操作するための定数。定数のサイズは32ビットで、解像度はミリ秒単位です。

さらに、時定数 LTIME 高解像度タイマーの時間基準として利用できます。 The LTIME 定数の次元は64ビットで、解像度はナノ秒単位です。

定数:TIME

構文

<time keyword> # <length of time>

<time keyword> : TIME | time | T | t
<length of time> : ( <number of days>d )? ( <number of hours>h )? ( <number of minutes>m )? ( <number of seconds>s )? (<number of milleseconds>ms)? // ( ...)? Optional

時間単位の順序は変更しないでください。ただし、すべての単位を指定する必要はありません。単位は大文字で指定できます。

時間単位

  • D | d: 日々

  • H | h: 時間

  • M | m: 分

  • s | s:秒

  • MS | ms:ミリ秒

185.

ST割り当ての正しい時定数

VAR
        timLength : TIME := T#14ms;
        timLength1 : TIME := T#100s12ms; // Overflow in the highest unit is allowed.
        timLength2 : TIME := T#12h34m15s;
        timCompare : TIME;
        xIsOK: BOOL;

        timLongest := T#49D17H2M47S295MS; // 4294967295
END_VAR

IF timLength < T#15MS THEN
        IF timCompare < timLength1 THEN
                xIsOK := TRUE;
        END_IF;
END_IF

誤った使用法

timIncorrect := t#5m68s;

低い位置でのオーバーフロー

timIncorrect1 := 15ms;

タイムマーカー T# ない

timIncorrect2 := t#4ms13d;

時間単位の順序が正しくありません



定数:LTIME

構文

<long time keyword> # <length of high resolution time>

<long time keyword> : LTIME | ltime
<length of high resolution time> : <length of time> ( <number of microseconds>us )?  ( <number of nanoseconds>ns )? // ( ...)? Optional

同じ単位を使用できます LTIME 定数は TIME 定数。指定された時間はより高い時間分解能で計算されるため、マイクロ秒とナノ秒を指定することもできます。 LTIME リテラルは内部的にデータ型として扱われます LWORD したがって、値はナノ秒単位で解決されます。

追加の時間単位

  • US | us:マイクロ秒

  • NS | ns:ナノ秒

186. ST割り当ての正しい使用例
PROGRAM PLC_PRG
VAR
        ltimLength := LTIME#1000d15h23m12s34ms2us44ns;
        ltimLength1 := LTIME#3445343m3424732874823ns;
END_VAR


詳細については、以下を参照してください。 データ型: TIME、LTIME定数:日付と時刻