I have a device which puts out three different voltage-levels on its GPIO pin: Its voltage is either 0v, 0.8v or 3v.

What I need is a clear digital logic high or low, but I need 0.8V to be treated like a logical low. Additionally I would like the result to be inverted. In other words, 0v and 0.8v becomes a logical high at the output and 3v on the input becomes a logical low.

I was thinking of using an inverted buffer, schmitt-trigger and my latest idea was using a LM393 comparator. I'm comparing the voltage from the GPIO with simply 1v (created from a voltage div.). The output should already be inverted, if I feed the 1v into the + Input of the comparator and the GPIO into the - Input.

I just would like to hear some feedback, if the comparator is the best way to implement my needed behavior or is there a more simple/discrete way to do this?

Thank you!


2 Answers 2


So basically:

Vin < 0.8 V: 1

Vin > 3V: 0

Supply is 3.3 V

You don't need a comparator for that, a simple inverter in a 74HC04 can already do that. Look at the 74HC04 datasheet

Unfortunately low and high levels are not listed for 3.3 V. But lets look at the 2 V values. 0.8 V (or lower) is typically assumed to be 0 and 1.2 V (or higher) is assumed 1. At 3.3 V supply voltage these values will increase somewhat which is beneficial for your requirement.

Another bonus is that one 74HC04 contains 6 inverters so you can monitor 6 pins !

A CMOS inverter is one of the simplest and cheapest circuits available so I doubt that there is a simpler and/or cheaper solution.

  • \$\begingroup\$ Thanks for your suggestion, one additional question to that: What if there is a voltage between 0.8v and 1.2v? In that case the inverter does not change the output? Whats the output for, lets say, 1.1v ? \$\endgroup\$
    – John
    Jan 17, 2017 at 8:29
  • \$\begingroup\$ @John the output depends on the moon phase when the chip was manufactured -- only guaranteed values are 0,8v low and 1,2v high. \$\endgroup\$ Jan 17, 2017 at 8:38
  • \$\begingroup\$ @Florian Castellane In that case I'm not sure if I can use the inverter solution. I know I wrote 0.8v above but during special moon phases the voltage might even be 1.1v but should still be considered as low. What to do in that case? Comparator? \$\endgroup\$
    – John
    Jan 17, 2017 at 8:47
  • \$\begingroup\$ You could use a diode in series to drop the voltage. Otherwise, yes, a comparator will work, although it is a more complex solution. \$\endgroup\$ Jan 17, 2017 at 8:55
  • 1
    \$\begingroup\$ In practice these inverters have a very narrow window where the output voltage is not properly determined. From the datasheet it looks like that window is 0.4 V (1.2 V - 0.8 V) but these are the guaranteed values. In practice most of these inverters will decide (1 or 0) right in the middle so 1.0 V when Vsupply = 2 V. So at 3.3 V supply I would expect the typical "decision point" to be at 3.3 /2 = 1.65 V so well above your 1.2 V. If you want to do mass production with this circuit then you will need proper data from the manufacturer at a 3.3 V supply voltage. \$\endgroup\$ Jan 17, 2017 at 9:48

The LM339 (or the dual version LM393) may be okay for this application, based on your stated requirements. Don't forget the pull-up resistor on the output.

One issue is your choice of 1.0V for the threshold, however, that leaves only (nominal) 200mV margin with 800mV in, but increasing it much (assuming a 3.3V supply) will run into the Vcc-2V common mode range limitation of this particular (ancient/cheap) comparator. If cost is not a big deal you could use a better comparator with more common mode range and pick a threshold closer to (3.0+0.8)/2.

  • \$\begingroup\$ @SpehroPerfhany: Thank you very much for your helpful hint! Price is not very critical, but package. I would like to have a DIP-8/SOP-8 package. Do you have any recommendations which better comparator to select? Thanks! \$\endgroup\$
    – John
    Jan 17, 2017 at 11:27
  • \$\begingroup\$ @John You can (and should) do a parametric search at a distributor or manufacturer(s) to match your requirements. For lower speeds, the MCP6541 and variants are very low power, cheap, rail-to-rail input and even have a bit of internal hysteresis. Variants are available with CMOS output as well as open drain. With CMOS input comparators, be sure to add some external resistance to limit the current if the input can be present when Vdd = 0 (eg. a few K at least for 3V), because of the internal protection network. \$\endgroup\$ Jan 17, 2017 at 14:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.