Shop OBEX P1 Docs P2 Docs Learn Events
I want to count minutes for the hole day — Parallax Forums

I want to count minutes for the hole day

sam_sam_samsam_sam_sam Posts: 2,286
edited 2008-03-10 05:29 in General Discussion
·Hi Every One

I need a way to have a counter that is time·base on the DS1302 that i count to 65535 secs
Can any one help i have try a couple ways to do it but no luck

counter = counter + 1

I kown this·will work ........>>>>>>>>· counter = counter + 1


........>>>>>>>>>>>>>>· but how do i use the DS1302 Time Chip·as my pulse...........>>>>>>>>>>>>>>

...............>>>>>>>>>>>>>>>··· Count = DS1302 + 1

and be able to use the count to turn thing·ON and OFF

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·idea.gif·that you may have and all of your time finding them

·
·
·
·
Sam

Post Edited (sam_sam_sam) : 3/10/2008 4:31:08 AM GMT

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-03-09 20:38
    The DS1302 has its own counter(s). You just need to write a subroutine that compares two times and indicates when one time is greater than the other. You also need a subroutine that takes the time from the DS1302 and computes a time in the future given some number of seconds or seconds and minutes or seconds, minutes, and hours. Essentially, you compute the time in the future when you want to turn something ON or OFF, then, in your main program, you read the DS1302 at least once a second and compare your stored times to the current time in the DS1302. When the current time is greater than your saved "action time", you do whatever you wanted to do when that time elapsed.

    If you're wondering how to do the time arithmetic ... it's just the same way you would do it on paper.
  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2008-03-10 03:42
    Mike Green

    Thank You for your Reply

    The only thing that i came up with was this

    some code before this

    IF secs = $59 THEN
    PAUSE 1000


    counter = counter + 1

    return

    I thought that there may have a simpler way to do this

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ··Thanks for any·idea.gif·that you may have and all of your time finding them

    ·
    ·
    ·
    ·
    Sam
  • Mike GreenMike Green Posts: 23,101
    edited 2008-03-10 04:05
    What you have written will not work. For one, you've ended an IF / THEN statement with a RETURN statement. A RETURN statement is used to return from a subroutine called by a GOSUB statement. Please re-read the sections of the Parallax Basic Manual that describe the statements you're using. Second, why do you have a "PAUSE 1000"? Do you understand what that does?

    Please try what I've suggested. If you don't understand it, please ask some specific questions until you do.
    It's not as helpful to say "the only thing that I came up with" as it would be to say "I thought this ... and wrote this because I thought it would do that" or "I tried this ... and this is what happened".

    You will also need to experiment. Try out program fragments (using DEBUG and DEBUGIN) until you understand them and until they work the way you expect them to work. That way you will have a library of tested and understood fragments and subroutines that you can use for other tasks.
  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2008-03-10 04:26
    mike

    Thanks· for trying to help me

    I am just looking for a way to·count just minutes for the hole day

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ··Thanks for any·idea.gif·that you may have and all of your time finding them

    ·
    ·
    ·
    ·
    Sam
  • Mike GreenMike Green Posts: 23,101
    edited 2008-03-10 04:43
    If you still plan to use the DS1302, you can just use the DS1302's counter to do this.
    If you don't actually need the time and date and just want the elapsed time, you can
    set the time in the DS1302 to zero when your device is started, then read the time
    from the DS1302 when you're done and it already has the elapsed time in seconds,
    minutes, and hours. If you want the elapsed time in minutes, you should be able to
    compute that given the minutes and hours.
  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2008-03-10 05:11
    mike

    The reason that i want to just use the minutes is because i want to use a look up table and i want to keep it simple

    I know some where a while back some·one·used it that way and i can not find·it in Google Search·or in the forum search

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ··Thanks for any·idea.gif·that you may have and all of your time finding them

    ·
    ·
    ·
    ·
    Sam
  • Mike GreenMike Green Posts: 23,101
    edited 2008-03-10 05:29
    Read about the LOOKDOWN and the LOOKUP statements in the Basic manual.
Sign In or Register to comment.