Algorithm that mimics the behavior of a Successive Approximation Analog-to-Digital Converter by finding an integer value using the same technique, even improving on it a little
C
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
README
SAC_DAC_Algorithm.c

README

******************************************
* 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.