Low-cost ADC using only Digital I/O
http://letsmakerobots.com/node/13843
Reading A Sensor With Higher Accuracy – RC Timing Method

RC Timing Method:
Simple RC step response
Vc(t) = VDD * (1 - e -t/(RC))
t = -RC ln(1 - Vth/VDD)
Vth/VDD is constant : R2 = (t2/t1) * R1
A reference resistor can be used to improve the accuracy of an analog sensor reading.
In this diagram, the charge time of a resistor/capacitor combination is measured using a timer and a port input or comparator input switches from a '0' to '1'.
The R1 curve uses a reference resistor and the R2 curve uses the sensor.
The charge time of the R1 curve is known and can be used to calibrate the unknown sensor reading, R2.
This reduces the affects of temperature, component tolerance and noise while reading the sensor.
Application Notes:
AN512 Implementing Ohmmeter/Temperature Sensor
AN611 Resistance and Capacitance Meter Using a PIC16C622
Ever find yourself in need of some extra ADC capabilities? Maybe you have a micro with no ADC built in, maybe you've used up all your ADC pins already, or maybe the integrated ADC doesn't provide a high enough resolution. This is where a custom-built Capacitor ADC can become very useful.
Now, there are ADC ICs that you can buy which will handle all the ADC stuff externally and just feed the digital results to your micro - there isn't anything wrong with these. If you can afford the cost and the PCB space then you can save yourself some time and effort by grabbing one of these. In my case however I had a small micro with no ADC, and if I added a big ADC IC to my circuit then what would be the point of having a small micro in the first place?
BTW, although I developed this particular method myself, I'm certainly not the first to use RC timing for ADC applications =)
If you are interested in some slightly more advanced stuff, I strongly recommend you check out the Microchip Tips n Tricks for 8-pin micros, which has many useful techniques that are applicable to small micros. As usual, Wikipedia also has a lot of good info on various ADC types.

So here's the most basic example - 2 digital I/O pins, one resistive sensor, and one capacitor. I know 2 pins for one sensor isn't very good in terms of pin efficiency, but it scales favourably with more sensors, as the number of pins = number of sensors + 1.
The method for reading the sensor is as follows:
• Set D I/O 1 & 2 as outputs, with D I/O 1 -> LOW and D I/O 2 -> HIGH.
• Set D I/O 1 as an input.
• Start a timer.
• When D I/O 1 changes from reading LOW to HIGH, stop the timer and record the value.
The time it takes for D I/O 1 to go from LOW to HIGH is a function of the resistance of the sensor R. It's not a nice linear relationship, but for many applications this is far from important, especially if you're just using a few thresholds to analyse the sensor. If you were using this method with an LDR in place of R, where the resistance drops as more light hits the sensor, then you'd see smaller timer values as more light fell on the LDR.
You can extend this approach to virtually an infinite number of sensors, just by connecting them all to the same capacitor and reading them sequentially. When you're reading one sensor just follow the method above, and set all the other sensor D I/O pins to inputs - that way they won't interfere with the sensor you're reading.
One final note - I've just shown the basic technique for reading resistive sensors here, but you can do the same thing with semiconductor sensors (reverse-biased LEDs, photodiodes, phototransistors, etc) just by substituting R for the sensor. In some cases you may want to limit the sensor current with a fixed series resistor too.
Other types of sensors (such as RF antenna) can also be used with this technique, but you have to be able to use an I/O pin to 'disable' the sensor when you want to read the others. Often a few cleverly placed diodes or transistors will do the trick.
Low-cost ADC using only Digital I/O的更多相关文章
- L147 Low Cost Study Has High Impact Results For Premature Babies
No one knows exactly why some babies are born prematurely(早产), but some of the smallest premature ba ...
- UVa1048 Low Cost Air Travel——最短路
很好的一道题呀 思路 状态\(d(i,j)\)表示已经经过了行程单中的\(i\)个城市,目前在城市\(j\)的最小代价,直接建边跑最短路就行了 比如机票为\(ACBD\),行程单为\(CD\),那么对 ...
- HamsterBear Linux Low Res ADC按键驱动的适配 + LVGL button移植
HamsterBear lradc按键驱动的适配 平台 - F1C200s Linux版本 - 5.17.2 ADC按键 - 4 KEY tablet 驱动程序位于主线内核: drivers/inpu ...
- USB ISP(ICSP) Open Programmer < PWM ADC HV PID >
http://sourceforge.net/projects/openprogrammer/?source=navbar Open Programmer http://openprog.alterv ...
- Fully Digital Implemented Delta-Sigma Analog to Digital Converter
http://www.design-reuse.com/articles/14886/fully-digital-implemented-delta-sigma-analog-to-digital-c ...
- ADC for programmable logic uses one capacitor
Many electronic devices require user input for setting the application properties. Typical input dev ...
- ADC In An FPGA
http://davidkessner.wordpress.com/2011/05/01/adc-in-an-fpga/ Geek Alert! What follows is very techn ...
- Building a Radio Listening Station to Decode Digital Audio & Police Dispatches
On April 7, 2017, residents in Dallas, Texas, woke to the sound of emergency sirens blaring all over ...
- adc转换原理
模数转换器即A/D转换器,或简称ADC,通常是指一个将模拟信号转变为数字信号的电子元件.通常的模数转换器是将一个输入电压信号转换为一个输出的数字信号.由于数字信号本身不具有实际意义,仅仅表示一个相对大 ...
随机推荐
- git 还原到指定版本号
git clone git branch -r --contains 88b92060224e96ef209565fa75c816eb9b0fae8e git checkout origin/re ...
- 关于boost 的smart_ptr 的使用问题
boost 的smart_ptr 库中含有好几种智能指针,大家用的最多的应该是shared_ptr ,为啥呢?好用,不用管他啥时候会自动删除等等,而且拷贝和复制都很到位, 但实际上,这个库也有问题,连 ...
- VS里属性窗口中的生成操作释义
生成操作:无,编译 ,内容 ,嵌入的资源... 如果是类.cs文件,就得编译之后你才能使用的.如果是txt,excel 这种文件,就属性内容或者资源文件了. 内容(Content) - 不编译该文件, ...
- <c:if></c:if>用法-转载
<c:if test="value ne, eq, lt, gt,...."> 用法 类别 运算符 算术运算符 + . - . * . / (或 div )和 % (或 ...
- 在内网环境使用WPAD/PAC和JS攻击win10
转:https://mp.weixin.qq.com/s/qoEZE8lBbFZikKzRTwgdsw 在内网环境使用WPAD/PAC和JS攻击win10 2018-03-01 wangrin 看雪学 ...
- 转:在 Ubuntu 上使用 Nginx 部署 Flask 应用
转:http://Python.jobbole.com/84286/ 原文出处: Vladik 译文出处:开源中国 我职业生涯的大部分都在使用微软的架构,最近我决定走出技术的舒适区,步入开源 ...
- ZOJ 3953 Intervals
线段树,排序. 按照$R$从小到大排序之后逐个检查,如果$L$,$R$最大值不超过$2$,那么就把这个区间放进去,区间$+1$,否则不能放进去. #include<bits/stdc++.h&g ...
- Python类总结-继承-子类和父类,新式类和经典类
子类和父类 class Father(object): #子类在使用super调用父类时,Father后面要加object --新式类 def __init__(self): self.Fname = ...
- 八步详解Hibernate的搭建及使用
本文通过了八个步骤以及一些实例添加用户来介绍Hibernate的搭建和使用,真切的介绍了hibernate的基本用法,其中好多优点等待我们自己去发现,比如hibernate中的缓存机制,映射方案. 1 ...
- Xcode 7.0正式版发布了
Xcode 7.0正式版发布了 下载地址:链接: http://pan.baidu.com/s/1FNkPS 密码: ee42 本文由大学霸整理,转载请注明出处,尊重IT人!