total seconds into minutes and seconds

irondesk40

Member
Join Date
Jan 2008
Location
nc
Posts
630
With some advice i got from this site, been working on a small project that i heating a plate and then letting plate cool and then reheat plate over and over and then tracking total time it takes to heat and cool and then determining the average.
Now wondering what would be the best approach to take a total of for example 1067 seconds and convert to minutes and seconds? If i take the 1067 divide it by 60 you end up with 17.83 minutes, any good advice on best approach to take the .83 and convert it to seconds? if i take the .83 and mulitply that by 60 it comes up as 49.8 seconds which i can display as the total seconds, so i am now displaying 17 minutes and 49 seconds. Just wondering how some of you with approach this? Thanks
 
I would use a one second pulse to track the heating and cooling time. The pulse would increment a register which would count the seconds. When the register equalled 60 seconds I would use a compare function to increment a minute count register and at the same time the second count register would be zeroed to carry on with the next 60 second count. This method would mean you always have a minute and second count without having to do the conversion maths.

James
 
thanks, i played with that approach as well, i am using a 1 sec time base and adding, it just seemed easier at the time to take the total seconds the first time, then the total seconds the second time and add them together and divide by 60 to convert for average minutes it took. Will get a chance to look at it again when i get back in the office next week, was playing around on the bench with a 1200 micrologix, but had this week off and just starting thinking about it again today.
 
Just be aware,if the result of a DIV in AB are sent to an integer (N) then the results are rounded. To preserve the remaining part either send the result to a float then extract the fractional part or read the manual on the DIV command - the unrounded quotient and remainder may be in the Math Register.
 
With some advice i got from this site, been working on a small project that i heating a plate and then letting plate cool and then reheat plate over and over and then tracking total time it takes to heat and cool and then determining the average.
Now wondering what would be the best approach to take a total of for example 1067 seconds and convert to minutes and seconds? If i take the 1067 divide it by 60 you end up with 17.83 minutes, any good advice on best approach to take the .83 and convert it to seconds? if i take the .83 and mulitply that by 60 it comes up as 49.8 seconds which i can display as the total seconds, so i am now displaying 17 minutes and 49 seconds. Just wondering how some of you with approach this? Thanks
Hi,
I think you are on the right way.
The problem is you only have two significant figures after the komma.
min = (INT)(1067 / 60)
==> min = 17
sek = counter - (min * 60)
sek = 1067 - (17 * 60)
sek = 47

BTW, 1067 / 60 = 17,78 (not 17.83)


br
bb
 
Last edited:
Paul,

If I am not completely senile, then you have some extra "do nothing" Divide instructions in the first line and the third branch. After each of these DIVs, you immediately Move S:14 to the same location, overwriting the results of the previous Divide instructions (making them null and void).

But I am old and worn-out, so could be also missing something.
 
The two sections of the math register after a DIV contain the UNROUNDED quotient and the remainder. So its ok that he's overwriting as he doesn't want the ROUNDED quotient anyway but has to have a destination for the DIV instruction.

And I'm pretty close to being completely senile.
 
Oh. I see.

I can feel the brain cells dying. I have this condition called Cerebrospinal Fluid Leak. My brain fluid leaks out, allowing my brain to drop down and put pressure on optic and auditory nerves, causing bad headaches and major confusion. It can be caused by hard blow to the head. Probably it was that time I rolled the wheel loader 90 degrees and cracked my head on the rollover bar.

I am fighting it hard.
 
Last edited:
Here's my take on the subject

Nice and compact Mickey.

However, just a warning for you and others - If you use this method on the Logix5000 series it won't produce the right results.

This is because the Rounding Algorithm used in Logix5000 is the "Round-to-Even" method, not the traditional "0.5 and above - round up" method.

The following table shows the result of storing REAL values ending in exactly .5 to a DINT

0.5 = 0
1.5 = 2
2.5 = 2
3.5 = 4
4.5 = 4
5.5 = 6
6.5 = 6

and so on
 
Paul,

If I am not completely senile, then you have some extra "do nothing" Divide instructions in the first line and the third branch. After each of these DIVs, you immediately Move S:14 to the same location, overwriting the results of the previous Divide instructions (making them null and void).

But I am old and worn-out, so could be also missing something.


LOL. Bernie beat me to it. Yeah, sometimes you don't want the rounded value.

I set this up for some heat treatment cells we have. They were old when I got here, and a couple of years ago we refurbed them. It always bugged me that the existing HMIs only displayed seconds; I wanted the OPRs to be able to see min:sec for time remaining. With Logix500, this is a pretty easy way to do it.
 
2 ways Paul. You can use a TRN block (RS5000).
From the help file.
The TRN instruction removes (truncates) the fractional part of the Source and stores the result in the Destination.

You could also subtract .5 and then move the result into an integer. That method has been discussed here before.
 

Similar Topics

Hi All, I have a SLC 500 & RSView 32 project that exports reports to Excel 2003. A portion of the report has a column with "total seconds"...
Replies
5
Views
3,575
I'm being tasked with supporting / upgrading these panels but no software, cable, documentation. I have an old laptop running XP and would like...
Replies
4
Views
2,003
Hi everyone, I'm trying to perform a serial download with a Total Control Quickpanel jr (QPK-2xxxx) using an old computer running QuickDesigner...
Replies
3
Views
1,712
Does anyone know where I might get a copy of development software for a TCP HMI?
Replies
4
Views
2,293
Is there a way to count the number of tags (including dot fields) in RSLogix 5000 automatically? When I export the tag database and open it in...
Replies
4
Views
3,048
Back
Top Bottom