Open 0i0i0i opened 3 years ago
It's probably hardware.
According to the schematics on Arduino's website, Arduino Uno and Mega uses a ceramic resonator, part number CSTCE16M0V53-R0. The datasheet says the "5" digit means 0.5% accuracy. You should expect up to 0.5% error on these boards.
Of course cheap clones might use anything!
On Teensy we use only high quality quartz crystals which are rated for 0.003% accuracy (30 ppm).
Thanks Paul. I think I can try to replace these 0.5% ones with higher quality ones.
Description
When use arduino 2560 and UNO to test how accurate the measument of the frequency could be, I found the different borads have different results. I used a standard 1kHz squarewave source and measured its frequency with an osilloscope, in which it shows exact 1000Hz.
Howerever, when I loaded the example code to all borads I have, I got 1001.86, 1003.45 and so on. One arduino mega 2560 could have different result to another. From your demo picture, I noticed the result is pretty accurate. My guess is that some variation of the cristals is resposible for this. If that is the case, I would multiple the result with a factor. However, there might be some systematic issue envolved, like some latency of reading. If the later is true, I would add some constants to some part of the period measurement. Could we add some parameters for conpensate?
Steps To Reproduce Problem
load the following code and the result will show it.
Hardware & Software
Board: arduino mega 2560 rev.3 Shields / modules used non Arduino IDE version 1.8.5 Teensyduino version (if using Teensy) Version info & package name (from Tools > Boards > Board Manager) Operating system & version windows7-64bit Any other software or hardware?
Arduino Sketch
Errors or Incorrect Output
Inaccurate results.