Code Monkey home page Code Monkey logo

sac-converter-algorithm's Introduction

******************************************
* Successive Approximation ADC Algorithm *
* Author: Travis Kaufman                 *
* Version: 1.0.1                         *
******************************************

UPDATE NOTE: When I tested my original programs output, I saw that the running time was approximately O(n), where n = word length. However, I was able to get this to run more efficiently than I thought, by checking if the word length was excessive and if so resizing it, therefore not avoiding wasting processor time on unecessary operations. Although this isn't exactly how a SAC works, I would rather have efficiency over real-world roadblocks. Furthermore, in terms of n = number being tested, it is WAY more efficient than a brute-force algorithm. Probably why it's used in ADCs ;)

Today I reviewed Successive Approximation Digital to Analog Conversion, and I decided it would be cool to try and implement the Successive approximation algorithm in C, since 1) C is really awesome, and 2) I am literally the biggest nerd on the planet. Therefore, here's my attempt at it. The algorithm is as follows:

1) Flip the MSB of the potential output word 
2) If the output word's value is larger than the reference voltage, flip the MSB back and repeat 1) with the next-most significant bit
3) If the output word's value is smaller than the reference voltage, flip the next-most significant bit and compare it with the reference voltage again, repeating steps 2) and 3) as necessary
4) If the output word equals the reference voltage, return it.

Obviously for the sake of my own sanity V1.0.* will use integers, but maybe someday in the future it'll be cool to twiddle some floating-point numbers and see if I can fenagle it to get it working.   

sac-converter-algorithm's People

Contributors

traviskaufman avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar  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.