Hello.
I'm developing a system which has to store user defined time variables, minutes and seconds. To save on eeprom, maybe it is possible to split byte into two "half bytes" and store hours and minutes in them?
Hello.
I'm developing a system which has to store user defined time variables, minutes and seconds. To save on eeprom, maybe it is possible to split byte into two "half bytes" and store hours and minutes in them?
4 bits can store 16.
So the hours can fit easily in the leftmost nibble of a byte (if you don't use 24 format), but there are 60 minutes in an hour.
Good luck jamming that in the rightmost nibble.
Robert
Yes but
24+60=84
84 needs only 7 bits (2^8=128)
so why not? just how![]()
Because 11:14 would be the exact same thing as 14:11 - how do you differentiate them?
/Henrik.
If you could live with 5 minute resolution then, I think, it is doable - easily. In the same way that 12 hours fits into the upper nibble, 5 minute increments fit in the lower.
It may also be possible to use the memory location as a partial bit - if location is even then AM, odd is PM or some such. I have not the will or the expertise to work out such a solution, but if program space is not the issue... Using the example above, it may be that you can differentiate 11:14 from 14:11 by its location? Or, perhaps you need only store the hour once every 10, 15, or 60 bytes, then use the bytes in between for only am/pm and minutes.
Last edited by Amoque; - 4th June 2014 at 14:39.
There are 1440 minutes in a day that need to be uniquely identified somehow.
Since you require 1440 "symbols" you will need at least 11 bits.
If you want to use different memory locations, you would need 6 (8 bit) locations.
Reducing the accuracy? Sampling every 5 minutes won't cut it - you will need to go to 6 minute samples to fit in a byte.
Coding time in the smallest possible binary space is a problem that has been around for at least 70 years now - likely nobody has thought about it before![]()
Bookmarks