Sign in to follow this  
Followers 0
edda

Convert a Integer to S5T# (BCD?)

4 posts in this topic

Hi all! I wont to convert a int (lets say 23) and convert it to S5time (whit the result s5t#23s), I thought that S5Time was regulary BCD so that i could do this. L 23 L 100 //i dont know, something to get it to seconds. *I ITB //int to BCD T MW10 But this do not work, is there some easy way i could to this and get the same result as if wrote L S5TW23s???

Share this post


Link to post
Share on other sites
I am fairly sure that 'under the hood' the s5t data type uses the top 4 bits in the same way as S5 i.e. bits 12 & 13 are the time base, either 10ms 100ms 1s or 10s, so you would need to do something like L 23 ITB L W#16#2000 //set time base bits to 1 sec OW // combine with required interval T MW10 Also remeber that internally the biggest number s5t can handle is 999 so if you need more than 15 mins you have to use 10s timebase One way out of this is to make your own 'timer' up from an adder and comparitor, and use a 1 sec timebase contact. Then you could go up to 2^31 secs if you you use a DINT for the counting register Havnt got s7 in front of me so syntax above is done from memory

Share this post


Link to post
Share on other sites
Mike's code is correct for generating an S5TIME. For an alternative to the S5Timer, why not use the IEC timers ?

Share this post


Link to post
Share on other sites
Thank You! I´ll try this later on today! Why I´m using S5 timer is becuse we normaly do this in the company, so just stickin to the standard.

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