Connect with us

Need help with op-amp/comparator circuit

Discussion in 'Electronic Basics' started by Anthony Fremont, Jan 14, 2005.

Scroll to continue with content
  1. Hello all,

    Danny got me thinking about my op-amp stuff, so I resurrected it for
    another application/experiment. Now what I'm doing is that I'm trying
    to "hear" some tapping type noises (actually an antique clock
    tick-tock). What I want to do is to measure the spacing between the
    beats. I'm sure to be in violation of someone's patent, but this is for
    personal use so on to the show. ;-)

    I am currently using the circuit below. The 10K voltage dividers were
    empirically picked so that the idle output voltage of the 741 is 2.52V,
    the divider on the 393 is at 2.50V leaving a 20mV difference.
    Everything works pretty much as expected (i.e. the 393's output rides at
    +5V until a loud enough noise causes the comparator output to flip) A
    "loud enough noise" is anything that causes the 741's output to shift by
    more than about 20mV. What I'm seeing on the scope peaks at about 500mV
    on the output of the 741.

    The 393 then swings low on the peaks of the tick sound like I want, but
    the the comparator's output swings high again between the peaks of the
    audio waves (every couple of mS) giving me a stream of pulses. What I
    want is for the output to pull low and stay low until the tick sound
    decays a bit (interpret this as about 50mS'ish ;o). IOW, I want to low
    pass filter the output of the 393. The base pitch of the sound seems to
    be around 600Hz or so. The sharp intial attack is all I'm really after,
    the main jist of the sound is between 40 and 60mS in length.

    I tried putting a 1uF cap to ground on the output of the 393. This
    helps, but I still get allot of ripple on the low signal. Bigger caps
    do better, but they also lead to real slow rise times even with the
    fairly stout pullup (2K). What do I do now? I think I need to add some
    RC time constant somewhere, but not sure where.

    VCC +5V VCC +5V VCC +5V
    + + +
    | | |
    | | |
    .-. .-. .-.
    | |10K | |10K | |
    | | ___ 100K | | | |2K
    '-' .---|___|----. '-' '-'
    | | | | |
    | | | | |
    10uF 1K | | LM741 | | LM393|\| |
    || ___ | | |\| | o--------|-\ |
    |\ __ .--||--|___|---(---o-------|-\ | | | >--o--->OUT
    | | |- || | | >-o----(--------|+/
    | |__|---------------o-----------|+/ | |/|
    |/ | |/| |
    .-. .-.
    Speaker IN | |10K | |10K
    | | | |
    '-' '-'
    | |
    | |
    === ===
    (created by AACircuit v1.28.4 beta 13/12/04
  2. The 741 is almost comatose if it is powered from only 5 volts. An
    LM324 quad would have more input and output swing capability with a
    low voltage supply.

    I would also connect the amplifier to the comparator through a voltage
    doubling rectifier to convert the audio to DC, for a cleaner pulse out
    of the comparator.

    This would consist of a series capacitor on the opamp output, with a
    diode connecting that to a 2.5 volt reference divider (say, cathode to
    capacitor) and also a second diode (anode to capacitor) connecting to
    a second capacitor and the comparator input, with the other end of
    that cap to ground. When the amplifier swings negative, the diode to
    the 2.5 volt reverence voltage keeps the series cap from going more
    negative than about 2 volts, and then on the positive swing, the
    voltage rises from that to a more positive voltage that is 2 + the
    peak to peak of the audio, the positive peaks of that passing through
    the second diode to the low pass filter cap. You will also need a
    high value resistor from the comparator input to the 2.5 volt
    reference to fade the positive voltage out after the pop is over.
  3. john jardine

    john jardine Guest

    Give it a bit of feedback. Adding the C and Rs will (on triggering) force
    the o/p low for about 100ms then the output goes high for about 100ms. Then
    ready and waiting for the next 'tick' soundburst.

    -|-\ |
    ___ | >--o---
    741 o/p o--|___|-o-------|+/ |
    47k | |/| |
    | |
    | |
    | ___ || |
    100k 470n
  4. Thanks allot John! It really works, though I don't really understand it
    all. I tried it without the 47K in between the 741 and 393, no effect
    at all. But when I did it right, it gave me long pulses. I eventually
    lowered the cap value to .1uF and the pulse length is about 60mS. I
    can't really tell, but is the pulse length determined from the start of
    the tick sound, or after it decays to the point that it's no longer
    triggering the 393? How does the 47K resistor figure in?
  5. I'm now experiencing an oscillation problem with the 393. I'm fairly
    sure it was working fine at first (at least the scope looked right
    comparing the output of the 741 with the output of the 393 and
    triggering on the 393, things were lining up correctly), but now it's
    self triggering and I can't seem to make it stop. :-( The oscillation
    is at the RC time constant rate. It doesn't even seem to need a trigger
    pulse to get it going. I tried playing with the 47K and the cap, and it
    doesn't seem to help any. How can I get less feedback, but not screw up
    the time constant?

  6. With a constant input, and absent noise effects, and
    assuming the input is not within the small range for
    which the comparator's output is non-saturated,
    the above circuit should not oscillate. This leads
    me to believe that you input is near enough to that
    small active range, with enough noise on it that an
    output transition is triggered by the noise. Due to
    the AC positive feedback, once triggered, the
    input is dominated by the feedback, and that is why
    you see "oscillation" at about the 1/RC frequency.

    I skimmed your earlier post on the circuit preceding
    the above, and thought that the manner in which the
    near-threshold bias was achieved could not be too
    reliable or stable. So I would look into that.
  7. That appears to be correct (see my post in the thread with John
    Popelish). The 47K resistor gives a little voltage drop that put things
    too close to the gray area. Yeah, I know the hand-selected voltage
    divider is a bit cheesy, but it's just a breadboard project right now.
    I may actually solder up a permanent version of this project though.
    I'll add some "knobs" for tweaking. I'm also adding two leds so that
    you can tell when it's synced to both the "tick" and the "tock".
    That'll be easier than dragging the scope around. ;-D
  8. Jamie

    Jamie Guest

    you need something like a non reset able one shot timer.
    i do think the out of the 741 could be used to trigger
    a 555 for a one shot mode.
    i think your trying to get a clean logic pulse.
  9. Hello Jamie and thanks for the reply,

    I was seriously considering doing something like that, but the RC
    feedback on the comparator is doing a nice job of cleaning up the
    signal. I now have it feeding into a PIC and two LEDs to indicate the
    "tick" and the "tock". It looks kinda neat. :)
  10. I'm having a bit of trouble with this still, forgive me for being
    moronic. First let's see if I'm getting any of this.

    After tinkering around with this circuit for a bit, I think I understand
    how it works (sorta ;-). When the comparator output goes low (due to
    741 output going below divider voltage), it feeds back and drives the +
    input even lower, holding it down. This voltage is kind of "stuck" and
    helps hold the comparator output low until it bleeds away thru the 47K
    resistor. When the 741's output can no longer hold the + input lower
    than the voltage divider input (-), it flips back high and does the same
    thing again only this time forcing the + input even higher until the
    voltage can bleed away thru the 47K resistor. Is that about right? If
    that's true, how does the 100K resistor figure in? Is it setting the
    gain to roughly 2 (100k/47k)? If so, why? Is it to help prevent signal
    degradation from the 47K resistor?

    Thanks for all your help, everyone
  11. The instantaneous positive feedback that happens whenever the + input
    reaches a match with the - input is determined by the ratio of the
    input and feedback resistor, and the voltage swing on the comparator
    output. Lets say the - input is held at 2.5 volts and the comparator
    produces a full 5 volt swing. So every time the + input approaches
    2.5 volts, the positive feedback will swing it to 2.5 + or -
    5*47k/(100k+47k)= 2.5 + or - 1.6 volts, driving the + input way past
    what it just takes to swing the output. But since there is a
    capacitor in series with the positive feedback, the effect fades out
    with a (100k+47k)*C time constant. So the overdrive disappears almost
    completely after about 5 time constants and the comparator goes back
    to looking pretty directly at whatever voltage is coming from the 741
    through the 47k resistor.
  12. So what you are saying is that the two resistors do act the same as when
    in a regular op-amp, they establish gain. Does that mean that the
    comparators gain went from its normallly immense value to 2 with the
    adition of the feedback/input components? Or does it retain it's huge
    voltage gain.
    5 time constants....hmm.... I'm seeing the comparator flip back after a
    bit over 2*RC on the scope. Currently, I'm liking a .22uF cap in there.
    It gives me about a 60mS low and a following stiff high for about the
    same time I think, for a total of possibly 5*RC. It's pretty nifty, and
    it does work, but it seems to make the comparator a bit touchy to things
    like fingers, voltmeter probes, etc.

    I ran into some problems with noise from the LCD getting into the
    system. I was updating the display every 100mS and that perfectly
    coincided with the noise I was seeing, so by a stroke of pure genius I
    concluded that they might be related. I tried allot of different things
    to eliminate the burst of noise. Bypass caps all over (mostly a waste
    of time), rerouting the LCD wiring (total waste of time), and finally
    installing a .1 ceramic to ground on the 741's mic input (the pin that
    leads to the inverting input). Strangely (to me), putting a cap on the
    non-inverting input of the comparator had little effect on the noise.
    Once I found the right spot, the noise all but disappeared. This made
    it seem to me like it was being picked up by the wire leading to my mic,
    which would seem very logical. However, moving it around and clasping
    my hand over it had no effect on the noise problem. By relocating the
    10uF cap and the 1K resistor (now 500 ohms for better gain) and putting
    in the bypass cap where the mic wiring connected to the breadboard,
    problem solved.

    It's accurately giving me the half-beat time intervals in whole mS
    instead of 100nS intervals. Not that I didn't like the added precision,
    but many clocks vary the balance of the beat by as much as 10% during
    one revolution of the escape wheel so the numbers looked erratic since
    jumps of several mS per tick are common. Especially when you get to the
    part of the wheel that contains the first and last tooth cut during
    manufacturing. You can also press a button and it counts whole beats
    for one minute and then prints the BPM value. Now to add some kind of
    optical sensor ability and data logging and write a bunch more PIC code.
    It also needs a serial interface so I can hook it to a computer and
    start whipping together some VB code to make it look impressive. ;-)

    Thanks for your help, it's greatly appreciated.
  13. You're thinking of the closed loop gain with negative feedback.
    In this case, the feedback is positive. Depending on how you
    like to define gain, this can be considered to increase the gain
    beyond its unfedback value.
  14. No. The gain is not 2. Positive feedback raises gain. Sufficient
    positive feedback (and this ratio of resistors is definitely
    sufficient) raises the gain beyond infinity. An infinite gain
    produces a finite output from zero input. This feedback produces so
    much gain that it produces an output in spite of opposing input. In
    other words, once the output begins its swing, that swing is
    reinforced by the feedback, even if the input signal changes direction
    and backs down a significant amount. The positive feedback makes a
    decision to begin swinging the output essentially irrevocable without
    a really big reversal in the direction of the input voltage.
    So you must be comparing the 741 output to a reference voltage offset
    more than 1% of 1.6 (the positive feedback voltage) volts from the
    bias voltage of the 741 (the zero signal amplifier voltage). The 5
    time constants I referred to is how long it takes for the positive
    feedback to decay to 1% of its initial value (of 1.6 volts).
    The tiniest moment that the two inputs of the comparator approach
    equality produces the same output as a big pop on the input. Once the
    output starts to move, it becomes the input signal, overwhelming the
    input from the opamp.
    That node has gain. Try putting small caps in parallel with the opamp
    feedback resistor, to roll the high frequency gain of the amplifier.
    Averaging successive periods is probably best done in software.
  15. I currently have the 741's output at 2.52V and the 393's divider at
    Looks pretty odd on the scope, something like an inductive kickback in a
    motor supply line.
    Ok, I'll try that and see how it looks on the scope without the cap I
    added. This was so weird at first because it only caused a problem when
    you pushed the button to calculate BPM. That made it seem like the
    software was somehow screwing up the beat detection making it count
    extra ticks. The reason that the display didn't cause problems before
    was because I was only writing to it immediately after detecting a tick.
    When doing the BPM calculation I kept a running total on the display
    that was updated every 100mS. Sometimes this led to extraneous triggers
    causing the LEDS to be out of sync with the pendulum. I was fortunate
    that I spotted it on the scope.
    Phase II involves a PC interface and a serial eeprom.

    Thanks again. :)
  16. Ok, thank you for that. I think I "get it" now. ;-)
  17. Ah. About 8.8% of 1.6 volts.

Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day