Sign in to follow this  
Followers 0
pete3589

S5Time Math functions

4 posts in this topic

I have a progam where I need to find the time remaining in a timer and move it to a new timer input. Basically all I need to do is take the preset time, and subrtract it from the remaining time to get this, and then move the result to the new timer. I cant simply take the value and use an integer subraction of the two values (or at least it wont work for me) cause i get a type conflict in my Subtraction block. Strangely I was able to save this block before with S5T values in the SUB_I block, but after adding a Positive edge trigger to the particular network, it will not save. I guess my question is, is there a way to add or subtract words that are S5T's and get the result in a S5T? Ex. S5T#100ms - S5T#10ms = S5T#90MS

Share this post


Link to post
Share on other sites
Try something like this; L S5T#100MS //Initial Timer value (100ms) L T 10 // Current time value -I // calculation ITB // convert to BCD L 2#1000000000000 // load mask OW //Or the word T MW 12 //transfer to MW 12 to use in new timer. (Note: Not tested)

Share this post


Link to post
Share on other sites
I dont understand how you are able to simply subtract the first 2 S5T numbers. Granted I dont use STL (mostly LAD), but the main problem was that I cannot subtract the S5T values using a SUB_I function in Ladder. Would I be able to do this in STL? (sorry I dont have S7 in front of me to test this out)

Share this post


Link to post
Share on other sites
For Siemens timers, the remaining time is output in either Integer or BCD format as standard, no maths function required. You could take the BCD value direct but you would need to add a time base value by OR'ing one of the following: No OR, as is for 10mS time base. 0001 0000 0000 0000 = 100mS 0010 0000 0000 0000 = 1S 0011 0000 0000 0000 = 10S Edited by Groo

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