View Full Version : differentiating time

01-17-2006, 01:14 PM

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


01-17-2006, 01:49 PM
Just mark the time when the user presses the button then test that time against the new time that gets updated by the DS1302

display LCD message

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

Think outside the BOX!

Jon Williams
01-17-2006, 02:02 PM
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

01-17-2006, 02:15 PM
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

that was a fast response!!!!!

01-17-2006, 02:58 PM
got it!

thanks metron9 and jon

Chris Savage
01-17-2006, 10:03 PM
Are you using WRITE and READ in your code to store the seconds?

Chris Savage
Parallax Tech Support
csavage@parallax.com (mailto:csavage@parallax.com)