I was wondering if I could have some feedback on this circuit.

The goal is to:

  1. Input up to 18VAC sine waves (possibly noisy) up to 20khz.
  2. Output 3.3V digital pulses.
  3. Minimize discrete part count.

I have built this circuit and it seems to work fine.

enter image description here

The left op-amp is wired to operate as a voltage clamp. Because the LM358N is not Rail to Rail, the output of this first op-amp is max 2V (3.3V - 1.3V spec'd rail voltage offset.)

The right op-amp is wired to operate as a Comparator. This allows the circuit to output full-rail 3.3V when the input signal crosses the the threshold voltage, as defined by the two resistors shown.

In the SPICE simulation below, the black sinusoid is the input signal, the green line is from the left op-amp and the orange is the right op-amp output.

enter image description here

Some notes:

  1. This circuit started off with a few more resistors and diodes, based on a bunch of other circuits on the web. I'm not sure why, but I couldn't get most of the other circuits working in SPICE, while this one both simulated properly in SPICE and works properly on the breadboard. This makes me suspicious that I'm missing something that everyone else is seeing. Yet it is working fine in reality.

  2. I actually tested the left op-amp circuit by itself as an input to a 3.3V Arduino, and while it worked for square wave and triangle wave inputs, the Arduino interrupt handler activated two or three times the actual pulse rate when using a sine wave. That was why I added the Comparator stage.

Some cons:

  1. Obviously, skew.
  • 1
    \$\begingroup\$ The first stage is wired as a buffer, the second stage is simply a comparator. There is NO feedback that would make this a Schmitt trigger. You need to limit the voltage excursion on the first op-amp by either including a +/- clamp with series resistor or providing feedback from the output. What is your intent? ...to get as close as possible to the zero crossing? \$\endgroup\$ – Jack Creasey Feb 18 '19 at 15:02
  • \$\begingroup\$ Thanks. I've updated the circuit. The intent is to simply to: 1. Input a sine wave with voltage from 2V to 18V p-p 2. Convert the sine wave into square wave pulses. You're right...this is a comparator and not a Schmitt Trigger...I'll update the post title....and try to implement a proper Schmitt Trigger. \$\endgroup\$ – hype Feb 18 '19 at 15:07
  • 1
    \$\begingroup\$ Your new circuit still does not work. \$\endgroup\$ – Jack Creasey Feb 18 '19 at 15:10
  • \$\begingroup\$ But it does work. It's working right here on a breadboard and my 4084 signal generator... \$\endgroup\$ – hype Feb 18 '19 at 15:16
  • \$\begingroup\$ I'm going to go back to the drawing board and try to figure out what you're saying. I trust you, I just need to understand what the difference is between what you're telling me and what I'm seeing. \$\endgroup\$ – hype Feb 18 '19 at 15:24

Input up to 18VAC sine waves (possibly noisy) up to 20khz. With minimized part count.

The choice of the LM358 is particularly problematic, it is not a rail-rail output and at 3.3V operation a poor candidate. The input common mode limitations force you far from zero for any comparison point.

You would be much better doing the following:

  1. Use a comparator meant for operation at low voltage,
  2. Use a part that allows comparison at close to zero.

Here is a potentially suitable circuit using the LM393 comparator:


simulate this circuit – Schematic created using CircuitLab

  1. The LM393 works down to 3.3V single rail.
  2. The trigger point is close to zero.
  3. There is about 100mV hysteresis. You can alter R2 to change this.

There's something a bit subtle going on at the input. You've provided no deliberate path for the op-amp input bias current (which flows out of the input on the LM358), however you've used a very leaky Schottky diode so that's what is happening there. It will change around with temperature and is a pretty schlocky thing to do.

The LM358 can withstand higher (but not much lower) input voltage than the supply rails, so you're not actually exceeding the absolute maximum ratings with 15V input and 3.3V supply (don't try this with a CMOS op-amp, you'll probably destroy not only the op-amp but everything else attached to the 3.3V rail) but the recovery time may be fairly long.

You've done nothing to deal with noise except using a glacially sluggish antediluvian op-amp as a comparator, which is slow (so no high frequencies get through, usually) but is not a Schmitt trigger.

You can try something more like the below. I've reversed the logic in order to improve the positive feedback. The piggy-backed triangle wave simulates noise on top of the sine wave input.


simulate this circuit – Schematic created using CircuitLab

D2 shunts away negative voltages and R6/R5 divide the voltage down so that it doesn't cause the op-amp to reverse phase as Lm358 bipolar op-amps are wont to do.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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