One push
The final button action I will look at turns a device on for a set time. This requires a monostable circuit, a term electronics fans might recognize from the good ol' 555. In fact, a 555 can be used for this function. However, I am going to use a somewhat newer chip, a CMOS CD4538. Let's see what is inside the chip:
This block diagram is taken from the datasheet. The box represents most of the circuit, pretty much the same thing that is in a 555. Namely, threshold detectors and switches to take the capacitor Cx through a discharge/recharge cycle. The whole thing is arraigned so a low at A (which I would have labeled trigger) will initiate the cycle. CD is a clear that will interrupt the cycle if desired, bringing Q low immediately. The timing pins 1 and 2 are brought out of the package where you supply your own R and C. The time formula is simpler than the 555, just RC-- one farad times one ohm gives a one second cycle. (But remember, capacitors come in microfarads, so we usually need a lot of ohms to get noticeable times.) R must be at least 5k, so the practical range ot times is 5 milliseconds to all day.
The structure attached to the A (or trigger) point is interesting. That shield shape represents a logical OR gate. The essence of OR is that if any input is high, the output goes high. There's a whole course in ee that covers logic gates and theory. Four simple gates (OR, AND, NOT and XOR) are the basis of all of the data manipulation we do on our computers. In this case, the OR gate gives the 4538 two inputs. Note the little circle on pin 5. That indicates a logical inversion. So a low on pin 5 is equivalent to the second OR input going high. As a result the two inputs work differently-- pin 4 will trigger the circuit if it is brought high (and 5 is high) and pin 5 will trigger the output when it is brought low (and pin 4 is low.) This gives us a choice in how we hook up buttons.
The previous two circuits were triggered by bringing the input high, but the opposite action is more common in the electronics world. Most buttons and such activate when brought low.This simplifies wiring in most cases- a positive activation requires running +V lines to every button, whereas ground is often readily available. Think of a car, where the chassis is ground, and your window activators, door latches and whatnot only have to connect a sense wire to the frame to work. I'm going toi use the active low trigger on this circuit, to show how it is done.
Here's the circuit:
Parts of this are really looking familiar, aren't they? That's the nice thing about electronics-- most problems only need to be solved once. The circuit connected to Q is right out of our playbook, as is the circuit attached to Clear (pin 3)- that prevents the circuit from firing when the power is turned on. Pin 2 handles timing with a capacitor to ground and a resistor to +V. To use negative activation, pin 4 is grounded, and pin 5 goes to a button. Normally pin 5 is held high by a 10k resistor, but the button shorts this to ground and fires the circuit.
You could plug a 555 into this circuit and get much the same action, but there is one big difference: If you hold the button on a 555 circuit down longer than the on time, the 555 will cycle again. If you press the button a second time during the cycle, nothing at all will happen. The 4538 is triggered by the transition from high to low (or vice versa). You can hold the button as long as you like with no effect, and if you hit it twice, the time will be extended from the second hit.
In the other circuits I mentioned the debounce problem, but you will notice I didn't do anything special about that here. That's because an edge triggered monostable is inherently debounced. In fact, the best way to debounce any other circuit is to use one of these first.
Here's a board:
As usual, the red wires are +V and the black ones are ground. The supply wires run off the top, and the +V and ground buss are bridged with a 100nf capacitor. Looking at the chip first, here is a pin by pin connection list.
- (Upper left, by the notch) T1, connected to ground.
- T2. 47 µf cap connected to ground (note stripe marking negative polarity), and 100k resistor connected to +V. Change these to produce the on duration you desire. T = RC
- Clear. 100k resistor to +V and 100nf cap to ground at pin 4. (It looks smaller than other 100 nF caps I've used- it is. I found a few 25v caps at the bottom of my supply drawer. Most of mine are 1000v cheapies I got in a grab bag.)
- Trigger A. Connected to ground.
- Trigger B. Connected by the white wire to the button and a 10k pull up resistor.
- Q. Connected to the base of the transistor by a 100k resistor.
- Not Q. Unconnected at this time.
- Ground. (There are 16 pins on this IC.)
9-15 are not connected, although it is a good idea to prevent accidental firing of the unused side by tying 15 and 12 to ground and 11 and 13 to +V.
Pin 16 is the power supply. I've forgotten this one on the last three builds. (Head slap)
Note that the transistor is turned from the position it has been in the other boards. The pins are (top to bottom)
- Emitter to ground.
- Base to pin 6 via 100k resistor.
- Collector to 1k resistor (brn black red). The other end of the resistor is connected to the LED (lead marked by flat) which is also connected to +V.
The button will connect to the header. One pin is grounded, the other is connected to the white wire and a 10k resistor to +V. You can connect as many buttons as you like between the pins.
Not much was done on the back except isolating the IC leads:
I am getting better at cutting tracks. I use a file to separate the ends-- this lets me test the board in a metal board holder. The other traces are cut with a lightweight grinder using a Dremel engraving bit.
And-- cue video:
What would you like to operate with buttons?
pqe