Monday, 12 February 2018

Analog to Digital convertor using capacitor



I found out that I can use a capacitor in order to get the data from an analog sensor in a digital manner(Connecting the analog sensor to the GPIO of a Raspberry Pi).


I have a 1μF polarised capacitor. Is it suitable? How should I connect it in order to work?


The sensor I'm talking about is the below push sensor.


Is it ok to connect GND to GND, VCC to 3.3V Power and the capacitor with the positive branch to OUT and with negative to the GPIO pin?


Here is the datasheet of the sensor: http://www.robofun.ro/docs/2010-10-26-DataSheet-FSR400-Layout2.pdf


Thank you!


enter image description here



Answer



Use two GPIO pins, alternate between input and output mode


Steps:



Discharge the capacitor


Charge one known resistor


Discharge capacitor


Charge the UNKNOWN resistor (the sensor)


http://www.doctormonk.com/2013/12/analog-sensors-without-analog-inputs-on.html


Use GPIO as input mode to detect the charge up reaching theshold (about mid point voltage)


This technique allow simple low cost MCU without build in ADC to read analogue sensor (variable resistance depending on sensed quality), including temperature (thermistor), humidity, light (CdS), force, etc.


Good absolute accuracy if the known resistor is high accuracy. Tolerance of capacitor is cancel out.


Widely used in consumer electronics device. Have excellent resolution, can be up to 16 to 20 bits or so. Typical conversion time in range of 100ms. Faster conversion can be traded with smaller resolution. Can use MCU hardware timer.


Raspberry Pi (vs Arduino) has no build in ADC and this technique is often used.



One pin version, lower absolute accuracy as affected by capacitor tolerance. http://www.raspberrypi-spy.co.uk/2012/08/reading-analogue-sensors-with-one-gpio-pin/


Also, three pin version, use one pin for sensing (input mode) and quick discharge (output), for quicker conversion time.


No comments:

Post a Comment

arduino - Can I use TI's cc2541 BLE as micro controller to perform operations/ processing instead of ATmega328P AU to save cost?

I am using arduino pro mini (which contains Atmega328p AU ) along with cc2541(HM-10) to process and transfer data over BLE to smartphone. I...