Author Topic: Circuit with op amp lm339  (Read 28401 times)

0 Members and 1 Guest are viewing this topic.

Offline Seekonk

  • Super Contributor
  • ***
  • Posts: 1938
  • Country: us
Re: Circuit with op amp lm339
« Reply #25 on: December 28, 2015, 02:40:30 pm »
25nA  input current X 470,000 to get at least 3mv, though it appears to be three times the resistance needed unless I missed a decimal place.
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19533
  • Country: gb
  • 0999
Re: Circuit with op amp lm339
« Reply #26 on: December 28, 2015, 02:51:24 pm »
25nA  input current X 470,000 to get at least 3mv, though it appears to be three times the resistance needed unless I missed a decimal place.
Yes and choosing thee times the resistance needed was deliberate, as the bias current could be much lower than specified on the datasheet, which just gives the typical and highest values, not the lowest.
 

Offline Yansi

  • Super Contributor
  • ***
  • Posts: 3893
  • Country: 00
  • STM32, STM8, AVR, 8051
Re: Circuit with op amp lm339
« Reply #27 on: December 28, 2015, 05:21:13 pm »
That's strange, there are two different explanations of how the circuit works. And it's a simple circuit.

My theory is this:

The output of the op amp (someone called it a comparator) ..

Sorry to bother you again, that is not "someone called it", LM339 actually is a comparator, cannot be used as a general purpose opamp! You cannot interchange the two. Not the same!

Another piece you should know (and was mentioned in the beginning) is that some type of input circuitry (usualy with PNP stages) allows operation below ground level. Usually up to some hundred mV. Typical OPAMPies and COMPies like that are LM358, LM324, LM393, LM339, ... In the datasheet search for a term of "input commonmode voltage range" and that shout "include ground" if operation like that is required.

 

Offline alsetalokin4017

  • Super Contributor
  • ***
  • Posts: 2055
  • Country: us
Re: Circuit with op amp lm339
« Reply #28 on: December 28, 2015, 07:06:28 pm »
OK... so I went out to my local supplier and bought an LM339. For a dollar ... what a ripoff, could have ordered 10 for $3.50, free shipping from Colorado, but I didn't want to wait 3 or 4 days for them to get here.    :rant:

I breadboarded Hero999's version and it works fine ... but it does have a tendency to oscillate, which keeps the LED "on" (really, it's flashing on and off so fast it looks continuously on.) I cured this self-oscillation by putting 0.1 uF ceramic caps from pins 6 and 7 to Ground. Now the LED stays nicely off until I move a magnet past the coil.

The circuit is more sensitive than I expected (using the same ~50 ohm miniature relay coil) but nowhere nearly as sensitive as the TL082 version that I posted and demonstrated in the video above.

The easiest person to fool is yourself. -- Richard Feynman
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19533
  • Country: gb
  • 0999
Re: Circuit with op amp lm339
« Reply #29 on: December 28, 2015, 07:30:26 pm »
That's strange, there are two different explanations of how the circuit works. And it's a simple circuit.

My theory is this:

The output of the op amp (someone called it a comparator) ..

Sorry to bother you again, that is not "someone called it", LM339 actually is a comparator, cannot be used as a general purpose opamp! You cannot interchange the two. Not the same!

Another piece you should know (and was mentioned in the beginning) is that some type of input circuitry (usualy with PNP stages) allows operation below ground level. Usually up to some hundred mV. Typical OPAMPies and COMPies like that are LM358, LM324, LM393, LM339, ... In the datasheet search for a term of "input commonmode voltage range" and that shout "include ground" if operation like that is required.


Yes, it's important to be aware of the internal workings of the op-amp/comparator when dealing with a circuit like this. Looking at the input stage it's clear the bias current is positive, i.e. the inputs source current.



It's also interesting you mention the distinction between op-amps and comparators. It's possible to get an LM339 to work as an op-amp but it's not ideal. The datasheet even shows an example of a VCO which uses one of the comparators as an op-amp to form an integrator.


http://www.ti.com/lit/ds/symlink/lm339-n.pdf

OK... so I went out to my local supplier and bought an LM339. For a dollar ... what a ripoff, could have ordered 10 for $3.50, free shipping from Colorado, but I didn't want to wait 3 or 4 days for them to get here.    :rant:

I breadboarded Hero999's version and it works fine ... but it does have a tendency to oscillate, which keeps the LED "on" (really, it's flashing on and off so fast it looks continuously on.) I cured this self-oscillation by putting 0.1 uF ceramic caps from pins 6 and 7 to Ground. Now the LED stays nicely off until I move a magnet past the coil.

The circuit is more sensitive than I expected (using the same ~50 ohm miniature relay coil) but nowhere nearly as sensitive as the TL082 version that I posted and demonstrated in the video above.


Wow that's expensive!

You could've easily used the LM393 which will probably be cheaper as it only contains two comparators.

 

Offline nForceTopic starter

  • Frequent Contributor
  • **
  • Posts: 393
  • Country: ee
Re: Circuit with op amp lm339
« Reply #30 on: December 28, 2015, 07:51:07 pm »
25nA  input current X 470,000 to get at least 3mv, though it appears to be three times the resistance needed unless I missed a decimal place.

This is maybe a beginners question, but: From where does this input bias current come from? There is no negative loop, no positive loop and no current or voltage source. Only the coil.
 

Offline alsetalokin4017

  • Super Contributor
  • ***
  • Posts: 2055
  • Country: us
Re: Circuit with op amp lm339
« Reply #31 on: December 28, 2015, 07:59:48 pm »
@Hero999:

Looking through my parts stash, I found a LM393 in there, a used pull! So I'll give it a try next.

But what's worse.... I found 2 brand new LM339s that I didn't know I had, not on the inventory list. SO I didn't need to go out and spend any money, either way.   :palm:
The easiest person to fool is yourself. -- Richard Feynman
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19533
  • Country: gb
  • 0999
Re: Circuit with op amp lm339
« Reply #32 on: December 28, 2015, 08:49:57 pm »
25nA  input current X 470,000 to get at least 3mv, though it appears to be three times the resistance needed unless I missed a decimal place.

This is maybe a beginners question, but: From where does this input bias current come from? There is no negative loop, no positive loop and no current or voltage source. Only the coil.
It comes from the base of Q1 & Q4, shown in the schematic attached to my previous post.
 

Offline nForceTopic starter

  • Frequent Contributor
  • **
  • Posts: 393
  • Country: ee
Re: Circuit with op amp lm339
« Reply #33 on: December 28, 2015, 09:15:33 pm »
So if I understand correctly, the input bias current runs from non-inverting and inverting input out. So away from the inputs, not in  the comparator.
 

Offline SeanB

  • Super Contributor
  • ***
  • Posts: 16284
  • Country: za
Re: Circuit with op amp lm339
« Reply #34 on: December 29, 2015, 07:23:30 am »
PNP transistors source a current to ground, NPN transistors sink a current to ground. Input of comparator internally uses PNP transistors in the first differential pair.
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19533
  • Country: gb
  • 0999
Re: Circuit with op amp lm339
« Reply #35 on: December 29, 2015, 10:27:46 am »
So if I understand correctly, the input bias current runs from non-inverting and inverting input out. So away from the inputs, not in  the comparator.
Yes, it's because, in order to switch on a PNP transistor, a current needs to flow out of the base.

In op-amps/comparators with an NPN stage, such as the uA741 and NE5532, the bias currents will flow into the inputs.

741 schematic

http://www.sentex.ca/~mec1995/gadgets/741/741.html

Note that this isn't always the case. In some op-amps, such as the OP07 and OP37, an NPN input stage is used and bias compensation circuitry is added to try to reduce the bias current to zero but it isn't perfect so the inputs may either source or sink a tiny current.
 

Offline alsetalokin4017

  • Super Contributor
  • ***
  • Posts: 2055
  • Country: us
Re: Circuit with op amp lm339
« Reply #36 on: December 29, 2015, 05:03:19 pm »
And then of course there are op-amps that use FET input stages, like the TL08x series ....

 
The easiest person to fool is yourself. -- Richard Feynman
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19533
  • Country: gb
  • 0999
Re: Circuit with op amp lm339
« Reply #37 on: December 29, 2015, 08:54:25 pm »
And then of course there are op-amps that use FET input stages, like the TL08x series ....
Which have  tiny bias current, until the input voltages is taken too near the negative rail, then the gates on the input transistors become forward biased, phase reversal occurs and a the bias current shoots up.
 

Offline nForceTopic starter

  • Frequent Contributor
  • **
  • Posts: 393
  • Country: ee
Re: Circuit with op amp lm339
« Reply #38 on: December 29, 2015, 10:48:11 pm »
OK... so I went out to my local supplier and bought an LM339. For a dollar ... what a ripoff, could have ordered 10 for $3.50, free shipping from Colorado, but I didn't want to wait 3 or 4 days for them to get here.    :rant:

I breadboarded Hero999's version and it works fine ... but it does have a tendency to oscillate, which keeps the LED "on" (really, it's flashing on and off so fast it looks continuously on.) I cured this self-oscillation by putting 0.1 uF ceramic caps from pins 6 and 7 to Ground. Now the LED stays nicely off until I move a magnet past the coil.

The circuit is more sensitive than I expected (using the same ~50 ohm miniature relay coil) but nowhere nearly as sensitive as the TL082 version that I posted and demonstrated in the video above.

Can you attach a schematic of this final circuit that you build. How are capacitors helping with oscillation problem?

Thank you.
 

Offline Seekonk

  • Super Contributor
  • ***
  • Posts: 1938
  • Country: us
Re: Circuit with op amp lm339
« Reply #39 on: December 29, 2015, 11:14:35 pm »
YOUR RESULTS MAY VARY

Operation of this circuit are based solely on the operation of a comparator.  The trip point of the comparator is totally uncontrolled due to variations in input current and offset voltage.  No effort has been made to adjust for variations from chip to chip.  Build five and you could easily get five different results.  I haven't seen anything which constituted a design.
 

Offline alsetalokin4017

  • Super Contributor
  • ***
  • Posts: 2055
  • Country: us
Re: Circuit with op amp lm339
« Reply #40 on: December 30, 2015, 12:20:13 am »
OK... so I went out to my local supplier and bought an LM339. For a dollar ... what a ripoff, could have ordered 10 for $3.50, free shipping from Colorado, but I didn't want to wait 3 or 4 days for them to get here.    :rant:

I breadboarded Hero999's version and it works fine ... but it does have a tendency to oscillate, which keeps the LED "on" (really, it's flashing on and off so fast it looks continuously on.) I cured this self-oscillation by putting 0.1 uF ceramic caps from pins 6 and 7 to Ground. Now the LED stays nicely off until I move a magnet past the coil.

The circuit is more sensitive than I expected (using the same ~50 ohm miniature relay coil) but nowhere nearly as sensitive as the TL082 version that I posted and demonstrated in the video above.

Can you attach a schematic of this final circuit that you build. How are capacitors helping with oscillation problem?

Thank you.
Which "final circuit"? The LM339 and LM393 versions are Hero999's circuit shown in Reply #13 which is a modification of the original circuit you linked in the original post. I added 100nF capacitors from Pins 6 and 7 to ground, which stopped the oscillations for me.  "MY" extremely sensitive version using the TL082 is shown at the end of the demonstration video I posted, and on the previous page (Reply # 20).
The capacitors in the 339/393 versions work to kill the oscillations by bypassing AC noise/oscillation to ground so it doesn't affect the inputs. In my TL082 version the 200 nF capacitor is feeding back oscillations from the output to the inverting input in a negative feedback loop which tends to cancel them out. I think.


@Seekonk:  There may not be "anything which constitutes a design"... but I've built, and demonstrated, examples that work quite well nevertheless. I also determined the likely reason the OP's LED was staying on: the circuit was oscillating. I did this by applying my _practical knowledge_ and using an oscilloscope to confirm my educated guess, and I also applied this knowledge to fix that problem.  Designs are nice, but they are only designs, until someone puts them into practice and shakes out the bugs.
« Last Edit: December 30, 2015, 12:23:44 am by alsetalokin4017 »
The easiest person to fool is yourself. -- Richard Feynman
 

Offline nForceTopic starter

  • Frequent Contributor
  • **
  • Posts: 393
  • Country: ee
Re: Circuit with op amp lm339
« Reply #41 on: December 30, 2015, 11:17:54 am »
The final circuit with LM339.

So, the capacitors help reduce  AC oscillations. Can you describe more detailed?
 

Offline Seekonk

  • Super Contributor
  • ***
  • Posts: 1938
  • Country: us
Re: Circuit with op amp lm339
« Reply #42 on: December 30, 2015, 02:24:33 pm »
The following schematic is one of many possible solutions.  It reduces some of the problems
of input offset and bias current variations between chips.  The first stage provides a small
gain for AC signals and no gain for the offset voltage.  This reduces the effect of offset
uncertainty.  Raising the input voltage to half of supply reduces the chance of IV damage
due to spikes and solves the problem of op amps that inputs are not rail to rail.

The second stage has two comparators and detects positive and negative signals.  Adjusting
the 1K pot changes the trip plus minus points from about  7 to 50 mv. High frequency roll off
can be achieved by placing a small cap across RG.  A pair of diodes can be used to OR the
outputs if an op amp is used instead of a 339.  Inputs are not designated.  If it doesn't
jump out right away it is time to view one of Dave's op amp videos.  You should learn something
by building.
 

Offline nForceTopic starter

  • Frequent Contributor
  • **
  • Posts: 393
  • Country: ee
Re: Circuit with op amp lm339
« Reply #43 on: December 30, 2015, 10:48:07 pm »
@alsetalokin4017

Can you attach the latest schematic of lm339 circuit with capacitors. I would like to know how does capacitors reduce AC oscillations.
 

Offline alsetalokin4017

  • Super Contributor
  • ***
  • Posts: 2055
  • Country: us
Re: Circuit with op amp lm339
« Reply #44 on: December 31, 2015, 05:40:03 am »
@Seekonk:

Can't you add a bit more complexity so that all 4 comparators in the 339 are used for something?    ::)



@nForce:

Here you go.
The easiest person to fool is yourself. -- Richard Feynman
 

Offline nForceTopic starter

  • Frequent Contributor
  • **
  • Posts: 393
  • Country: ee
Re: Circuit with op amp lm339
« Reply #45 on: December 31, 2015, 11:55:47 am »
@alsetalokin4017

Why did you choose 1n4148 diode? Isn't this diode for high power electronics? 1 A of a current.

Can I replace that with some other diode for smaller current?
 

Offline Audioguru

  • Super Contributor
  • ***
  • Posts: 1507
  • Country: ca
Re: Circuit with op amp lm339
« Reply #46 on: December 31, 2015, 03:03:21 pm »
Why did you choose 1n4148 diode? Isn't this diode for high power electronics? 1 A of a current.

Can I replace that with some other diode for smaller current?
You should read the datasheet for a 1N4148 low current silicon diode:
1) Its maximum continuous DC current is 300mA.
2) Its max peak current for 1 second is 1A.
3) Its max peak surge current for 1 micro-second is 4A.
5) Its datasheet shows a graph of its typical forward voltage at currents as low as 1uA.
6) its reverse leakage current is very low. 
 

Offline nForceTopic starter

  • Frequent Contributor
  • **
  • Posts: 393
  • Country: ee
Re: Circuit with op amp lm339
« Reply #47 on: December 31, 2015, 05:54:52 pm »
Oh, sorry my local supplier has a wrong picture. It's a small signal diode.

@alsetalokin4017, Hero999

Which program are you using for modifying and adding components on the schematics? These modified schematics look original.
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19533
  • Country: gb
  • 0999
Re: Circuit with op amp lm339
« Reply #48 on: December 31, 2015, 07:41:38 pm »
I just use MS Paint and cut and paste the original symbols.
 

Offline Seekonk

  • Super Contributor
  • ***
  • Posts: 1938
  • Country: us
Re: Circuit with op amp lm339
« Reply #49 on: December 31, 2015, 09:18:20 pm »
I like that look, like it is copied out of an old manual.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf