marcinmrag

edit time variable in Recipe NA HMI

11 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?

1 person likes this

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)

1 person likes this

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

I am new to SYSMAC.

I came across this trying to work out how to convert time to real. Some handy hints thanks.

Real to time is simple with "MULTIME" function. I am surprised nobody mentioned it.

Simply put time units for the first variable eg T#1s or T#1h. Then put real value (or any data type) in second variable and output will be correct time variable.

Share this post


Link to post
Share on other sites
On 1/11/2021 at 1:23 PM, IO_Rack said:

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;

Thanks IO_Rack. I was looking for this solution. Works perfectly.

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