Go Down

Topic: Help with timer structure (Read 1 time) previous topic - next topic


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!


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

Go Up