# Nand logic gate problem

#### Copey84

Joined Jul 27, 2015
198
Ignore last post, realised switch wouldn't be able to link pin one to ground.
Will have a rethink.

#### Copey84

Joined Jul 27, 2015
198
Hi all, can't come up with another way to sink current from pin 1 to ground when circuit is open, will have to use transistor and logic gates as before. Going to use power supply so 1ma feeding transistor not really an issue.
Have decided to use a 4.7micro farad electrolytic cap, the rest will be ceramic, think these are ok.
Could someone briefly describe how the IC logic works with pin 1 an 2 going high 3 goes low, but how then does 2 remain high as it is feed from 3?
As mentioned in other post I'm not going to include led, however a diode has been shown in other circuit posted by eetech00 showing a diode in circuit, what is the purpose of diode in this circuit? Should I include one ?

#### Alec_t

Joined Sep 17, 2013
11,755
Adopting WBahn's suggestion (post #12), here's a suggested circuit:

R1,D1 allow a rapid discharge of the cap when both fridge doors are closed. U1b,c,d are paralleled to enable a greater base current for Q1 if required (depending on the buzzer current draw). D3 catches any voltage spike if the buzzer has any inductive kick. Not shown is a 100nF decoupling cap which should connect between pins 7 and 14 close to the IC. I have assumed a 9V PP3 battery is the supply.

#### Copey84

Joined Jul 27, 2015
198
Thanks Alec_t, much appreciated. That's a better circuit, understand now that the diodes in circuit are for suppression incase there is any spikes caused by buzzer. Think the buzzer draws 30ma, will I still need to parallel the outputs of nand gates? What sort of current can you draw from single gate?
Have ordered a 230v AC to 5v DC 700ma power supply, i know its a bit high on current output, only one i could get though. Circuit will run of 5v, don't think it will change any of the component values you have included, or am I wrong?

#### marcf

Joined Dec 29, 2014
260
As an old fire alarm tech, I am bothered by monitoring circuits that rely on normally open switches and parallel circuit monitoring. Probably would be better to use NC switches in series. Then you would also know if the monitoring circuit itself was good or bad. As it stands, you will never detect a open wire or a bad switch, or loss of power.

We had a running joke with the telephone people that they never did series and we never did parallel.

#### AnalogKid

Joined Aug 1, 2013
8,708
Referring to the schematic in post #18, everything will work better if you change from a 4011 to a 4093 NAND gate with hysteresis. Very long R-C timers do not work well with standard logic gates.

1. For a 30 second startup delay, increase the capacitor at pin 1 to 47 uF, put a 4.7 megohm resistor across it to GND, and put a 1 megohm resistor from pin 1 to the switches. This will be close to 30 seconds ON delay, but also an OFF delay of at least 1 minute. For delayed-on / instant-off operation, you need either to change to normally closed switches that open when the doors open, or a slightly different circuit.

2. The two gates form a 1 Hz oscillator. The 4.7 uf cap is the oscillator timing capacitor. The idea here is that the beeper and LED sound/flash at a 1 Hz rate. Better values would be a 470K resistor and 1.0 uF capacitor.

ak

#### Alec_t

Joined Sep 17, 2013
11,755
Think the buzzer draws 30ma, will I still need to parallel the outputs of nand gates? What sort of current can you draw from single gate?
A CMOS gate has an output impedance of a few hundred Ohms, so if it sources more than a few mA the output voltage drops significantly. Whether that drop is important would depend on the application. Here, it doesn't matter much. With Q1 used as a saturated switch having a rule-of-thumb current gain of 10, the designed base current would be 3mA for a 30mA collector current, so the gate output would drop only ~1V. Paralleled gates unnecessary in this case for a 30mA collector current. But unused gates must not have their inputs floating, so it's just as easy to parallel the gates as not.

#### WBahn

Joined Mar 31, 2012
26,326
Thanks Alec_t, much appreciated. That's a better circuit, understand now that the diodes in circuit are for suppression incase there is any spikes caused by buzzer. Think the buzzer draws 30ma, will I still need to parallel the outputs of nand gates? What sort of current can you draw from single gate?
Have ordered a 230v AC to 5v DC 700ma power supply, i know its a bit high on current output, only one i could get though. Circuit will run of 5v, don't think it will change any of the component values you have included, or am I wrong?
The CD4011 can source/sink roughly 1 mA per gate. There are logic families that can sink considerably more current. For instance, the 74AC/ACT families can source/sink about 24 mA per gate. It will consume more current while powered, but since it will only be powered when the door is open, who cares? I would recommend the 74AC132 as it has Schmitt trigger inputs -- those will work much better in an oscillator (particularly a low speed oscillator) than normal inputs because of the hysteresis they have (should you decide you really want a pulsing buzzer).

Right now in Alec_t's circuit (which doesn't have an oscillator in it) you have one gate driving the other three in parallel to produce an active-HI signal to drive the transistor. But if you put all four in parallel and get rid of the transistor you can drive the buzzer directly.

#### dannyf

Joined Sep 13, 2015
2,197
The whole thing can be done with two gates: one to generate a periodic on-off and another to detect switch positions. How to wire them will depend on your logic and switches used - without knowing what you have and what you want to do, it is hard to tell.

Typically switches are active low -> there is a resistor from the switch to the rail.

#### Copey84

Joined Jul 27, 2015
198
Ak, how would you create a closed circuit that would delay for 30sec then instant off, and still keep the oscillator signal out to buzzer?

#### Copey84

Joined Jul 27, 2015
198
Just seen latest replys, thanks. Would prefer the oscillation in circuit and totally closed just not sure how to wire, also wanted 30sec delay on opening door, assume it would be an instant reset once door is shut,might have different IC if needed, not hard to get anyway.

#### dannyf

Joined Sep 13, 2015
2,197
I would try something like this.

U1/R1/C1 is the oscillator - pick your RC constant accordingly.

R2/C2/D1 form the delay / reset circuitry. Pick R2/C2 for your desired delay.

U2 detects the switches' positions - those switches are NO.

With the switches open, U2 outputs a logic low, which through D1 keeps the capacitor discharged -> no output on the oscillator.

if one of the switches is closed, U2 outputs a logic high, which allows the capacitor to be charged up. Once the capacitor is sufficiently charged up, the oscillator kicks in.

you can put your buzzer driver on U1's output.

#### Attachments

• 22.7 KB Views: 10

#### dannyf

Joined Sep 13, 2015
2,197
The choice of the chips is not important -> you just need to re-value the rc parameters accordingly.

#### dannyf

Joined Sep 13, 2015
2,197
The circuit is designed to work with NO switches. It can be made to work with NC switches too, either active high or active low.

#### Copey84

Joined Jul 27, 2015
198
Danny thanks for reply, how does c2 stay discharged whenever it's connected to R2, won't it charge up through R2?

#### AnalogKid

Joined Aug 1, 2013
8,708
Here is the first schematic, with normally closed pushbutton switches that are open when the fridge doors are closed, and close when the fridge doors open. This is like the logic in your schematics. As mentioned above, I changed to a 4093 because it handles very slow R-C voltage ramps much better than a 4011. If you are stuck with the 4011, there is a way around the problem. Diode D3 keeps the delay capacitor mostly discharged in the closed state, and lets it charge up in the open state. When both doors are closed it rapidly discharges the cap through the gate's output resistance. Other than that, it is pretty much like your circuit with decoupling and the buzzer diode added.

And before everyone get excited, YES, I know the oscillator can be done with only one hysteretic gate. I drew it this way because it mimics the TS's original design.

ak

#### Attachments

• 14 KB Views: 3
Last edited:

#### Tonyr1084

Joined Sep 24, 2015
5,268
Quick question: If the alarm is meant to sound when both doors are open, what happens if just one door is slightly open while the other is closed?

And this: If you have a buzzer (I have one on my freezer single door), why not use a micro switch with a Common, a Normally Open and a Normally closed set of contacts? Wire them in series (for two doors) and directly power your buzzer. No need for transistors or resistors or oscillators. I'll bang out a diagram and post it shortly.

#### AnalogKid

Joined Aug 1, 2013
8,708
Here is the second schematic, based on normally open switches that are closed when the fridge doors are closed, and open when a door is opened. This reverses the input logic in away that makes things much more simple.

ak

#### Attachments

• 13.5 KB Views: 0

#### Tonyr1084

Joined Sep 24, 2015
5,268
OK, boring as this may be:

#### Tonyr1084

Joined Sep 24, 2015
5,268
I like AK's circuit because it has the time delay (RC Trigger [R2/C2]). AND it will sound the buzzer with only one door open. Great solutions. However, I still don't see the need for an oscillator circuit. IF the buzzer makes a sound when powered then all you need to concern yourself with is powering the buzzer. Maybe use U1a and U1b as a buffer and fire off the transistor.

If you want the time delay then that can be done with a transistor or a FET. Only, using a transistor or FET will mean the buzzer will see a low voltage or current rising as the time circuit counts down. Eventually the buzzer will sound. But still, I don't understand why everyone wants to build an oscillator. Well, maybe I'm missing something.