Sign in to follow this  
Followers 0
Kiwikev

Extract Month from DT

4 posts in this topic

Hi Gang I am trying to extract the Date and Month from the DT format on a S7-417H CPU - We are using am atomic clock on site for all PLC time/dates and need to translate this to New Zealand time, taking into account Daylight saving. I have looked at FB60 and 61 and they don't help me, having the date/month will allow me to add an hour on the Sunday nearest the 26th March and remove the hour after the 26th October. Any help would be most appreciated Thanks in advance Kev

Share this post


Link to post
Share on other sites
Hi Kev. Not sure what your problem is, but you can extract the details in the Date and Time format from the individual bytes: Byte 0 Year Byte 1 Month Byte 2 Day Byte 3 Hour Byte 4 Minute Byte 5 Second Byte 6+Byte7_1st_nibble Ms Byte 7_2nd_nibble Weekday edit: Important is that all the values are BCD coded. You canvert from BCD to INt with the BTI instruction, and from INT to BCD with the ITB instruction. Edited by JesperMP

Share this post


Link to post
Share on other sites
Thanks Jesper / Kevin I had the byte addressing but was unable to get the correct data out using the DIB function - I used your code Kevin - but found a problem with the SFC 1 call - there were too many spaces between SFC and 1, but it is working now. Thanks again Kev

Share this post


Link to post
Share on other sites
It's the best and simple road to extract your data. For example, you can create a Data Block first, and save the date. Then read exclusively the right bytes. Be careful! Remember to convert BCD! Ciao Edited by varlux

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