0
\$\begingroup\$

I've just built a circuit using Yenka, and it's meant to be a system that basically senses light, and whether a switch is on or not, and when both of these are true, the buzzer will, buzz.

I'm quite bad at electronics in general, but I'm trying to get the following to work (ref. Circuit diagram)

Circuit Diagram

What it's trying to do is basically (in code-like-terms):

IF(LDR SENSES LIGHT && SPST SWITCH TOGGLED) { BUZZER ON }
ELSE { BUZZER OFF }

From my low-level understanding of electronics, I think there might be a need for a transistor just before the buzzer to push up the voltage, and possibly more resistance on the AND gate, because this diagram made in Yenka keeps 'blowing up'.

Basically what I think it's going to do: LDR senses light, compares this output resisted voltage against baseline voltage with op-amp, resists the output value if true, send to AND gate. AND gate checks whether op-amp is true, and whether switch is true, if they are both true, activate buzzer.

Will this circuit work? And if not, what's wrong with it? :S

\$\endgroup\$
6
  • 1
    \$\begingroup\$ What are the red rectangles in the schematic? \$\endgroup\$
    – clabacchio
    Commented Feb 3, 2012 at 10:27
  • \$\begingroup\$ They're resistors :) \$\endgroup\$
    – Brian
    Commented Feb 3, 2012 at 10:30
  • \$\begingroup\$ The RED ones ?_? \$\endgroup\$
    – clabacchio
    Commented Feb 3, 2012 at 10:33
  • \$\begingroup\$ Ah, they're supposedly indicating the level of voltage at that point, Yenka does strange things. :S \$\endgroup\$
    – Brian
    Commented Feb 3, 2012 at 10:35
  • 2
    \$\begingroup\$ Yucc. Surely you can find better software for drawing schematics that doesn't leave those red turds and gratuitous stub lines dropped about, and the understands about component designators. Or, at least learn to shut all that crap off and export a presentable schematic when you want to show it to others. I still don't know what that compass rose looking thing by the top left resistor is trying to tell me, and the rectangular thing below the switch. What a mess! \$\endgroup\$ Commented Feb 3, 2012 at 20:15

2 Answers 2

2
\$\begingroup\$

First basic error: you are driving the OPAMP inputs with single resistors connected to the supply lines: this simply ties the inputs to the same voltages, as there is virtually no current flowing in them.

So, first thing to do is understand what is a voltage divider.

Then, you have to use the principle of the voltage divider to create voltages to the inputs of the OPAMP. Of these voltages, one will be fixed, and will be used as a reference, while the other will be variable in function of the value of the photoresistor.

The photoresistor

Let's talk about the photoresistor: this is a resistor that decrease its value when exposed to light; let's consider it in a binary way (for your purpose): low when there is light, high when it's dark. Now you have to specify what do you want as 'light', and what do you want as 'dark'. Then measure the value of the resistor in the two cases. If you are simulating, I don't know how to create these situation, try to take a look or use a variable resistance to simulate the effect.

Depending on the values chosen for the photoresistor, you will have to size the other 3 resistors such as they will generate a positive differential voltage in one case, and a negative in the other.

The AND gate

There is a "small" problem also with the AND inputs: the switch input, when this is open, will be floating and with an unpredictable value; so you should put a (quite big - 10K should work, for sure in the simulation) resistor, between that input of the AND gate and ground. This will pull down the voltage when the switch is open; but you really need the 680 Ohm? For sure not in the simulation, you can think about it in a real implementation.

(Sorry but I'm busy, I'm adding the answer a piece at a time...but try to understand those parts)

\$\endgroup\$
3
  • \$\begingroup\$ Hi, thanks for your answer :D Voltage dividers are a pair of resistors before and after a connection are made, correct? Should I be using this for the negative + input on the op amp? Thank you, very much! :) \$\endgroup\$
    – Brian
    Commented Feb 3, 2012 at 10:34
  • \$\begingroup\$ 10k is hardly "quite big" - 100k would be standard here when using modern ICs, and you might be able to get away with more if this was a power-sensitive app. \$\endgroup\$ Commented Feb 5, 2012 at 5:38
  • \$\begingroup\$ @KevinVermeer yep, maybe I lack the concept of "quite", but it was to avoid him using 680Ohm resistors like the others :) \$\endgroup\$
    – clabacchio
    Commented Feb 5, 2012 at 9:41
2
\$\begingroup\$

First of all, you cannot ever leave gate inputs floating (not connected to anything). This may be OK in a simulation, but it may cause all sorts of problems if you try to build this circuit in real life. When the switch is open, in your circuit diagram, the input of the gate is not connected to anything.

Also, the inputs of an opamp are very high impedance, so connecting them using a resistor in series is pointless and is basically the same as connecting them directly to the power supply.

What you should do instead is use two voltage dividers - one with fixed resistors* and one made out of a fixed resistor and the LDR. Like this:

modified original circuit diagram

Now, when the resistance of the LDR gets lower than 5k Ohm, the voltage on the "+" input of the opamp becomes higher than the voltage on the "-" input and the output goes high, turning on the buzzer. In real life you would want to replace the fixed 5k Ohm resistor with a potentiometer, so you could set the light level at which the buzzer turns on. Also, as you see, I connected a 1kOhm resistor from the switch to ground, so that when the switch is open, the input of the gate is grounded. You also may need to use a transistor to drive the buzzer, depending on how much current it uses (in reality).

However, your circuit can be made simpler if the switch just turned off the power supply, like this:

simplified circuit diagram

Again, in real life you may need to use a transistor if the buzzer uses too much current. Now the switch turns off the entire circuit so the buzzer will not sound. For some weird reason though, Yenka simulates this as if the buzzer sounded briefly while the switched was turning off, but in reality it would not happen :)

If, for some reason you want the opamp to remain powered at all times, you can use the switch to disable the buzzer like this:

modified circuit diagram

I also added a transistor here, since it is needed :) Because the opamp outputs 2V while it is "off", I added a voltage divider so the transistor does not turn on when it should not. If you were connecting this to the ouput of the AND gate, only the 10k resistor would be required.

\$\endgroup\$
3
  • \$\begingroup\$ Excellent answer! Looks like you even braved the Yenka software :) My only comment is that any implementor needs to be careful with how you power the transistor. If it's connected to the un-switched supply, you could end up driving the unpowered output of your op-amp high while the supply was low. This would damage the op-amp. \$\endgroup\$ Commented Feb 5, 2012 at 5:42
  • \$\begingroup\$ @KevinVermeer, a long time ago I used Crocodile Clips (didn't know any better) and it seems that Yenka is the new name for it. If the transistor is powered from some other supply, then you can just disconnect the LDR. I didn't think of it when I was writing my answer. \$\endgroup\$
    – Pentium100
    Commented Feb 5, 2012 at 6:54
  • \$\begingroup\$ Make sure you aren't exceeding the input range of the opamp when you are using it as a comparator or just use a comparator. Also make sure if you use an opamp that it can drive its output to 0V, i.e., rail to rail and your input reference is within the common-mode range of the opamp. Again, better to use a comparator which is designed for this type of thing. \$\endgroup\$ Commented Oct 3, 2012 at 16:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.