← Wiki · Component

Comparator (TLV7031)

Compares two voltages and gives a digital answer: high when IN+ is above IN−. A battery-low flag, a threshold on a sensor or a wake-up signal without the microcontroller awake.

What it does#

A comparator is a tiny chip with two inputs and one digital output. When IN+ is above IN−, OUT goes high (to VCC); when it is below, OUT goes low. Unlike an ADC it needs no code and no running microcontroller: it can watch a battery and wake the MCU only when something changes.

The TLV7031 (TI) runs from 1.6–6.5 V and draws only 335 nA, so it can stay on all the time on a battery board. Its push-pull output drives a GPIO directly, no pull-up needed.

Example circuit: TLV7031 on 3V3 with 100 nF. VBAT is halved by 1 MΩ / 1 MΩ into IN+, 3V3 is halved the same way into IN−; BAT_OK is high while VBAT is above 3V3.
TLV7031 on 3V3 with 100 nF. VBAT is halved by 1 MΩ / 1 MΩ into IN+, 3V3 is halved the same way into IN−; BAT_OK is high while VBAT is above 3V3. Open the comparator_battery_low example from this page in SolderCanvas: “Insert into my schematic”.

Hysteresis#

Near the threshold a slow, noisy input would make the output chatter. The TLV7031 has 7 mV of hysteresis built in, enough for a clean signal. For a wider band add a resistor from OUT back to IN+.

Pitfalls#

  • Dividers draw current: two 1 MΩ dividers take about 4 µA from a full LiPo, ten times the comparator. Use large resistors.
  • The reference must be steady: here it is 3V3 / 2. When VBAT falls so low that the 3V3 regulator drops out, the reference falls too.
  • X2SON pinout: the X2SON-5 version has VCC on pin 2 and VEE on the centre pad 3; the SOT-23 version has different pins. Use the matching symbol.

Footprint#

X2SON-5 is 0.8 × 0.8 mm: machine assembly only, no hand soldering. Its JLCPCB rotation is not checked yet: look at the part in JLCPCB’s assembly preview. The footprint follows TI’s DPW0005A land pattern with the copper cut to TI’s exposed metal (non solder mask defined), so its pads stay 0.21 mm apart.