Giter VIP home page Giter VIP logo

oversampling's Introduction

Arduino Oversampling And Decimation Library

Arduino oversampling, decimation and averaging library. Using oversampling and decimation will only lower the ADCs quantization error, it does not compensate for the ADCs integral non-linearity.

Oversampling adc(Adc, Oversampling, Averaging);

unsigned long adc_value = adc.read(Pin); // Oversampling and decimation

Where:

  • Adc is the resolution of the ADC of the microcontroller; can be from 8 to 16,
  • Oversampling is the number of bits obtained through the oversampling process; can be 11 to 24,
  • Averaging is the number of consecutive oversampled readings performed inside adc.read() before returning the averaged value.
  • Pin is the ADC pin number (e.g., analogRead(Pin)).

Example Sketch:

#include <Oversampling.h>

Oversampling adc(10, 16, 2);
/* 10 = resolution of the ADC of the microcontroller (e.g., for the ATTINY88, the ADC resolution is 10 bits)
 * 16 = n of bits obtained through the oversampling process (16-10 = 4 additional bits)
 *  2 = number of consecutive oversampled readings performed inside adc.read() before returning the averaged value.
 */

void setup()
{
  Serial.begin(19200);
}

void loop()
{
  Serial.print( (long) adc.read(0) ); // 0 is adc pin
  delay(1000);
}

The maximum value returned by adc.read() is ((2^Adc)-1) * (2^(Oversampling-Adc)), where Adc is the number of bits of the ADC and Oversampling is the number of bits obtained through the oversampling process. (The minimum value is 0.)

Example of maximum value for the ATTINY88 10-bit ADC with 16-bit oversampling: ((2^10)-1) * (2^(16-10)) = 1023 * 64 = 65472.

References:

oversampling's People

Contributors

ircama avatar muink avatar regimantas avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.