Electronic Design

Get Extra Op Amps By Using Spare Comparators

So, you have selected an MCU with an analog-to-digital converter (ADC) and analog comparator peripherals for your cost-sensitive application. You then realize that your sensor signal needs to be amplified to a voltage level suitable for analog-to-digital conversion. Do you need to buy an additional op-amp device, or is there another lower-cost alternative? If the sensor output is a fast-moving signal, then most likely you'll need to spend more money to add that op amp. If, however, the sensor output is a slow-moving voltage, such as in temperature, humidity, or ambient light sensors, then you may be able to convert one of the onboard comparators to operate as an amplifier.

Figure 1 shows a circuit that will perform as a non-inverting-gain amplifier using a comparator as the active component. Depending on the selected PIC MCU, the comparator output can optionally be synchronized using a D flip-flop. Usually, the synchronization clock frequency can be adjusted by choosing the proper divider from the MCU's main oscillator. The RC network R1, R2, and C1 scales down the comparator output, which is either 5 V (supply voltage) or ground, and provides an RC time constant. At every active edge of the synchronization clock (Sync Clock), the comparator output is latched to the D flip-flop, which then updates the COUT signal to R1.

Now let's assume that initially the VCAP voltage is lower than the input voltage, VIN. Thus, the comparator output is high. As the active edge of Sync Clock arrives, the comparator output is latched to the flip-flop output. Therefore, the signal COUT becomes high, causing the voltage on VCAP to start rising. Upon the next active edge of Sync Clock, the VCAP voltage becomes higher than VIN, causing the COUT signal to transition low. Now, the VCAP voltage changes direction.

When the next clock arrives, the VCAP voltage continues to fall, but let's assume that it's still higher than VIN. Signal COUT then stays low for another clock period. This operation continues as long as the clock is present. Over many clock cycles, the average VCAP voltage is equal to VIN. In addition, the average voltage on COUT can be expressed using the non-inverting-gain-amplifier equation:

The average voltage on COUT can be extracted using a simple low-pass RC filter, R3 and C2, producing a linear output VOUT. Then VOUT can be read via an ADC, or it can drive another comparator peripheral.

Depending on the application, the synchronization flip-flop can be eliminated. But without synchronization, the only delay elements in the system are the comparator's response time and the RC time constant introduced by R1, R2, and C1. Under this configuration, the comparator output switches at a much higher rate. Therefore, the device is more likely to draw higher supply current.

A prototype circuit was built, and the performance was subsequently evaluated in the lab. VIN was varied from nearly 0 to 0.65 V, and VOUT was recorded. The transfer function and gain were then plotted over the input range shown in Figure 2.

The gain is very close to the calculated value and mostly constant over the tested range. The gain does have some distortions when VOUT is close to either ground or 5 V. Because the COUT signal is either 0 or 5 V, generating pulses for an accurate average value near those extremes is more difficult than in the middle of the range. In general, this technique should perform well enough when VOUT has at least 0.5-V headroom from each rail.

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.