Close

Button ON OFF Switch

Used ComponentsUsed Components wrote 03/24/2020 at 07:49 • 5 min read • Like

This article shows you how to make an ON OFF switch with a button.

You can see from the photo above that I implemented this circuit with an old TTL (Transistor Transistor Logic) JK flip-flop IC (7476). However, you can use D flip-flop and CMOS is always better than TTL that has been obsolete for many decades now.

The micro chip is inserted into a wire wrap socket. I hardly used a soldering iron and you might be able to avoid it if you want to build this circuit. You might need to user a bigger matrix board.

The IC (Integrated Circuit) has two JK flip-flops inside. You can search for specifications online and find that all inputs need to connected to logic "1" (5 V power supply) and each of the clock inputs to two two buttons.

You can see my circuit working in the video:



Step 1: Design and Build Input Circuit

The video does not show that at times the LED is not turning ON or not turning OFF even after the button is pressed. This is because I do not have a USB oscilloscope and cannot see the input entering the JK flip-flop clock input when the button is pressed.

You can see the clock input circuit that I used:

Removing the RC filter that consists of two resistors and one capacitor will allow a spiky signals to enter the flip-flop clock input. Some people who are not experts in digital or electronic design might think that when a button is pressed ON and OFF a perfect step function signal (rectangular/square shaped waveform) is entering the flip-flop (switching from 0 V to power supply voltage ) or any other input device. This is never the case unless you have a very expensive and perfect button. There are small spikes in the waveform due to mechanical imperfection of the button metallic contacts. This is why I designed an RC low pass filter.

The frequency of the RC filter equals to:

fLP = 1/(2*pi*Ci*R)

Where: R = 1/(1/Ri + 1/Rbutton + 1/Rflip-flop)

Calculating this value could be a very complicated problem because you might not be able to easily calculate the flip-flop resistance. However, you can measure it as flip-flop clock inpu voltage divided by input current. Also, you can assume that both Ri and Rflip-flop are a lot higher than Rbutton 100 ohm resistance thus can be ignored. 

Higher capacitor value will filter more button spikes. However, they might also filter the input signal, increasing the step function rise time and the flip-flop would not turn on. I chosen 220 pF capacitor via trial and error. This capacitor resulted in best circuit performance.

When Ci capacitor voltage is zero the current coming from 5 V power source is Vs / Rbutton = 5 V / 100 ohms = 50 mA. Thus reducing Rbutton to zero (short circuit) will cause Ci capacitor failure. I suggest that you use a 100 ohms resistor because the flip-flop might need a high input current. Assuming that after the capacitor is fully charged the current entering Ri and Rflip-flop is 2 mA, the voltage drop across the Rbutton will be as high as 2 V if Rbutton is 1000 ohms. Than means the voltage entering is flip-flop is only 3 V. The flip-flop might need at least 3.5 V to accept the input as a logic "1". This is why Rbutton resistor needs to be small in resistance value.

Next step is choosing Ri resistor. When the button is disconnect the flip-flop is supplying small current to the Ri resistor. Thus there is issue with flip-flop maximum input current to accept the input voltage as a "0" when the button is OFF. Assuming the maximum flip-flop input current no more than 300 uA = 0.3 mA. That means the maximum input voltage when the button is disconnected will equal to 0.3 V. If this flip-flop accepts a logic "0" for voltages below 0.7 V (greater than 0.3 V) means that the circuit will work.


Step 2: Power Supply

The power supply can be implemented with a 5 V voltage regulator. It could be a better option than using a zener diode, yet might cost more money if you have to order this IC. You can implement a 5 V zener diode with 7 general purpose diodes connected in series (0.7 V * 7 = 4.9 V = approximately 5 V).

You will need high power Rs resistor and a high power zener diode or two zener diodes in connected in parallel. I used two 18 ohm resistors to reduce power consumption for each resistor and to create an approximate 10 ohm resistance value that I did not have. I should have used a high power resistors. The zener diode protects the IC from voltages above 5 V that will burn this microchip. You can try using a 4.7 V zener. It might work because usually the maximum zener diode voltage usually exceeds the zener diode voltage ratings by a few hundred mV when current is applied. This is why you should not use a 5.3 V zener because the diode and thus the IC power supply voltage might reach 5.9 V and cause flip-flop failure.

A voltage regulator IC might need a heat sink. Do not forget the maximum check the maximum input voltage and maximum input-output voltage difference for this voltage regulator IC. You might also try ordering a few regulator IC so that you do not have to wait for many months for the next package if you accidentally burn the regulator but shorting the regulator outputs.

Cs is decoupling capacitor. It is used to filter small voltage spikes in the power supply line caused by changes in flip-flop outputs (from logic "0" to logic "1" or from logic "1" to logic "0"). I tried bigger capacitors. However, those capacitors allowed the high frequency spikes through and the circuit was not working. High value capacitors have stray inductance that causes to increase in impedance at high frequencies. You might need to try a few different capacitors. You can still connect a bigger capacitor across the flip-flop power supply terminals to filter low frequency spikes. However, keep in mind that when the capacitor voltage is zero, the the current from power supply could be as high as: 5/10 = 0.5 amps. Higher Farad value capacitors take a longer time to charge. This can also damage the power source. I suggest you do not try capacitor values above 100 uF and do not connect to USB power supply.

The frequency of the power supply RC filter equals to:

fLP = 1/(2*pi*Ci*R)

Where: R = 1/(1/Rzener + 1/Rs + 1/Rflip-flop)

Like

Discussions