I need to seperate the day from the month on %SW52 on Unity Pro. I convert the BCD to INT and end up with a number eg. 0630. How do i extract the day and month to seperate variables?
After hours of searching, finally found my answer. Thanks to Lare. http://www.plctalk.net/qanda/showthread.php?t=51902 . I had found the shift block but was converting the BCD to INT before using shift. Wrong. Shifting the BCD first, then converting allowed me to extract the day of the month.
Or you can just DIV by 100 to get the month once converting BCD to INT, and then MOD by 100 to get the days. I use this with the Hours / Minutes register %SW51 for providing a time register to some of the "less capable" RTUs which they can easily interpret.
Or you can just DIV by 100 to get the month once converting BCD to INT, and then MOD by 100 to get the days. I use this with the Hours / Minutes register %SW51 for providing a time register to some of the "less capable" RTUs which they can easily interpret.
Or this also works. Dividing with 100 to get the month. After this multiple month with 100 and subtract from original month_day format to get the days.