Pages: [1]   Go Down
Author Topic: Help with timer structure  (Read 680 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Karma: 0
Posts: 1
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!

Offline Offline
Faraday Member
Karma: 24
Posts: 3496
20 LEDs are enough
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You mean like this library ?

Check out my experiments

Pages: [1]   Go Up
Jump to: