Help - Search - Members - Calendar
Full Version: converting timer to display minutes and seconds
Forums.MrPLC.com > PLCs and Supporting Devices > Allen Bradley
bill n tn
I am creating a count down timer in a control logix , I have subtracted the acc from the preset and dumping this in a dint called remaining time and i want to display this in minutes and seconds. I can get the minutes working but I am having trouble with the seconds. I am div the remaining time by 60000 to get the minutes and putting this into a dint called minutes. I have tried div tag minutes buy 1000 and this does not work. I am displaying this in a PV+. I am fairly new to Allen Bradley, any suggestions?
BobLfoot
QUOTE (bill n tn @ Jun 26 2009, 06:24 PM) *
I am creating a count down timer in a control logix , I have subtracted the acc from the preset and dumping this in a dint called remaining time and i want to display this in minutes and seconds. I can get the minutes working but I am having trouble with the seconds. I am div the remaining time by 60000 to get the minutes and putting this into a dint called minutes. I have tried div tag minutes buy 1000 and this does not work. I am displaying this in a PV+. I am fairly new to Allen Bradley, any suggestions?


Okay let me lay out what I am reading from your post.

1. You have a tag called CountDownTimer.
2. You are doing math as follows : CountDownTimer.PRE - CountDownTimer.ACC = TimeRemaining {type DINT}
3. You are doing math as follows : TimeRemaining DIV 60000 = MinutesRemaining {type DINT}
4. You need to do the following math to get the SecondsRemaining {type DINT}
4a. TimeRemaining DIV 60000 = MinutesRemainingFloat {type REAL}
4b. MinutesRemainingFloat {type REAL} - MinutesRemaining {type DINT} = SecondsRemainingFloat {type REAL}
4c. SecondsRemainingFloat {type REAL} MUL 60 = SecondsRemaining {type DINT}

Hope the above is clear enough. There are other ways but this one will do.
bill n tn
at one time I was using the real(floating point) but I was div by 60 instead of multiplying. Thanks for the help!!!!!





QUOTE (BobLfoot @ Jun 26 2009, 09:22 PM) *
QUOTE (bill n tn @ Jun 26 2009, 06:24 PM) *
I am creating a count down timer in a control logix , I have subtracted the acc from the preset and dumping this in a dint called remaining time and i want to display this in minutes and seconds. I can get the minutes working but I am having trouble with the seconds. I am div the remaining time by 60000 to get the minutes and putting this into a dint called minutes. I have tried div tag minutes buy 1000 and this does not work. I am displaying this in a PV+. I am fairly new to Allen Bradley, any suggestions?


Okay let me lay out what I am reading from your post.

1. You have a tag called CountDownTimer.
2. You are doing math as follows : CountDownTimer.PRE - CountDownTimer.ACC = TimeRemaining {type DINT}
3. You are doing math as follows : TimeRemaining DIV 60000 = MinutesRemaining {type DINT}
4. You need to do the following math to get the SecondsRemaining {type DINT}
4a. TimeRemaining DIV 60000 = MinutesRemainingFloat {type REAL}
4b. MinutesRemainingFloat {type REAL} - MinutesRemaining {type DINT} = SecondsRemainingFloat {type REAL}
4c. SecondsRemainingFloat {type REAL} MUL 60 = SecondsRemaining {type DINT}

Hope the above is clear enough. There are other ways but this one will do.

BobLfoot
QUOTE (bill n tn @ Jun 27 2009, 09:11 AM) *
at one time I was using the real(floating point) but I was div by 60 instead of multiplying. Thanks for the help!!!!!


Glad to assist. Please let us know when you get it working or if you need more help. And Welcome to MRPLC.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.