Electronic – Op-amp (LM358N) half-wave rectifier and 3.3V clamp

operational-amplifierrectifiertachometer

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.

Best Answer

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:

schematic

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.