About Circuit Cellar Staff

Circuit Cellar's editorial team comprises professional engineers, technical editors, and digital media specialists. You can reach the Editorial Department at editorial@circuitcellar.com, @circuitcellar, and facebook.com/circuitcellar

Op-Amp Versus Comparator (EE Tip #128)

Practically every lecture course or textbook on electronics describes how to use an operational amplifier as a comparator. Here we look at the possibility in more detail, and see how it can often be a very poor idea.

The idea behind the comparator configuration is simple. An op-amp has a very high open-loop DC gain which means that even a tiny differential input voltage will drive the output to one extreme or the other. If the voltage at the non-inverting (“+”) input is greater than that at the inverting (“–“) input the output goes high; otherwise the output goes low. In other words the two voltages are compared and the output is a binary indication of which of the two is the greater.

Figure 1: SPICE simulation results: an LT1028 op-amp pressed into service as a comparator versus a real comparator type LT1720.

Figure 1: SPICE simulation results: an LT1028 op-amp pressed into service as a comparator versus a real comparator type LT1720.

So the op-amp looks like the perfect device to use as a comparator. But why then do there exist special-purpose comparator devices? Looked at from the outside, op-amps and comparators appear indistinguishable. Besides power connections, they both have “+” and “–” inputs and a single output. Taking a look at the internal circuit diagram, again the two devices appear broadly very similar (although a comparator device with an open-collector or open-drain output does look more obviously different from an op-amp). The big difference, which is not apparent without looking at the circuit more closely, is that the output stages of operational amplifiers are designed for linear operation, with the general aim of amplifying the input signal with as little distortion as possible (assuming that some negative feedback is provided), but in the case of a comparator the output circuit is designed to operate in saturation, that is, to switch between the upper and lower output voltage limits without the provision of external feedback. Comparators often also offer a ground connection in addition to the usual power connections, and provide digital logic levels at their outputs while accepting symmetrical analogue input signals.

What do these differences mean in practice? Comparators can react very quickly to changes in their input voltages with short propagation delays and output rise- and fall-times all specified by the manufacturer.

In contrast, because op-amps are not expected to be used in this mode, manufacturers tend not to give explicit specifications for propagation delay and rise- and fall-times (although they do normally specify slew rate), and these characteristics can be considerably poorer for op-amps than for comparators. To take an extreme example, a low-power op-amp might have a propagation delay measured in milliseconds, whereas a comparator might react in nanoseconds: a million times faster.

There is a further problem with op-amps. Many devices exhibit significantly increased power consumption when the output is in saturation, the resulting power dissipation on occasion being enough to destroy the device. Also, many op-amps (those not advertised as having “rail-to-rail outputs”) are not capable of driving their outputs close to the supply rails, for example having a maximum output voltage of 3 V with a 5-V supply. There can also be restrictions on the inputs. Some op-amps are equipped with antiparallel diodes across their input terminals, which prevent differential input voltages of more than about 0.6 V, whereas comparators’ inputs are often allowed to vary over the whole supply range.

Of course, there are many noncritical applications where an op-amp will work perfectly acceptably as a comparator, but it is not a practice to be recommended. The skeptic should lash up a quick test with a comparator and an op-amp side-by-side, each fed with a squarewave signal with rapid edges. Some of the potential pitfalls are shown up more easily in simulation, such as the possibility of an op-amp being so slow that it entirely misses a narrow pulse. It is hard to guarantee circuit performance, current consumption, and even the survival of the device.

The illustrations show a SPICE simulation of a relatively nimble op-amp (an LT1028 with a minimum slew rate of 11 V/µs) and a type LT1720 comparator. It is clear that the comparator responds sooner and with a much shorter rise-time. Its output swings all the way to +5 V rather than the 3 V managed by the op-amp. The situation is similar when the output swings low: the op-amp is much slower and only reaches an output voltage of –3 V rather than –5 V. The original squarewave is hardly recognizable at the op-amp’s output. Although the LT1028 cannot achieve its maximum specified gain with a –5-V supply, it is still a factor of at least 20 faster than an LM324 (with a slew rate of 0.5 V/µs); what the latter would make of our squarewave would not be a pretty sight. The op-amp fails to cope at all with shorter pulses, which are then effectively “swallowed,” while the comparator continues to handle them without difficulty.

Worthwhile further reading on this subject is Texas Instruments application note SLOA067 by Bruce Carter entitled “Op Amps and Comparators—Don’t Confuse Them!.”— Michael Holzl, Elektor January 2011

CircuitCellar.com is an Elektor International Media publication.

Build an Adequate Test Bench (EE Tip #127)

It’s in our makeup as engineers that we want to test our newly received boards as soon as possible. We just can’t wait to connect them to a power supply and then use our test bench equipment (e.g., generators, oscilloscopes, switches or LEDs, and so on) for simulation.

Circuit Cellar columnist Robert Lacoste's workspace in Chaville, France.

Circuit Cellar columnist Robert Lacoste’s clean, orderly workspace in Chaville, France.

But due to our haste, the result is usually a PCB under test lying on a crowded workbench in the middle of a mesh of test cables, alligator clamps, prototyping boards, and other probes. Experience shows that the probability of a short circuit or mismatched connection is high during this phase of engineering excitement.

Test Board

Rather than requiring a mesh of test wires, it is often wise to develop a small test PCB that will drastically simplify the test phase. Here the ancillary board provided a clean way to connect a Microchip Technology ICD3 debugger, a JTAG emulator, a debug analyzer, and a power supply input.

Take your time: prepare a real test bench to which you can connect your board. It could be as simple as a clean desk with properly labeled wires, but you might also need to anticipate the design of a test PCB in order to simplify the cabling.—Robert Lacoste, “Mixed-Signal Designs,” CC25:25th Anniversary Issue, 2013. 


New 8-bit PIC Microcontrollers: Intelligent Analog & Core Independent Peripherals

Microchip Technology, Inc. announced Monday from EE Live! and the Embedded Systems Conference in San Jose the PIC16(L)F170X and PIC16(L)F171X family of 8-bit microcontrollers (MCUs), which combine a rich set of intelligent analog and core independent peripherals, along with cost-effective pricing and eXtreme Low Power (XLP) technology. Available in 14-, 20-, 28-, and 40/44-pin packages, the 11-member PIC16F170X/171X family of microcontrollers integrates two op-amps to drive analog control loops, sensor amplification and basic signal conditioning, while reducing system cost and board space.

PIC16F170X/171X MCUs reduce design complexity and system BOM cost with integrated op-amps, zero cross detect, and peripheral pin select.

PIC16F170X/171X MCUs reduce design complexity and system BOM cost with integrated op-amps, zero cross detect, and peripheral pin select.

These new devices also offer built-in Zero Cross Detect (ZCD) to simplify TRIAC control and minimize the EMI caused by switching transients. Additionally, these are the first PIC16 MCUs with Peripheral Pin Select, a pin-mapping feature that gives designers the flexibility to designate the pinout of many peripheral functions.

The PIC16F170X/171X are general-purpose microcontrollers that are ideal for a broad range of applications, such as consumer (home appliances, power tools, electric razors), portable medical (blood-pressure meters, blood-glucose meters, pedometers), LED lighting, battery charging, power supplies and motor control.

The new microcontrollers feature up to 28 KB of self-read/write flash program memory, up to 2 KB of RAM, a 10-bit ADC, a 5-/8-bit DAC, Capture-Compare PWM modules, stand-alone 10-bit PWM modules and high-speed comparators (60 ns typical response), along with EUSART, I2C and SPI interface peripherals. They also feature XLP technology for typical active and sleep currents of just 35 µA/MHz and 30 nA, respectively, helping to extend battery life and reduce standby current consumption.

The PIC16F170X/171X family is supported by Microchip’s standard suite of world-class development tools, including the PICkit 3 (part # PG164130, $44.95), MPLAB ICD 3 (part # DV164035, $189.99), PICkit 3 Low Pin Count Demo Board (part # DM164130-9, $25.99), PICDEM Lab Development Kit (part # DM163045, $134.99) and PICDEM 2 Plus (part # DM163022-1, $99.99). The MPLAB Code Configurator is a free tool that generates seamless, easy-to-understand C code that is inserted into your project. It currently supports the PIC16F1704/08, and is expected to support the PIC16F1713/16 in April, along with all remaining microcontrollers in this family soon thereafter.

The PIC16(L)F1703/1704/1705 microcontrollers are available now for sampling and production in 14-pin PDIP, TSSOP, SOIC and QFN (4 x 4 x 0.9 mm) packages. The PIC16F1707/1708/1709 microcontrollers are available now for sampling and production in 20-pin PDIP, SSOP, SOIC and QFN (4 x 4 x 0.9 mm) packages. The PIC16F1713/16 MCUs are available now for sampling and production in 28-pin PDIP, SSOP, SOIC, QFN (6 x 6 x 0.9 mm) and UQFN (4 x 4 x 0.5 mm) packages. The PIC16F1718 microcontrollers are expected to be available for sampling and production in May 2014, in 28-pin PDIP, SSOP, SOIC, QFN (6 x 6 x 0.9 mm) and UQFN (4 x 4 x 0.5 mm) packages. The PIC16F1717/19 microcontrollers are expected to be available for sampling and production in May 2014, in 40/44-pin PDIP, TQFP and UQFN (5 x 5 x 0.5 mm). Pricing starts at $0.59 each, in 10,000-unit quantities.

Source: Microchip Technology, Inc.

A Wire Is an Inductor (EE Tip #126)

I’m confident you know that you should keep wires and PCB tracks as short as possible. But I’m also sure that you will underestimate this problem fairly frequently.

Remember that 1 cm of a 0.25-mm-wide PCB track is roughly equivalent to an inductance of 10 nH. If this 10 nH is paired with, say, a 10-pF capacitor, that gives a resonant frequency as low as 500 MHz, which is easily below the third or fifth harmonics of the clock frequencies commonly seen on modern high-speed digital boards. Similarly, a 1-cm-long track will jeopardize the performances of any RF system such as a 2.4-GHz transceiver. There is only one solution: keep tracks and wires as short as possible. If you can’t, then use impedance-matched tracks.

Remember this rule especially for the ground connections: any grounded pad of any part working in high frequencies should be directly connected by avia to the underlying ground plane. And this via must be as close as possible to the pad, not some millimeters away.

Just yesterday I did a design review of a customer’s RF PCB. A small 0402 inductance was grounded through a via that was 3 mm away. It was a bad idea because the inductance was as low as 1 nH. Those 3 mm changed its value completely.—Robert Lacoste, “Mixed-Signal Designs,” CC25:25th Anniversary Issue, 2013. 

Client Profile: Integrated Knowledge Systems

Integrated Knowledge Systems' NavRanger board

Integrated Knowledge Systems’ NavRanger board

Phoenix, AZ

CONTACT: James Donald, james@iknowsystems.com

EMBEDDED PRODUCTS: Integrated Knowledge Systems provides hardware and software solutions for autonomous systems.
featured Product: The NavRanger-OEM is a single-board high-speed laser ranging system with a nine-axis inertial measurement unit for robotic and scanning applications. The system provides 20,000 distance samples per second with a 1-cm resolution and a range of more than 30 m in sunlight when using optics. The NavRanger also includes sufficient serial, analog, and digital I/O for stand-alone robotic or scanning applications.

The NavRanger uses USB, CAN, RS-232, analog, or wireless interfaces for operation with a host computer. Integrated Knowledge Systems can work with you to provide software, optics, and scanning mechanisms to fit your application. Example software and reference designs are available on the company’s website.

EXCLUSIVE OFFER: Enter the code CIRCUIT2014 in the “Special Instructions to Seller” box at checkout and Integrated Knowledge Systems will take $20 off your first order.


Circuit Cellar prides itself on presenting readers with information about innovative companies, organizations, products, and services relating to embedded technologies. This space is where Circuit Cellar enables clients to present readers useful information, special deals, and more.