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的更多相关文章

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

  2. UVa1048 Low Cost Air Travel——最短路

    很好的一道题呀 思路 状态\(d(i,j)\)表示已经经过了行程单中的\(i\)个城市,目前在城市\(j\)的最小代价,直接建边跑最短路就行了 比如机票为\(ACBD\),行程单为\(CD\),那么对 ...

  3. HamsterBear Linux Low Res ADC按键驱动的适配 + LVGL button移植

    HamsterBear lradc按键驱动的适配 平台 - F1C200s Linux版本 - 5.17.2 ADC按键 - 4 KEY tablet 驱动程序位于主线内核: drivers/inpu ...

  4. USB ISP(ICSP) Open Programmer < PWM ADC HV PID >

    http://sourceforge.net/projects/openprogrammer/?source=navbar Open Programmer http://openprog.alterv ...

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

  6. ADC for programmable logic uses one capacitor

    Many electronic devices require user input for setting the application properties. Typical input dev ...

  7. ADC In An FPGA

    http://davidkessner.wordpress.com/2011/05/01/adc-in-an-fpga/ Geek Alert!  What follows is very techn ...

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

  9. adc转换原理

    模数转换器即A/D转换器,或简称ADC,通常是指一个将模拟信号转变为数字信号的电子元件.通常的模数转换器是将一个输入电压信号转换为一个输出的数字信号.由于数字信号本身不具有实际意义,仅仅表示一个相对大 ...

随机推荐

  1. Linux硬链接和软连接的区别与总结

    图示软硬链接的区别 有关硬链接的总结 具有相同inode节点号的多个文件互为硬链接文件: 删除硬链接文件或者删除源文件任意之一,文件实体并未被删除: 只有删除了源文件和所有对应的硬链接文件,文件实体才 ...

  2. Linux Supervisor的安装与使用入门---SuSE

    Linux Supervisor的安装与使用入门 在linux或者unix操作系统中,守护进程(Daemon)是一种运行在后台的特殊进程,它独立于控制终端并且周期性的执行某种任务或等待处理某些发生的事 ...

  3. laravel5.1--数据库操作

    1 配置信息 1.1配置目录: config/database.php 1.2配置多个数据库 //默认的数据库 'mysql' => [ 'driver' => 'mysql', 'hos ...

  4. Weex Workshop 挑战赛,等你来战!

    一个颠覆性的移动开发方式,一个匠心打造的跨平台移动开发工具,一个后App时代的生产力解放者—Weex,针对App Native开发频繁发版和多端研发的痛点,H5开发的页面稳定性.性能体验等问题,提供了 ...

  5. html5多媒体Video/Audio

    video:    1.常见的视频格式 视频的组成部分:画面.音频.编码格式 视频编码:H.264.theora.VP8(google开源)      2.常见的音频格式     编码:AAC.MP3 ...

  6. ssh客户端乱码

    export LC_ALL=zh_CN.GB2312;export LANG=zh_CN.GB2312

  7. 【LOJ】#2172. 「FJOI2016」所有公共子序列问题

    题解 听说是什么序列自动机? 我们考虑对于每个位置的串,下面拼接相同的字符时,拼接最近的一个,这样可以保证不重不漏 为了实现这个我们需要什么呢,我们需要一个链表,记录一下每个位置的下一个字符会转移到哪 ...

  8. 【LOJ】#2280. 「FJOI2017」矩阵填数

    题解 我们发现没有限制的小方格可以随便填 然后考虑有限制的,我们把它切割成一个个小块(枚举相邻的横纵坐标),然后记录一下这个小块的最大值限制(也就是所有覆盖它的矩形最小的最大值) 记录一下每个小块的大 ...

  9. 使用STL sort对字符串按字典序排序

    使用string数组 #include<iostream> #include<string> #include<algorithm> using namespace ...

  10. [转]基于Protel DXP软件的PCB高级编辑技巧大全

    来源:基于Protel DXP软件的PCB高级编辑技巧大全 一.放置坐标指示 放置坐标指示可以显示出PCB板上任何一点的坐标位置. 启用放置坐标的方法如下:从主菜单中执行命令 Place/Coordi ...