Will this circuit work? AND Gate behaving strange

digital-logicldroperational-amplifier

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

Best Answer

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)