How accurate is millis()?


has encountered issues accuracy of millis() when using interrupts? using 4 interrupts measure (count signal from) digital encoders.  have noted time measurement (after i'm trying measure #of counts/unit time each encoder) seems change depending on number of interrupts in period millis() no longer match external chronometer example.

i noted when try calculation such as:

int counter = 0;
int time = 0;
int rpm=0;

time = millis()/1000/60;
(counter being updated each time specific interrupt triggered)
rpm = counter/time;

rpm either returns zeroes or bunch of irrelevant numbers (v.g., -1, -3) when supposed calculating 1,000 rpm.
the weird thing when serial output time , counter values expected (v.g. counter = 2000; time = 2). doing wrong?

please help!!!

i think it's accurate (within accuracy of 16mhz resonator).

but, steps in program take time execute, might not reading time when think reading time...

quote
int time = 0;

time = millis()/1000/60;
time should float.   have checked values you're getting time?    going integer minutes (whole minutes).


Arduino Forum > Using Arduino > Project Guidance > How accurate is millis()?


arduino

Comments

Popular posts from this blog

invalid use of void expresion in FlexiTimer2 library

error: a function-definition is not allowed here before '{' token

LED Strip Code