Search code examples
timetypesautomationtimerplc

Omron PLC elpsed time


I'm wokring on project with Omron PLC, I need to show on HMI elapsed time after I started my system but problem is that, I can see my time just in seconds but I need in hour and min type. How to display elapsed time in hour and minute type from Omron Nx1 PLC to HMI?


Solution

  • One solution is to calculate the total hours and minutes from the total secconds and display on the HMI. You could concatenate the values into a string, but since I don't know what your purpose is, it's easier to use the values directly in integers with two different variables.

    As you didn't define the language, here's an example in Structured-text. The Time given in Seconds in TotalSeconds will be separated into Hours and Minutes (and also Seconds as a bonus!).

    Note: I'm putting the variable declaration as text, but I know that in Sysmac it is possible to declare it as a table...

    Declaration

    VAR
        TotalSeconds : DINT;
        Seconds : DINT;
        Minutes : DINT;
        Hours : DINT;
        rest : DINT;
    END_VAR
    

    Program

    rest := TotalSeconds MOD 3600;
    Seconds := rest MOD 60;
    Minutes := (rest - seconds) / 60;
    Hours := (TotalSeconds - rest) / 3600;
    

    Example

      242 s >>> 0 h /  4 min /  2 s
    33868 s >>> 9 h / 24 min / 28 s