IamJon Posted August 8, 2012 Report Posted August 8, 2012 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. Quote
IamJon Posted August 8, 2012 Author Report Posted August 8, 2012 (edited) 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 August 8, 2012 by IamJon Quote
Groo Posted August 8, 2012 Report Posted August 8, 2012 when you say you have a block, are you using the Siemens IEC Timer SFB4 "TON"? Quote
IamJon Posted August 8, 2012 Author Report Posted August 8, 2012 (edited) 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 August 8, 2012 by IamJon Quote
Groo Posted August 8, 2012 Report Posted August 8, 2012 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. Quote
IamJon Posted August 8, 2012 Author Report Posted August 8, 2012 (edited) 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 August 8, 2012 by IamJon Quote
JesperMP Posted August 11, 2012 Report Posted August 11, 2012 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. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.