-
Notifications
You must be signed in to change notification settings - Fork 12
Compensating Measurement Errors
A single ADC measurement (either voltage or temperature) can be imprecise. There are differences in consecutive measurements coming from the inherent imprecision in the measurement process.
Much stronger though is the influence of the current draw on the battery's voltage level, especially if the battery is nearly discharged.
To compensate both effects multiple measurements are taken, the lowest and the highest measurement are discarded and the mean of the remaining values is used.
Currently 5 measurements are used for this approach.
Since doing all these measurements generates a lot of heat that influences temperature measurements they are taken first, when the die is still comparatively cool due to the last deep sleep phase.
We use two values to compensate our measurements. We use a coefficient as a multiplier to change the gradient of the measurement curve and a constant to correct any offset (see the following diagram).
For every one of the measurements, battery, external voltage and temperature, these two values are used for the compensation. By using these values the measurements reported by ATTiny Daemon can be reasonably correct.