Kiwikev Posted December 8, 2006 Report Posted December 8, 2006 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 Quote
JesperMP Posted December 8, 2006 Report Posted December 8, 2006 (edited) 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 December 8, 2006 by JesperMP Quote
Kiwikev Posted December 8, 2006 Author Report Posted December 8, 2006 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 Quote
varlux Posted December 10, 2006 Report Posted December 10, 2006 (edited) 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 December 10, 2006 by varlux 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.