Time Conversion Problem

Join Date
Feb 2009
Location
Nl
Posts
2
Good day. I have a problem that I am hoping someone will be able to help me with. I am running RsLogix 500 with a Micrologix 1100. I am doing some timing sequences, and I have run into a bit of a snag.

Basically I have a user enter (into Integers) two sets of times, one in minutes and one in hours. These two times are then multiplied by 60 and 3600 respectively, and added together to give me the total time in seconds that my timer will count down from.

EX: If I have 1 hour and 25 mins entered, I will get (1*3600) + (25*60) = 5100 seconds. When the user activates the time, this 5100 will count down to 0 (this is done with some other math functions I have incorperated).

My problem is that I need to be able to display this time (5100 seconds) on my HMI as Hours and Minutes left. Is there anyway I can have something in my code that will check how many hours are in 5100 seconds, take that number, and display it. And also find out how many minutes are left for each hour out of 60, and display it.

So basically, if I have 5100 seconds, I have 1 hour and 25 minutes. After a time of 40 minutes has past, I want it to display 0 hours and 45 mins left.

I hope I am not to confusing in my question. My biggest problem that is stopping me with most things I have tried is converting from decimal to integer.

Thanks in advance for anyone trying this problem. I'm exhausted in my attempts.



Paul
 
Try this:

BST DIV N7:0 60 S:13 NXB MOV S:13 N7:1 NXB MOV S:14 N7:2 NXB DIV N7:2 60 S:13 NXB MOV S:13 N7:2 NXB MOV S:14 N7:3 BND

N7:0 = Total Remaining Seconds

After processing

N7:3 = Remaining Hours
N7:2 = Remaining Minutes
N7:1 = Remaining Seconds
 
Several ways come to mind. But I think the easiest will be to make use of the Real Time Clock in the PLC instead of a timer.

Look in your help menu for RTC to finde the adresses to use.

Basically I would take a snaphot of my RTC value when the operator entered there time

add their input time to your snapshot. Once you have that you just need to use a compare instruction to compare your current RTC value to the calculated value your looking for and when both are equal shut down the process.

For display you take your calculated value and subtract the current RTO value. The remainder is the process time you have left.

Minutes, Seconds, and hours each have their own words so when you configure your HMI the process time needs to be broken down the same way.
 
Well I think you have absolutely no idea how easy you have just made my job. It works like a charm. You wouldn't believe how much code I was about to attempt to put in there to get this working, that is till I read your reply. Thank you very very much. Like I said, it works perfectly. Thank you!!!
 

Similar Topics

Good Day Sirs! I'm now having problem on a system that runs formerly in version 17. I upgraded it to version 24. I simply Upload the program then...
Replies
4
Views
1,468
Ran across a problem with the TwinCAT Real_To_String conversion today. I have found that if my real is 0.12345 it converts to '1.2345' It also...
Replies
2
Views
1,704
Hi all, I've exported an S5 program into a SEQ file and a AWL file. The SEQ file was not directly usable, but with an excell I was able to fix...
Replies
1
Views
1,335
Converted a PLC5 To a controllogix. In wonderware I/O servoer the tags are off. Thanks for any help.
Replies
2
Views
1,791
Hi all, I have no communication between controllogix to PanelView plus after conversion of program "rslogix 5 to rslogix 5000" and panelbuilder...
Replies
2
Views
4,006
Back
Top Bottom