Shop OBEX P1 Docs P2 Docs Learn Events
GoodTimeCount Program — Parallax Forums

GoodTimeCount Program

piguy101piguy101 Posts: 248
edited 2011-12-30 13:44 in Propeller 1
I just got the Propeller Education Kit on Christmas (great gift, by the way) and I think the GoodTimeCount program on page 66 in the manual is over complicated. The program just keeps track of the real time in seconds and uses modulus operator to determine when minutes, hours, and days have passed. Below the program, it says that the program will fail when seconds = 2^31 - 1 because the seconds will reset to -2^31 + 1. Instead of using modulus, could the program wait for seconds to get to 60 and reset the seconds? This way the program could run for 2^31 -1 years. I know this is kind of pointless because of the low crystal accuracy, but would this work? Please keep in mind I've only had the Propeller for a few days. Thank you for your time.

Comments

  • MagIO2MagIO2 Posts: 2,243
    edited 2011-12-29 23:07
    2^31-1 seconds is something around 68 years. So, if your plans are to have a propeller system up and running for more that timespan, you should really think about a solution. Maybe you are building an interstellar sattelite?

    I think the idea of not resetting the seconds is that you can easily build the difference of two points in time. For example an event occurred today and the next event can occur 20 days later. By not resetting the seconds since startup you only have to record this value and you can calculate days only ... or days and hours ....
  • piguy101piguy101 Posts: 248
    edited 2011-12-30 13:44
    I have never thought of it like that, you could just return the value in seconds and then the prosseser could use modulus to convert it to usable data to a person.
Sign In or Register to comment.