Summary of Read analog values without an ADC using PIC12F675 microcontroller
Digital and analog electronics often require ADCs to interface, but you can measure resistance or capacitance using an RC timing trick without an ADC. Drive an RC node high as an output briefly, then switch the pin to input and time how long it stays high; the discharge/charge time reflects the sensor value. Replace the resistor with a thermistor or photoresistor (or the capacitor for capacitive sensors). Use stable components (precision resistors, Mylar capacitor) for accuracy. Example uses include one-wire keypad and security keypad implementations on small PIC microcontrollers.
Parts used in the RC timing project:
- Microcontroller with digital I/O (example: PIC12F675)
- Capacitor (example: 33 pF, Mylar recommended)
- Resistor (example: 1 kΩ)
- Thermistor or photoresistor (optional, for temperature or light sensing)
- Precision resistors (for accurate calibration)
- Wiring and breadboard or PCB for connections
Digital electronics and Analog electronics doesn’t mix easily. A Microcontroller can’t get analog values unless an Analog-to-Digital converter is used, however, you may find a little complicated the use of an ADC and it need lots of Input/Output ports.
Some Microcontrollers, like the small 8-pin Microchip PIC 12F675, do have an ADC integrated, but it is expensier than a PIC without ADC. A simple solution is to use a RC circuit to measure the resistance or capacitance.
Basically, a RC circuit is just a capacitor and a resistor. The circuit labeled A shows the most common RC circuit used. I like to use the B circuit, I get better results.
You can replace the resistor and use a thermistor to measure temperature (PTC or NTC), also a photoresistor can be used to measure light. Any kind of resistive sensor can replace the resistor. If you are using a capacitive sensor, just replace the capacitor instead of the resistor.
How it works:
Just connect the RC circuit directly to an I/O pin of the microcontroller. You can use a 33pf capacitor and 1k resistor.
- First, make the I/O pin as OUTPUT.
- Second, make the pin POSITIVE (+) for one milisecond. (Using a PIC at 4mhz, a 255-cycles loop will be enough).
- Third, Make the I/O pin as INPUT and measure how long stays as POSITIVE (+).An good application of this technique is my “One wire keypad”:
The PIC will measure the RC value of the I/O pin. If the time measured is too long, that means; there is no key pressed. Precision resistors and Mylar capacitor is required to get exact values.
You can see my ” Security Keypad ” uses a similar technique.
For more detail: Read analog values without an ADC using PIC12F675 microcontroller
- How can a microcontroller read analog values without an ADC?
By using an RC circuit: drive the pin high as an output, switch it to input, and measure how long the pin remains high; the time reflects the sensor value. - Can I use a resistor sensor like a thermistor with this method?
Yes, you can replace the resistor with a thermistor (PTC or NTC) to measure temperature. - Can I use a photoresistor to measure light with this technique?
Yes, a photoresistor can replace the resistor to measure light via the RC timing. - What components are recommended for better accuracy?
Precision resistors and a Mylar capacitor are recommended for exact values. - How long should the microcontroller drive the pin high before measuring?
Make the pin positive for about one millisecond; on a PIC at 4 MHz a 255-cycle loop is sufficient. - What capacitor and resistor values are suggested?
An example combination is a 33 pF capacitor and a 1 kΩ resistor. - Does this method require many I/O pins?
No, the RC circuit connects directly to a single I/O pin, reducing I/O usage compared to some ADC setups. - Is this technique used in real applications?
Yes, it is used in applications like a one wire keypad and a security keypad described by the author.
