Hours calculation between different dates on a DS1302
Sutton Murray
Posts: 88
I want to build an hour meter for a diesel engine. My thoughts was to make use of the DS1302 IC. I am getting stuck with calculating the amount of hours between the different dates. I thought it would be as easy as one will calaculate this on a normal calculator. But i realized that things aren't working as i was thinking.
Can any one maybe help me with an example?
Can any one maybe help me with an example?
Comments
If you need to calculate across year boundaries just add in the total hours from th past year, and continue on from 8760 upward.
It becomes a more difficult if you have to do it down to the minute, because there are 525,600 minutes in a non-leap year, and that requires a double precision (32 bit) calculation. But it is the most convenient way to do many time calculations, otherwise it a a tangle of mixed base of 60/24/356,366.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Tracey thank you for the sample, i have looked at your web site (your examples). I can/have a lot to learn. Great examples i will be going through this.
I should be coming right with the examples.
Thanks to you and your Web site.