Adding ADC to Microcontrollers without ADC

Summary of Adding ADC to Microcontrollers without ADC


Summary: A minimal-cost method for precise voltage measurement using a comparator, two transistors, and passive components is presented to control a crystal oven. It charges a capacitor at a constant current so voltage rises linearly and times how long it takes to cross the test voltage. The approach prioritizes precision and simplicity over absolute accuracy and speed, uses only three MCU pins, and suits sensors like LM335, LM35, or thermistors. Alternatives and improvements (ADC, op-amps, 555 timer, references) are discussed.

Parts used in theCrystal Oven Controller:

  • Comparator (or microcontroller analog comparator inputs)
  • Two transistors
  • Capacitor (timing capacitor)
  • Current-limiting resistor(s)
  • Additional passive components (resistors, possibly diodes)
  • Temperature sensor (LM335, LM35, or thermistor)
  • Microcontroller (with comparator or at least digital I/O; e.g., ATMega328, ATTiny85)
  • Power supply

I recently had the need to carefully measure a voltage with a microcontroller which lacks an analog-to-digital converter (ADC), and I hacked together a quick and dirty method to do just this using a comparator, two transistors, and a few passives. The purpose of this project is to make a crystal oven controller at absolute minimal cost with minimal complexity. Absolute voltage accuracy is not of high concern (i.e., holding temperature to 50.00 C) but precision is the primary goal (i.e., hold it within 0.01 C of an arbitrary target I set somewhere around 50 C). Voltage measurement is usually a balance of a few factors: precision, accuracy, cost, simplicity, and speed. The method I demonstrate here maximizes precision and simplicity while minimizing cost.Adding ADC to Microcontrollers without ADC
High speed operation is not of interest (1-2 measurements per second is fine), and as mentioned before accuracy is not a chief concern as long as precision is maximized. I would feel neglectful if I didn’t give a shout out to a few alternatives to this method: Using the 10-bit ADC built into most AVR microcontrollers (my go-to for ATMega328 at ATTiny85, but the ATTiny2313 doesn’t have any) often combined with an op-amp like this, using an IC like the MCP3208 8-channel 12-bit ADC (very expensive at $3.66 on mouser) are a good option, and fancy alternative dual slope methods as described in this really good youtube video and even mentioned nicely in the digital volt meter (DVM) / LCD driver ICL1706 datasheet. Those addressed, my quick and dirty idea uses only a couple cents of components and 3 pins of a microcontroller. There is much room for improvement (see my notes about a 555 timer, voltage reference, and operational amplifiers at the bottom) but this is a good minimal case starting point. This type of measurement is perfect for high precision temperature measuring using things like an LM335, LM35, or thermistor.

Schematic Adding ADC to Microcontrollers without ADC
The concept behind this method is simple: use a current-limiting circuit to charge a capacitor at a constant rate so voltage rises linearly with time (rather than forming an exponential RC curve), and time how long that voltage takes to cross your test voltage.

A circuit which compares two voltages and outputs high when one voltage surpasses the other is called a comparator, and many microcontrollers (including ATMEL AVRs) have analog comparators built in (which compare AIN0 and AIN1, the result of which accessable by accessing the ACSR&(1<<ACO)) bit value (at least for the ATMega328, according to the datasheet).
For more detail: Adding ADC to Microcontrollers without ADC

Quick Solutions to Questions related to theCrystal Oven Controller:

  • What is the basic measurement concept?
    Charge a capacitor at a constant current so voltage rises linearly and time how long it takes to cross the test voltage using a comparator.
  • Which microcontrollers can use this method?
    Microcontrollers with an analog comparator such as many ATMEL AVRs (example ATMega328 or ATTiny85) can use this method; ATTiny2313 lacks an ADC but may still have a comparator depending on variant.
  • How many microcontroller pins are required?
    The method uses three microcontroller pins.
  • Is high speed measurement necessary?
    No, the method targets low speed operation; 1-2 measurements per second is acceptable.
  • Is absolute voltage accuracy important for this project?
    No, absolute accuracy is not a chief concern; precision is prioritized to hold temperature within about 0.01 C of a setpoint.
  • What sensors are suitable with this measurement method?
    Temperature sensors like LM335, LM35, or thermistors are suitable for this precision measurement approach.
  • What are alternatives to this method?
    Alternatives include using built-in 10-bit ADCs on AVRs often with an op-amp, external ADCs like MCP3208, or dual-slope measurement methods and dedicated DVM/LCD driver ICs like the ICL1706.
  • What improvements are suggested?
    Possible improvements mentioned include using a 555 timer, a voltage reference, and operational amplifiers.

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter
Scroll to Top