Variation in accuracy of the internal clock of the atmel328p in function fo the temperature

Hello everyone,
I'm doing a project where I'm using an ultrasonic sensor to make measurements. I see that there was a variation in the accuracy of the data when there was a variation in the temperature.

For example at 0° the sensor measure 80cm and the manual measure is of 80cm with a good repeatability of the measure and a good accuracy close to 0.5cm.
But I make the same test at 25° and here the accuracy was completely different with a variation of 2 cm. 78 ultrasonic measurement against 80 manual measurement. at 30 cm distance the differences become of 1 cm. the repeatability is still good but the accuracy varies.

I make this test with 5 sensors and I always get the same result.

The sensor make the measurement by time domain return routine. make an impulse on a pin and attend the time when the sonic wave return to the other ultrasonic cone. so if the time count by the arduino was corrected the whole system give bad result.

Does anyone know which clock Arduino uses to measure time in the program exegution and if this is affected by temperature variations?
I'm using an arduino nano 328P.

Thanks in advance.

I think this will be a bigger variation than arduino clock

There is only one clock. Either external or internal. A standard 328P based Arduino uses the an external 16 MHz source. I think it depends on the quality of the source what the deviation will be.

For the internal oscillator the following image applies (see datasheet)

Sorry, but I forgot to mention that we used the speed of sound as the speed of sound at 20° or 343 m/s so I would have expected to be wrong at low temperatures not 20 degrees.

ok thank you so much.

But I have a question :
you say that [quote="sterretje, post:3, topic:1356467"]
Arduino uses the an external 16 MHz source
[/quote]
but in the graph i say 8 MHz the clock is of 16 o 8 MHz.

Thank you!

There were two paragraphs in my reply.

  1. One for the external source.
  2. One for the internal oscillator. This is not used in the Nano.

Not in your case. The clock used is determined by MCU fuse settings as well as register settings.

The default for the Arduino Nano 328P is an external resonator or crystal, typically 8 or 16 MHz, usually cheap and therefore not particularly accurate.

All clocks are temperature sensitive.

Perhaps you could get some estimate of clock variation with temperature. Write a simple sketch that just changes the state of an LED in loop() followed by delay(60000). Then time how long it takes the LED to change state, using a stopwatch. Try it at 0° and 25°.

May well be using a ceramic resonator instead of a crystal. A ceramic resonator has less accuracy in general. Picking a part at random, I see

Oh sorry i don't get it.

thank you!

Ok, but I know that some clocks are more accurate than others.

For example, if I use an ArduinoEvery, will the clock remain the same or become more accurate?

Thank you for your time!

good idea, i will consider to make some test!

thankss!

Brilliant observation!

if I use an ArduinoEvery, will the clock remain the same or become more accurate?

That depends on which of many possible clock sources is selected, and the characteristics of the frequency determining element of that clock source.

clear!
sorry for the insistence but it is a new world to me.
and how do i know/set the clock source?
thankss

so the crystal resonator ar better.
Thank you!

The data sheet for the processor explains how to do that. You need a processor fuse programmer to change the clock source.

If you have a stock Arduino Nano 328P, then either a crystal or resonator is used, most likely 16 MHz. The clock accuracy depends almost entirely on the selection of that component (if a crystal, including the two associated capacitors) and its temperature dependence.

It is possible with the Nano 328P to measure the crystal or resonator frequency of oscillation to about 1 Hz accuracy using a GPS module as a time base. Let me know if you are interested and I can point you to some resources.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.