marcinmrag

edit time variable in Recipe NA HMI

9 posts in this topic

Hello,

I would like to use one recipe parameter which is time variable. But I have problem to use time variable in HMI recipie. Can someone help me with this? How i can handle this? I can put value in INT but how can i convert it to TIME in PLC program?

Share this post


Link to post
Share on other sites

Look for NanoSecondToTime, or MillisecondsToTime instruction in NJ. You put LINT valeus of Timespan in Nanoseconds / Milliseconds in HMI then convert it to time by program.
If your time requires Hour, Minutes, Seconds, you can put each individually then calculate the total value in Nanosecs / Millisecs before converting to Time.

 

Alternatively you can implement a Custom Time Keypad in NA to input Time values directly to Time variables, although it's more complicated (requires VB Scripting)

Share this post


Link to post
Share on other sites

@innoaloe

Do you have an example of using the custom time keypad to edit the time variables directly?

This would be very much appreciated.

Share this post


Link to post
Share on other sites

Hello !

I found this topic while searching an easy way to edit TimeSpan tags in an NA-5 HMI.

Is the EditVariable() method the only way to use a TimeSpan keypad?

Using a Press Event is somewhat clunky because it doesn't seem we can pass arguments to methods called that way.

I have 16 PIDs I need to make configurable via HMI and their I and D gains are in the TIME/TimeSpan datatype.

Share this post


Link to post
Share on other sites

I'm not aware of an elegant method. I don't use the TimeSpan data type in the NA. I create Functions in the controller that will convert REAL to TIME and TIME to REAL (in seconds), then enter my time in [Seconds].[Fraction of a Second].

Share this post


Link to post
Share on other sites

The commands in the controller are NanoSecToTime and SecToTime, there is no millisecond variant.

Share this post


Link to post
Share on other sites
57 minutes ago, Crossbow said:

The commands in the controller are NanoSecToTime and SecToTime, there is no millisecond variant.

This is correct. For the purposes of reading and writing time to/from the HMI, I create the following custom Functions:

REAL_TO_TIME

REAL_tmp:=In*REAL#1000000000;
LINT_tmp:=REAL_TO_LINT(REAL_tmp);
Out:=NanoSecToTime(LINT_tmp);

 

TIME_TO_REAL

LINT_tmp:=TimeToNanoSec(In);
REAL_tmp:=LINT_TO_REAL(LINT_tmp);
Out:=REAL_tmp/REAL#1000000000;

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now