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

0 Members and 1 Guest are viewing this topic.

Offline nForceTopic starter

  • Frequent Contributor
  • **
  • Posts: 393
  • Country: ee
Circuit with op amp lm339
« on: December 25, 2015, 10:31:14 pm »
Hello, i have build this simple  circuit on a breadboard to learn electronics.

But when I connect power supply, the led turns on.  I thought that the led will turn on only when I apply a magnetic field to the coil. How do I achieve that?

Because now the op amp works as a comparator, and when I apply the magnetic field it induces a current on both sides of a coil, but it should do  just on one of  the terminals to connect the gnd to power supply.  And then led should turn on. (Theoreticaly)

Can someone analyze the circuit and describe, what is actually happening here? Thank you.
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19651
  • Country: gb
  • 0999
Re: Circuit with op amp lm339
« Reply #1 on: December 25, 2015, 10:45:29 pm »
Yes, that's what you should expect to happen. The op-amp's bias current will flow out of both the inverting and non-inverting inputs. The voltage at the inverting input will be slightly higher than the non-inverting input because the resistance of the coil will mean it develops a voltage across it.

When a magnet is moved across the coil then LED may flicker off if the coil generates a negative voltage for long enough.
 

Offline Seekonk

  • Super Contributor
  • ***
  • Posts: 1940
  • Country: us
Re: Circuit with op amp lm339
« Reply #2 on: December 25, 2015, 10:58:56 pm »
You could bias the negative input slightly, a few milivolts, to insure the op amp does not turn on until a signal is present. That circuit is not guaranteed to work with every chip.
 

Offline Yansi

  • Super Contributor
  • ***
  • Posts: 3893
  • Country: 00
  • STM32, STM8, AVR, 8051
Re: Circuit with op amp lm339
« Reply #3 on: December 25, 2015, 11:27:11 pm »
LM339 is not opamp. It is a comparator. And beware od the pinout. :-+
 

Offline nForceTopic starter

  • Frequent Contributor
  • **
  • Posts: 393
  • Country: ee
Re: Circuit with op amp lm339
« Reply #4 on: December 26, 2015, 02:09:38 pm »
How do you know, that when I move a magnet across the coil, it generates a negative voltage?

How can I make with only these components the other way around? So that when I move a magnet across the coil it will light up the led.
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19651
  • Country: gb
  • 0999
Re: Circuit with op amp lm339
« Reply #5 on: December 26, 2015, 04:19:27 pm »
Moving a magnet across the coil will produce both a negative any a positive voltage, depending on the field and direction of movement.

Have you measured the voltage on the coil using an oscilloscope?
 

Offline alsetalokin4017

  • Super Contributor
  • ***
  • Posts: 2055
  • Country: us
Re: Circuit with op amp lm339
« Reply #6 on: December 26, 2015, 07:52:37 pm »
I can confirm that the circuit does work, using one of the opamps in a TL082. The LED is off, until I move a magnet rapidly past a coil taken from a small relay. Then the LED flashes briefly -- as it should, since the circuit isn't a "magnetic field detector" but rather a "change in magnetic field detector". See Faraday's Law of Induction. The voltage induced in a coil is proportional to the _time rate of change_ of the magnetic flux applied to the coil.

I don't know why nForce's LED is on all the time.


A ratiometric Hall effect sensor (Allegro A3503) makes a much better "magnetic field detector" than the relay coil does, though.

« Last Edit: December 26, 2015, 07:57:43 pm 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 #7 on: December 26, 2015, 08:17:20 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) is switching between a GND and 9 V. Because those two voltages (0V and 9V) are on the supply terminals of the op  amp. If there is 9 V on the output, there is no potential difference between the terminals and no current will run. If there is GND, there is a potential difference and the current will run, lightning up the LED. But there is something odd, why doesn't the LED burn out, because there is 9V? Maybe that 1K ohm resistors helps.

Well this is how I understand working of this circuit. Can someone with a lot of practice confirm it?

@Hero999 Sorry i don't have an oscilloscope, because i don't have the money for buying one. I have bought these electric components for $10.
 

Offline Seekonk

  • Super Contributor
  • ***
  • Posts: 1940
  • Country: us
Re: Circuit with op amp lm339
« Reply #8 on: December 26, 2015, 10:43:13 pm »
It is a hobby circuit designed to teach you not to trust what you see on the internet.  The 339 has up to 3mv of offset on the input.  Shorting the inputs to common the output is undefined.  You should always have  several mv  designed into the circuit to define the output to a certain state.  The input is not protected.  Spec says not to let input drop below -.3V.  Get near a good magnetic field and the chip may self destruct.  Good luck.
 

Offline alsetalokin4017

  • Super Contributor
  • ***
  • Posts: 2055
  • Country: us
Re: Circuit with op amp lm339
« Reply #9 on: December 26, 2015, 11:19:50 pm »
The inputs are not exactly shorted to ground... well, one is, but the other one is on the other end of the relay coil. The relay coil I used for testing my version has about 50 ohms DC resistance.
« Last Edit: December 27, 2015, 12:01:10 am by alsetalokin4017 »
The easiest person to fool is yourself. -- Richard Feynman
 

Offline alsetalokin4017

  • Super Contributor
  • ***
  • Posts: 2055
  • Country: us
Re: Circuit with op amp lm339
« Reply #10 on: December 27, 2015, 12:22:01 am »
May I suggest this slightly modified circuit?

I don't know if it will work with the lm339 but it's a lot of fun with the TL082. It will detect the motion of a magnet, moving quite slowly, from several inches away.

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

Offline alsetalokin4017

  • Super Contributor
  • ***
  • Posts: 2055
  • Country: us
Re: Circuit with op amp lm339
« Reply #11 on: December 27, 2015, 01:02:20 am »
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) is switching between a GND and 9 V. Because those two voltages (0V and 9V) are on the supply terminals of the op  amp. If there is 9 V on the output, there is no potential difference between the terminals and no current will run. If there is GND, there is a potential difference and the current will run, lightning up the LED. But there is something odd, why doesn't the LED burn out, because there is 9V? Maybe that 1K ohm resistors helps.

Well this is how I understand working of this circuit. Can someone with a lot of practice confirm it?

@Hero999 Sorry i don't have an oscilloscope, because i don't have the money for buying one. I have bought these electric components for $10.

Yes, the op-amp is being used as a comparator in this circuit. The output changes state from HI to LO depending on which of the inputs has the higher voltage.

What you have said here is correct. Say the LED's forward voltage drop is 2.2 V. So to calculate the current through the LED and the 1000 ohm resistor with a 9V supply, you use Ohm's Law. V=IR, so I=V/R.

 (9-2.2) = 6.8 V  , and 6.8 V / 1000 Ohms = 6.8 mA, which is fine for a modern, bright LED.


Homework question: Say you want 20 mA through the LED. What should the value of the resistor be in that case?

« Last Edit: December 27, 2015, 01:06:52 am by alsetalokin4017 »
The easiest person to fool is yourself. -- Richard Feynman
 

Offline alsetalokin4017

  • Super Contributor
  • ***
  • Posts: 2055
  • Country: us
Re: Circuit with op amp lm339
« Reply #12 on: December 27, 2015, 01:36:10 am »
Oscilloscope trace (single-shot) obtained by sweeping one pole of a NdBFe magnet rapidly past the end of the 50 ohm miniature relay coil. If I use the other pole of the magnet, the trace is reversed (first peak positive, second peak negative.)  If I go faster the voltages are greater. Faraday's Law of Induction in action!
The easiest person to fool is yourself. -- Richard Feynman
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19651
  • Country: gb
  • 0999
Re: Circuit with op amp lm339
« Reply #13 on: December 27, 2015, 11:13:13 am »
That's strange, there are two different explanations of how the circuit works. And it's a simple circuit.
No, only one explanation for how the circuit works has been given. I only provided a possible reason for the circuit not working.

It is a hobby circuit designed to teach you not to trust what you see on the internet.  The 339 has up to 3mv of offset on the input.  Shorting the inputs to common the output is undefined.  You should always have  several mv  designed into the circuit to define the output to a certain state.  The input is not protected.  Spec says not to let input drop below -.3V.  Get near a good magnetic field and the chip may self destruct.  Good luck.
Yes, unless the resistance of the coil is very high, the input offset voltage will dominate the bias current.

The circuit should work with the LM339, with a couple of modifications. Connect a 470k resistor between the non-inverting input to raise the input voltage a few mV above 0V. The bias current will develop a voltage across the resistor which should be greater than the offset voltage, thus ensuring the non-inverting input high enough above the inverting input to cause the output to go high and the LED turn off. Adding diode in reverse parallel with the coil will provide some protection against negative voltages.
 

Offline alsetalokin4017

  • Super Contributor
  • ***
  • Posts: 2055
  • Country: us
Re: Circuit with op amp lm339
« Reply #14 on: December 27, 2015, 04:26:16 pm »
Two points: The circuit above is still not a "magnetic field detector", it is a _change_ in magnetic field detector. If the applied field isn't changing, there is no voltage induced in the coil and the circuit just sits there doing nothing.
 
And the circuit (on my breadboard using 1/2 TL082 and a 50 ohm miniature relay coil) still isn't very sensitive. It still requires very fast magnet motion very near to the coil for the LED to flash briefly.

Try this variant. It has much improved sensitivity, will detect fast magnet motion from several inches away and slow magnet motion from an inch or so by turning the LED on for as long as it detects the magnet is moving.

I don't  know if it will work the same way with the LM339 (using the correct pin numbers for that op-amp of course), I don't have one on hand to test. It doesn't work very well with the LM358n, it probably needs the high-impedance inputs provided by the TL082.
« Last Edit: December 27, 2015, 05:35:16 pm by alsetalokin4017 »
The easiest person to fool is yourself. -- Richard Feynman
 

Offline Seekonk

  • Super Contributor
  • ***
  • Posts: 1940
  • Country: us
Re: Circuit with op amp lm339
« Reply #15 on: December 27, 2015, 04:58:17 pm »
YIPES!
 

Offline alsetalokin4017

  • Super Contributor
  • ***
  • Posts: 2055
  • Country: us
Re: Circuit with op amp lm339
« Reply #16 on: December 27, 2015, 05:36:51 pm »
YIPES!

Change the feedback resistor R2 to 47k for even greater sensitivity. 

(I've made this change on the circuit diagram and reposted it above.)

A 0.1 uF cap in parallel with the feedback resistor may be needed if the circuit oscillates.
« Last Edit: December 27, 2015, 05:44:11 pm by alsetalokin4017 »
The easiest person to fool is yourself. -- Richard Feynman
 

Offline Seekonk

  • Super Contributor
  • ***
  • Posts: 1940
  • Country: us
Re: Circuit with op amp lm339
« Reply #17 on: December 27, 2015, 05:50:11 pm »
Capacitors.  Let's add some capacitors.

I don't need to build one of these.  I have a GHOST METER that I picked up.  Photo is unretouched, you can find these on ebay.  It flashes and beeps.  This won't do anything around my equipment or TV but there is a place in the middle of the living room that it goes crazy, oooooooooh scary.  GHOST METER, Don't stay home without it!
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19651
  • Country: gb
  • 0999
Re: Circuit with op amp lm339
« Reply #18 on: December 27, 2015, 05:54:16 pm »
Capacitors.  Let's add some capacitors.

I don't need to build one of these.  I have a GHOST METER that I picked up.  Photo is unretouched, you can find these on ebay.  It flashes and beeps.  This won't do anything around my equipment or TV but there is a place in the middle of the living room that it goes crazy, oooooooooh scary.  GHOST METER, Don't stay home without it!
Lol, how about doing a teardown?
 

Offline alsetalokin4017

  • Super Contributor
  • ***
  • Posts: 2055
  • Country: us
Re: Circuit with op amp lm339
« Reply #19 on: December 27, 2015, 05:59:47 pm »
The scale should read "milliGHOSTS"  instead of milliGauss.....      :-DD
The easiest person to fool is yourself. -- Richard Feynman
 

Offline alsetalokin4017

  • Super Contributor
  • ***
  • Posts: 2055
  • Country: us
Re: Circuit with op amp lm339
« Reply #20 on: December 27, 2015, 06:41:59 pm »
Capacitors.  Let's add some capacitors.

(snip)


OK.... how about this then.  Eliminate the feedback resistor altogether and replace it with a 200 nF monolithic ceramic cap (I used 2 ea. 100nF in parallel).   Now the circuit has _crazy_ sensitivity. It will detect the motion of a weak magnet moving slowly, several inches away, and a strong magnet at six inches or more.
The easiest person to fool is yourself. -- Richard Feynman
 

Offline alsetalokin4017

  • Super Contributor
  • ***
  • Posts: 2055
  • Country: us
Re: Circuit with op amp lm339
« Reply #21 on: December 27, 2015, 09:43:43 pm »




Some one asked a few days ago about simple circuits for scoping. This is one such. The circuit has a tendency to self-oscillate, which makes the LED look like it's "ON" continuously, but really it is turning on and off very rapidly. (This is why the OP's LED appeared to be continuously ON, probably: the op-amp was probably oscillating and making the LED look like it was continually lit. Maybe.) This effect can be seen with the scope, which can tell you whether the LED is in fact solidly ON, or is oscillating rapidly, and so helps you to find the right place to install capacitors to kill the oscillations.
« Last Edit: December 27, 2015, 09:50:17 pm by alsetalokin4017 »
The easiest person to fool is yourself. -- Richard Feynman
 

Offline edavid

  • Super Contributor
  • ***
  • Posts: 3388
  • Country: us
Re: Circuit with op amp lm339
« Reply #22 on: December 27, 2015, 09:54:37 pm »
Yes, the op-amp is being used as a comparator in this circuit.

If it's an LM339, it's actually a comparator being used as a comparator :)
 

Offline Seekonk

  • Super Contributor
  • ***
  • Posts: 1940
  • Country: us
Re: Circuit with op amp lm339
« Reply #23 on: December 27, 2015, 10:55:09 pm »
When I was a kid I made the amplifier section of a radio cluck like a chicken.  I probably
couldn't do that now if I tried.  So there is something to be said about experimenting and
connecting parts up randomly.

The following circuit provides about 3 mv (matching that of the maximum offset of the 339)
of bias assuming a 50 ohm coil. This should guarantee a solid off or on state of the LED.
Input connections depend it you want it off or on. This should prevent oscillations.  An
added advantage is that it offsets the inputs at half the supply voltage.  That should
provide sufficient protection for input spikes.

Biasing the input will make it stable.  However, you never know which way the offest of
the op amp input is.  That could require up to 6 mv of signal before the comparator trips.
Placing the coil in a resistor H configuration with a 10K pot in the upper or lower feed
ia an option.  Then it could be adjusted to the edge of tripping with just 1 mv of offset.
 

Offline nForceTopic starter

  • Frequent Contributor
  • **
  • Posts: 393
  • Country: ee
Re: Circuit with op amp lm339
« Reply #24 on: December 28, 2015, 11:37:39 am »
That's strange, there are two different explanations of how the circuit works. And it's a simple circuit.
No, only one explanation for how the circuit works has been given. I only provided a possible reason for the circuit not working.

It is a hobby circuit designed to teach you not to trust what you see on the internet.  The 339 has up to 3mv of offset on the input.  Shorting the inputs to common the output is undefined.  You should always have  several mv  designed into the circuit to define the output to a certain state.  The input is not protected.  Spec says not to let input drop below -.3V.  Get near a good magnetic field and the chip may self destruct.  Good luck.
Yes, unless the resistance of the coil is very high, the input offset voltage will dominate the bias current.

The circuit should work with the LM339, with a couple of modifications. Connect a 470k resistor between the non-inverting input to raise the input voltage a few mV above 0V. The bias current will develop a voltage across the resistor which should be greater than the offset voltage, thus ensuring the non-inverting input high enough above the inverting input to cause the output to go high and the LED turn off. Adding diode in reverse parallel with the coil will provide some protection against negative voltages.


How did you calculate the resistor value? So it has to be 470k?
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf