Joined Jan 18, 2005
A comparator can be created from a device known as an Operational Amplifier. The amplifier has a gain of about 200,000 (using 471 model). The two inputs to this device are the non inverting input given the symbol +, and the inverting input given the symbol -.
The Operational Amplifier take the difference in voltages which are placed on these inputs, therefore the input voltage Vi = (V+ - V-).
The maximum voltage that an 'Op Amp' can output is determined my the power supply, meaning the output can have its maximum voltage equal to that of the power supply - no bigger.
Due to the huge gain, when a small signal is input into the Op Amp the output will saturate to the maximum supply voltage. The inverting input when used as a comparator is used as a reference voltage, meaning that you place a voltage on this input so that the other voltage on the positive + non inverting input is compared with this value. For instance if the voltage on the non- inverting input is bigger than the reference voltage the input voltage Vi is positive and due to the high gain the output will saturate to the maximum of the supply voltage. On the other hand if the voltage on the non - inverting input is less than that of the reference voltage then the input voltage Vi will be negative, and again due to the high gain, the output will saturate to the negative Supply voltage (as there are two power supply terminals on the Op Amp, one for V+ and the other for V- or ground).
Hope that helps you.



Joined Feb 24, 2006
Although you can create a comparator out of an opamp the output is still an analog level. A better approach is to use an actual comparator which is optimized for the application. It has a high-gain differential input stage like an opamp but is has a TTL compatible open collector output stage.

This means the output can be wire-ored with other comparator or open collector outputs. You can also wire the comparator output directly to a microprocessor input. You need to ensure that there is a pullup either inside the processor or externally on the board.

Easiest trap to fall into. Common mode range. At least one of the input signals MUST be within the common mode range. Read the datasheets carefully.