Sign in to follow this  
Followers 0
PlasticsDude

Converting decimal time to clock time

4 posts in this topic

Generally speaking, how does one convert decimal time into clock time on a PLC? Eaxmple: 1.50 minutes = 1:30 (the 1:30 gets displayed on an HMI screen) Thanks for any help!

Share this post


Link to post
Share on other sites
What PLC ( vendor, brand) are you using? Edited by Mickey

Share this post


Link to post
Share on other sites
Siemens S7...figured it would be about the same idea for most PLC's...

Share this post


Link to post
Share on other sites
I'm not familar with Siemens but the below works for AB stuff: Step 1 (1.5-.5)=1 ( result placed in an integer register, Hour component) Step 2 (1.5-1)=.5 ( subtract the above hour component from orginal number) Step 3 (.5*60)= 30 minutes ( Multiply results of step 2 by 60 this is your min. component, put result in an integer register) Only problem with this is that in step three the results could be rounded to 60 min., you might have to write logic to account for this. ( if above 59 then move 59 to min. else move min. to min.) Note when moving a floating point numbers to an integer rounding must take place. This works for AB PLC's. Not sure about Siemens. Edited by Mickey

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