Shop OBEX P1 Docs P2 Docs Learn Events
differentiating time — Parallax Forums

differentiating time

press9761press9761 Posts: 6
edited 2006-01-17 15:03 in BASIC Stamp
Hello:

I'm looking for some suggestions on how differentiate time, not tell time.

Let me explain:

I am using a DS1302 to tell time. I am trying to delay my programs operation using the time. Let me give you a step-by-step example of what I'm trying to accomplish.

1. You press a button
2. An LCD will display “button press”-(let's say) for one second
3. one second has passed
4. the LCD will display something else.

Using the pause function is unacceptable. The program I am writing is very large and may not pause operation at any time.

The problem lies in the fact that I couldn't possibly know what time someone is going to press the button. So, the stamp would have to understand change from one second to the next. I cannot find a way to do this.

I hope someone has a suggestion. This is very frustrating for me.

Thank you

JP

Comments

  • metron9metron9 Posts: 1,100
    edited 2006-01-17 06:49
    Just mark the time when the user presses the button then test that time against the new time that gets updated by the DS1302


    Buttonpressedroutine
    buttontime=timefromDS1302
    display LCD message
    endbuttonroutine

    mainloop
    if buttontime is less than (timefromDS1302 minus one second) one second has passed so clear the LCD
    .....
    ......
    gotomainloop

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Think outside the BOX!
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-01-17 07:02
    You could create a state-driven program that handles the display. What you'll want to do when setting a new state is read the seconds register, update the target value, display the string, then go on about your business. Somewhere in the main loop you'll be reading the time and when it matches the target time you change to the next state.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • press9761press9761 Posts: 6
    edited 2006-01-17 07:15
    Yah.....I hear what you guy are saying. I just cant think of a way to do it.
    how about.

    write 000,secs
    read 000,secs

    if secs = secs+ 1 then.....

    no, this wont work. secs is the time var so it will read the actual time on the RTC in the if/then
    can I do,
    secs= time

    write 000,time
    read 000, time
    if time = secs +1 then......

    no I can't ( I just tried it)

    so...... this is killing me

    BTW
    that was a fast response!!!!!
  • press9761press9761 Posts: 6
    edited 2006-01-17 07:58
    got it!

    thanks metron9 and jon
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-01-17 15:03
    Are you using WRITE and READ in your code to store the seconds?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
Sign In or Register to comment.