Go Down

Topic: Time functions (Read 4 times) previous topic - next topic

GoForSmoke


Quote
At a sports event when a race starts they don't look at the clock and note that is say 10:15:35 and when the race ends they don't subtract the final time from the start time. No they start a stopwatch from 0 at the beginning of the race, and note the time at the end.

That's quite true, because they have a hardware timer that can do that. The Arduino doesn't, and so a different technique is required.


Not true. He could go to the extra trouble to set up a timer and interrupt and have his stopwatch. Hell, it's possible to reset the millis() counter with precautions on how you do it.

We just tried to take him through the -easy- way but what the heck do WE know?
I find it harder to express logic in English than in Code.
Sometimes an example says more than many times as many words.

Ramigrafx



Thanks to those trying to help


So ? Did you try my working sketch ?


Thanks Krodal. I have printed out your sketch and am currently going through it, trying to understand it.
I am writting my sketch at the moment so it is helping me, together with many other pieces of information I have gathered.

Ramigrafx


Quote
If PaulS looked at my sample sketch at reply#4 that I have been using with delay in it he would understand what I was trying to do.

I did look at it. If you'd read #3, you'd know that.

Quote
Thanks to those trying to help

What part have you contributed? What have you come up with? Are you expecting us to write the code for you?


I am trying to write the code myself, when I understand the procedure. I don't want anyone to do it for me.
If you are going to get so bad tempered I suggest that you chill out for a while and give this job a rest. You put people off.

PaulS

Quote
If you are going to get so bad tempered I suggest that you chill out for a while and give this job a rest.

Fine. Good luck.

GoForSmoke

Look, Rami,

The chip has counter-timer circuits inside. Every cycle they add 1 and you know by your cycle time how many ticks makes a millisecond and that adds 1 to another memory register. That already happens. That's what's behind millis().

You can -make- your own count-down timer. You can put a time value in a volatile global variable and run an interrupt off a timer so when it rolls over the IRQ decrements the time value. Then your regular code has until the next interrupt to recognize when the value hits zero -or- it can know the time passed zero -if- it keeps the last time value stored and not be time-critical. If your time value increments are 1 ms or more then tight code will never miss when it zeroes.

You can make one without interrupt, IRQ and volatile variables just by using code that uses... millis(), and it will be simpler and work cleaner.

It's up to you.......
I find it harder to express logic in English than in Code.
Sometimes an example says more than many times as many words.

Go Up