Purpose
This guide shows the users how to display the TIME data on an HMI without displaying all the nanoseconds.
Using a data display object, users are able to see the time in the following format 00:00:00.0000000.
Some users prefer to display the time without the complete decimal seconds, displaying only HOUR:MINUTES:SECONDS to show 00:00:00.
Problem Explanation/Objective
The predetermined displays of NA5 HMI show a complete format of TIME data and do not allow the users to set just the TIME data they want to display.
Supported devices
- NA5 HMI
- NX or NJ Controllers
Requirements
For this example:
- NA5-7W001
- NX102-9000
- Sysmac Studio
Procedure
1 - On the Program section of the controller, use the following ST code:
TEST_TIME is a TIME DataType variable
TIME_STRING and TIME_STRING2 is a STRING[] DataType variable
To get a string with HH:MM:SS format for dispaly from a TIME DataType you can use the below code:
(* Convert Time to String HH:MM:SS format for Display *)
TIME_STRING := LEFT(TodToString(SecToTod(TimeToSec(TEST_TIME))),UINT#8);
If you want to display with miliseconds in the format (HH:MM:SS.SSS) then you need to do two TIME conversions to strip the lower decimals from the nanosecond conversion and CONCAT the two strings with a decimal in between:
(* Convert Time to String HH:MM:SS.SSS format for Display *)
Time_String :=
CONCAT(LEFT(TodToString(SecToTod(TimeToSec(Test_Time))),UINT#8),'.',LEFT(RIGHT(LINT_TO_STRING(TimeToNanoSec(Test_Time)), UINT#9),UINT#3));
2 - Create the variables from the Controller on the HMI (Remember that the controller variables must be Global so they can be mapped).
3 - Add two data displays and set both with a data type of TEXT.
4 - Test the functionality with the Simulator:
Date/Revision History
First review 09/22/2025 V1.0
Author:
Karla Flores Avila, Technical Support Specialist
References
Time display formatting question - NJ Series / Sysmac Studio - MrPLC.com
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article