monday Apr 18 2011
To test the micros() fuction I run the following progrm.
unsigned long time;
void setup(){
Serial.begin(9600);
}
void loop(){
Serial.print("Time: ");
time = micros();
//prints time since program started
Serial.println(time);
// wait 1/1000 second to see how much will change at micros().
delay(1);
}
This progtram is to test, during 1/1000 second what is the value of micros(). I got the result that is unexpected.
First:
I run this program in about one second. I got information from the serial monitor
...
Time: 11945552
Time: 11962192
Time: 11978832
Time: 11995472
...
so the micros()'s value at 1/1000 second is
11962192 - 11945552 = 16640
but after about 10 second I got information that had changed a lot from the serial monitor
...
Time: 102355872
Time: 102373552
Time: 102391232
Time: 102408912
...
so the micros()'s value at 1/1000 second is
102373552 - 102355872 = 17680
this change is more than 5%
(17680 - 16640 )/17680 = 0.0588
I test this for a few times. The result is almost the same: at start, the micros() value is small---close to 15600, and after about ten sedond the micros() value will change to biger ---- close to 17680.
why ?
second , I noted the Arduino Uno microprocessor's working frequence is 16 MHz
so during 1/1000 second the micros() value should be 16000. That is correct ?
Third, what is the physical tolerance of the part---- 16 MHz crystal oscillator ?