Go Down

Topic: Help with timer structure (Read 808 times) previous topic - next topic

ivirban

Hello my friends!
I am a newbie, just have an Arduino and I have following problem:
Science I don't like to use delay function for timming, I would like to use something more real-time functions, like PLC's have.
What I tried to create was something like a timer structure, with following members:
EN-enable (active as long as conditions are true)
TT-Timer Timing (active as long as timer is counting, but not reached a preset value)
DN - Done (active when condition is On and ACCumulated value reached PREset value).
I try to calculate Accumulated value by registering time before and after Acc value calculation, like this:

     start_time = micros();
     timer1_acc = timer1_acc + start_time - end_time;
     end_time = micros();

seems to work, but the result is not accurate at all. Actually is 4 times bigger than it shoult be,probably becouse it can return me only multimples of 4 and scan is seen as being like a microsec, but it counts 4. I don't know the bahaviour on bigger programs.
Did any of you try to do something similar?

Can this be implemented in a library?

Best regards!

Udo Klein

Check out my experiments http://blog.blinkenlight.net

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy