Sign in to follow this  
Followers 0
IamJon

Math with data type TIME?

7 posts in this topic

I have a block that mimics the AB TON functionality. The ACCUM and Setpoint are both TIME data types. I need to turn on a warning light when I have a time difference of 10s between ACCUM and Setpoint. Can I convert the TIME data to an Int? Or is there any way to do this? It almost seems like I will need to change all my TON data types to a standard S_ODT timer. It already has the remaining time etc, I would just need to convert it from BCD to Int.

Share this post


Link to post
Share on other sites
So I'm trying to use the S_ODT timer now. I can choose the BI time left address, which is a WORD, or the BCD. Siemens has no WORD to INT converter, and BCD is not an optional data type when I create a tag. I need to compare either the BI or BCD to 10 in order to start flashing my light. How can I do this? ETA: Nevermind, I was only looking in the LAD help. I can do it in STL. Edited by IamJon

Share this post


Link to post
Share on other sites
when you say you have a block, are you using the Siemens IEC Timer SFB4 "TON"?

Share this post


Link to post
Share on other sites
I WAS going to use that, but I can't do anything with the TIME data type that uses. I'm switching to the S_ODT timer. Even though the BI is a WORD data type, it seems if I do a <I in STL, it lets me compare a WORD with an integer value of 10. Sound correct? ETA: It saved and compiled, so I think I got it. And yes, it was SFB4. Edited by IamJon

Share this post


Link to post
Share on other sites
The TIME format is mS, as Siemens describe "The data type TIME is stored with milliseconds prefix as two's complement INTEGER" a value of 1000 = 1 second.

Share this post


Link to post
Share on other sites
Just talked to Siemens. Apparently I can simply do a MOV function to move the WORD data type to INT, then do an integer compare with 10. And just to clarify, I ended up using the S_ODT timer. Edited by IamJon

Share this post


Link to post
Share on other sites
IamJon, I suggest you use the IEC timer TON, as the S5Timers are really an arcaic leftover from S5. To do math with a TIME variable, switch to STL mode, since there is no typechecking in STL. You can switch back to LAD or FBD, only the rungs that no longer can be represented as LAD or FBD will display as STL.

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
Sign in to follow this  
Followers 0