Enables the resolution of analog inputs to be increased by oversampling and decimation. More...
#include <OverSample.h>
Public Member Functions | |
T | next (T input) |
Oversample and decimate the input to increase resolution by RESOLUTION_INCREASE_BITS;. More... | |
Protected Member Functions | |
T | add (T input) |
Enables the resolution of analog inputs to be increased by oversampling and decimation.
Noise should be added to the input before it's digitised, then a succession of input readings are summed and finally divided to give a number with greater resolution than the ADC.
Often, noise in the Arduino system will be enough, but there are other practical methods described in Enhancing ADC Resolution by Oversampling, as well as an explanation of the overall approach.
RESOLUTION_INCREASE_BITS | how many extra bits of resolution to produce. The window length and the memory it needs increases quickly as the oversampling resolution increases. 1 bit = 4 unsigned ints (analog input between 0-1023) = 8 uint8_ts, 2 bits = 16 unsigned ints = 32 uint8_ts, 3 bits = 64 unsigned ints = 128 uint8_ts, More than 3 bits increase in resolution would require either using longs to store the readings, which would need 1024 uint8_ts for a 4 bit increase and 4096 uint8_ts for 5 bits (do any avr's have that much room?), or the average reading would have to be no more than 128 (for 4 bits increase), because 256 readings would be needed, and the sum of all 256 readings would have to fit into an int. (32767 / 256 = 128). Changing OverSample to use unsigned ints could enable an average reading of 256, but isn't tested properly yet. |
Definition at line 42 of file OverSample.h.
|
inline |
Oversample and decimate the input to increase resolution by RESOLUTION_INCREASE_BITS;.
input | an analog input to oversample. |
Definition at line 53 of file OverSample.h.