Debouncing with OpAmp

Discussion in 'General Electronics Chat' started by MikeA, Mar 24, 2014.

  1. MikeA

    Thread Starter Member

    Jan 20, 2013
    125
    17
    Hi, I have a circuit board with a 4-channel op-amp that is amplifying a signal using one of the channels. I'm feeding the amplified output to an Arduino and using an external interrupt to find the falling/rising edge.

    But I'm getting bouncing on the edge as there is noise in the amplified signal. The signal is a sine wave between 0.1hz to 30hz or thereabouts.

    I'd obviously like to eliminate the bounce, and I'm assuming I can setup a Schmitt trigger using one of the extra channels. The amplified signal ranges from about 0.5v to 3.5v, and I already have a voltage divider at 2.5v on the board that I can tap into.

    How would my debounce circuit look like? And I'm assuming I need a capacitor-resistor pair that would have to match my sine wave frequency range to debounce it just right? :confused:
     
  2. MrChips

    Moderator

    Oct 2, 2009
    12,440
    3,360
    The rising and falling edges of a sine wave is not very steep.
    Use an analog comparator to detect the edge.
     
  3. MikeA

    Thread Starter Member

    Jan 20, 2013
    125
    17
  4. MrChips

    Moderator

    Oct 2, 2009
    12,440
    3,360
    Yes, you can do it with an op-amp.
    An op-amp with open-loop gain makes it a comparator. By adding positive feedback you give it hysteresis. That is what the schmitt trigger does.
     
  5. MikeA

    Thread Starter Member

    Jan 20, 2013
    125
    17
    [​IMG]

    That would be perfect if I can just use the existing op-amp. How would I connect up the 2 channels of the LM324? Just take the output of one channel and connect it to the input of the other?
     
  6. MrChips

    Moderator

    Oct 2, 2009
    12,440
    3,360
    I am not sure why you need two channels (op-amps).
    Simply use one of the unused op-amps in the LM324.
     
  7. MikeA

    Thread Starter Member

    Jan 20, 2013
    125
    17
    Maybe I'm not getting the terminology right, but I think that's what I meant. Taking output from op-amp that is amplifying the sine wave and feeding it straight into input to the other opamp set up like the image above?
     
  8. crutschow

    Expert

    Mar 14, 2008
    13,003
    3,232
    The circuit you show in post #5 looks fine for the Schmitt trigger. You can run it through another opamp if you want a non-inverted signal.
     
  9. MikeA

    Thread Starter Member

    Jan 20, 2013
    125
    17
    So I've set up my LM324N with 5v Vcc, divider @ 2.5v (10K+10K) and a 28K resistor from output and V+. And got everything to work as I wanted, just had to blindly play with the resistor.

    The 28K resistor gives me thresholds at 2.2v and 2.6v. But the simulator at the link(http://hyperphysics.phy-astr.gsu.edu/hbase/electronic/schmitt.html) would suggest that my thresholds should be 1.3v and 2.8v.

    Why the discrepancy? Is it because it's an op-amp and not a comparator? Are all comparators equal and that simulator would be true for all of them? Is there a way to simulate the same thing with an op-amp?
     
  10. crutschow

    Expert

    Mar 14, 2008
    13,003
    3,232
    I tried the link simulator and it gave me thresholds of 2.14V and 2.62V, close to your calculations. Don't know how you got those other values.

    Note that the simulator apparently assumes a high output voltage of 5V but the LM324 has a high output of a least a volt below the supply voltage, so that will affect the upper threshold in real life.

    To get a more realistic simulation you can use a Spice simulator such as the free LTspice download from Linear Technology.
     
  11. MikeA

    Thread Starter Member

    Jan 20, 2013
    125
    17
    That's really odd. :eek:
     
  12. crutschow

    Expert

    Mar 14, 2008
    13,003
    3,232
    Yes, it is. Don't see why the difference.
     
  13. MikeA

    Thread Starter Member

    Jan 20, 2013
    125
    17
    I just tried it in different browsers (Firefox & Opera) and on a different computer. They all showed me the same 2.8V and 1.3V thresholds.

    crutschow, can you please check it again? Maybe the NSA is doing something to my traffic. :D

    Edit: I think you left the resistor at 100K, my circuit has 28K. But that still leaves the question why my real life test was so different from the simulator.
     
  14. crutschow

    Expert

    Mar 14, 2008
    13,003
    3,232
    OK, I redid the website calculation and it now gives the values you show (which are not correct). So it appears to be some bug in the website calculations.
     
Loading...