skyfox

Timer Instruction. Clarity Needed

8 posts in this topic

Looking at the image below,

Q1. How can I pass the value of a variable (integer or DINT) in to my timer preset variable "T1_PRE" which is a Time data type. Short of creating a custom timer function, is there any way to have the native "TON" timer's "PT" and "ET" have their values in just seconds or milliseconds? 

Q2. How do I pass a a value of 2500ms in to this Time data type from an NB series HMI?  

Q3. TON instruction summary says "PT" & "ET" values are set in "ms". But below it states time is set in nanoseconds? Can someone explain this?

Thanks.

TON.png.32e57d48e39ab1fd184e38d77a0e3776

Share this post


Link to post
Share on other sites

Just found the "SecToTime" and "TimeToSec" functions. So for Q1 & Q2, I have the answer. Still would like to get a clarification on Q3.

Share this post


Link to post
Share on other sites
35 minutes ago, skyfox said:

Looking at the image below,

Q1. How can I pass the value of a variable (integer or DINT) in to my timer preset variable "T1_PRE" which is a Time data type. Short of creating a custom timer function, is there any way to have the native "TON" timer's "PT" and "ET" have their values in just seconds or milliseconds? 

Q2. How do I pass a a value of 2500ms in to this Time data type from an NB series HMI?  

Q3. TON instruction summary says "PT" & "ET" values are set in "ms". But below it states time is set in nanoseconds? Can someone explain this?

Thanks.

TON.png.32e57d48e39ab1fd184e38d77a0e3776

 

Q3 - The timer is capable of nanoseconds and is set with them behind the scenes so to speak but only ms can be specified for a value. You can use 100.43ms for example though.

 

Share this post


Link to post
Share on other sites

Thanks.

Is it possible to just extract minutes and seconds out of Time data type in to 2 integer data types? Is the Time data type structure described anywhere in detail?

Share this post


Link to post
Share on other sites

have not used Omron in long time so my best guess is that it is a 64-bit value (8bytes). if you prefix literal with DT# it should be in seconds and format may be YYYY-MM-dd-hh:mm-cs. which would make everything single byte except year. not sure if BCD or BCI coded. again, just a guess, not confirmed. you may also try DTToSec instruction, then rest should be easy. good luck

Share this post


Link to post
Share on other sites

Thank you. I will dig around a bit.

Cheers.

Share this post


Link to post
Share on other sites

The time datatype is quite simple. At the core it is a LINT and it represents the nanoseconds of time.

Extracting mins and secs would be fairly simple. Use TimeToSec to get seconds and then a little math to figure out mins/secs.

1 person likes this

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