Computers and modern gadgets

In portable devices, as you know, an important component is battery life. Who would like to use a device that has to be charged very often? Therefore, it is useful to add another function to various ways to reduce energy consumption - automatic power off, which will help save battery power if the user forgot to turn off the device. And in order to implement this, the device must be turned on and off from the button without locking. I just needed to implement something similar, and after testing several schemes found on the Internet, I settled on the most interesting solution. Therefore, now I will show how you can turn on and off a device on a microcontroller with one button without locking and the implementation of such an algorithm in Bascom-AVR.

The circuit is built on a small number of discrete elements and uses one controller interrupt:

When you press the S1 button, the transistor Q1 opens and the voltage from the battery goes to the circuit. In order to prevent transistor Q1 from closing after releasing the button, it is necessary to open transistor Q2 by applying one to the gate. And as long as there is a high voltage level at the gate of Q2, the circuit will be powered. When you need to de-energize the circuit and turn off the device, simply remove the voltage from this pin, both transistors will close and completely de-energize the circuit. LED D3 for operation indication.

Transistors must be used with a Logic Level so that they are fully turned on by battery voltage. Although I assembled and tested the circuit on what came to hand: I used IRF5305 as Q1, and IRF530 as Q2. Both transistors open almost completely from 5 volts. I took them because they are in large cases and can be used in a breadboard. Instead of diodes D1 and D2, I plugged in a diode bridge :)

First example. Turning the power on and off is done by simply pressing a button.

$regfile = "m8def.dat"
$crystal = 1000000

Dim flag asByte"variable for executing the main program

Config PORTB. 0 = OUTPUT"LED output
Ledalias portb. 0

Config portd. 3 = OUTPUT"power management
pwralias portd. 3

Config INT0 = low level "on/off button
On Int0 Start:

Enable int0 "enable interrupts
Enable interrupts

"main loop
Do

If flag = 1 then
Led= 1
endif

Loop

end


launch:

toggle pwr "on/off

flag= 1 "raise the flag

do
loop until pind. 2 = 1

waitms 100
Gifr= 64

return

And the second example. In order to prevent accidental switching on or off, a delay when pressing is more often used. This can also be easily implemented in this circuit; the code below has been slightly modified and now switching on and off occurs with a three-second delay:

$regfile = "m8def.dat"
$crystal = 1000000

dim flag asByte"variable for executing the main program
dim a asByte"to organize a delay
config PORTB. 0 = OUTPUT"LED output
ledalias portb. 0

config portd. 3 = OUTPUT"power management
pwralias portd. 3

config INT0 = low level "on/off button
On Int0 Start:

enable int0 "enable interrupts
enable interrupts

"main loop
do

if flag = 1 then"execution of the main program
"....
"....
endif

loop

end

"interrupt when a button is pressed
launch:

flag= 1 "raise the flag

do
incr a
wait 1

if a = 3 then"if 3 seconds have passed
toggle pwr "on/off
toggle led
goto ext "exit loop
endif

loopuntil pind. 2 = 1 "while the button is pressed, let's spin here
ext:
a= 0
waitms 100
Gifr= 64

return

Radio amateur Power supply

One button switch on and off

Turn on and off with just one button

In radio electronics, situations arise when one or more loads require only one button, which will turn the power on and off. This approach has advantages over placing two buttons or volumetric toggle switches in the case. It is also possible to use stylish and compact touch buttons. Or use turning on and off with one button in cases where there is only one button. Two schemes will be considered, in different versions and with different power options. Both options are working and tested. If the installation of components was carried out correctly and without replacing parts, then everything will work properly.

On and off one button - circuit on the trigger

The power supply of the circuit is from 7 V to 35 V. All parts are inexpensive, and repetition of the circuit is within the power of people who are far from radio electronics. Any button can be used, even from calls, as long as it can connect and disconnect a contact. You can hold it as long as you like, since the trigger will only work when the contact is disconnected. Accordingly, it will enter the next position when pressed again.

On and off one button - circuit on timer 555

Another remarkable circuit is built on the 555 timer. It is notable for the fact that the mains voltage is used, and several loads can be connected, as well as buttons. The diagram shows the locations of subsequent connections.

If you are faced with the task of turning on and off a device or several devices with one button, and you are looking for such an option, then you have clearly come to us at the right place. Here you will be offered several schemes for implementing similar projects on different microcircuits, and therefore with different operating principles, but with the same result. Well, let's talk about everything in order!

Control of one device (on/off) from one button (NE555)

We won’t bother too much about the first scheme, since the scheme is not our original idea, besides, this scheme has already been disassembled everywhere on the Internet. We saw that there is even a video about this. If you want, you can search.

Essentially, this circuit works on the NE555 timer chip. Yes, the microcircuit is already legendary and has achieved fame. Here, from this very timer, a multivibrator was created. So, if you create feedback on a timer, you get a multivibrator. And this very connection is created by pressing a button. As a result, the timer enters multivibrator mode and, with a certain frequency, begins to produce output pulses of either a one or a zero. As a result, it is this impulse that will control the power and indication circuit on a transistor with a relay and an LED.

What could be the downsides? Well, the main disadvantage is that the timer remains a timer, that is, he is not particularly interested in how many times you pressed the button, he is more interested in how to quickly charge or discharge a 1 uF capacitor. That is, it is possible to skip switching on and off, not explicit and inaccurate operation. Some hams call this "contact chatter", but that term has nothing to do with it. This is the normal operation of the timer, nothing more. So, with this option everything is clear.

Control of several or one device (on-off) from one button (K155IE7)

Now the option is on the counter. This is the principle here. There is a binary counter on the K155ie7 chip, at its output the potential changes with the input signal. Again, it's either a one or a zero. There are four exits in total. The first output on leg 3 changes its potential with every 1 press, the second on leg 2 with every 2, etc. In the end, what happens? It turns out that with one click you can control not only one device, but 4 at once, that is, according to the number of outputs. Here the main thing is to convert the low current signal into a high current signal. It is for this purpose that on the output leg we need, it is enough to “hang” a power module assembled on a 4n25 optocoupler, a transistor and a relay.

Also, in addition to controlling one, two, three or four devices, it will be possible to use such a scheme as a code key, that is, a combination lock. Here you can install a second counter and, depending on the high potentials on certain legs, provide power to operate the control locking element of the lock. We will not develop this topic, since it is better to make our own thematic article on this matter. We can only summarize that this scheme is not much more complicated than the first one; at the same time, it works with one click clearly and without deviations, and besides, it can control the power of 4 devices at once. This is exactly what we needed to achieve!
And now, whoever was too lazy to read and understand all this, we suggest you watch the video, which describes exactly the same thing.

Turning on/off multiple devices using microcontrollers (on Arduino)

Well, another variation of working with a whole “galaxy” of different devices is the use of microcontrollers. One of the most popular and at the same time understandable devices is Adruino, based on the Amtel 328P microcontroller. Microcontrollers are able to solve assigned tasks much more “flexibly” than analog circuits, especially if we take into account the possibility of customization and reconfiguration. Therefore, once you have mastered microcontrollers, you will simply start doing everything on them on a whim, since the current price of microcontrollers is comparable to analog elements. So, about turning on and off several devices on a microcontroller in the article “Arduino controls several devices"

Video about turning on and off several devices (one, two, three, four) with one button

28-07-2016

Anthony Smith

Low-current, momentary switches, similar to board-mounted tact switches, are cheap, readily available, and come in a wide variety of sizes and styles. At the same time, latching buttons are often larger, more expensive, and have a relatively limited range of design options. This can be a problem if you need a miniature, low-cost switch to secure power to a load. The article proposes a circuit solution that allows you to give a self-return button a locking function.

Previously, designs were proposed whose circuits were based on discrete components and microcircuits. However, below we will describe a circuit that requires only a couple of transistors and a handful of passive components to perform the same functions.

Figure 1a shows a variant of the power supply circuit for the case of a load connected to ground. The circuit operates in “switch” mode; this means that the first press turns on the power to the load, the second turns it off, and so on.

To understand the operating principle of the circuit, imagine that the +V S power supply has just been connected, capacitor C1 is initially discharged, and transistor Q1 is turned off. In this case, resistors R1 and R3 are connected in series and pull the gate of P-channel MOSFET Q2 to the +V S bus, keeping the transistor in the closed state. Now the circuit is in an “unblocked” state when the load voltage V L at the OUT (+) pin is zero.

By briefly pressing the normally open button, the gate of Q2 is connected to the capacitor C1, discharged to 0 V, and the MOSFET is turned on. The load voltage at the OUT (+) terminal immediately increases to +VS, through resistor R4, transistor Q1 receives base bias and turns on. As a result, Q1 becomes saturated and connects the gate of Q2 to ground through resistor R3, holding the MOSFET open when the button contacts are open. The circuit is now in a "latched" state where both transistors are open, the load is powered, and capacitor C1 is charged to +V S through resistor R2.

After momentarily closing the switch again, the voltage across capacitor C1 (now equal to +V S) will be applied to the gate of Q2. Since the gate-source voltage of Q2 is now close to zero, the MOSFET turns off and the load voltage drops to zero. Q1's base-emitter voltage also drops to zero, turning off the transistor. As a result, when the button is released, there is nothing holding Q2 open, and the circuit returns to the "enabled" state, with both transistors turned off, the load de-energized, and C1 discharged through resistor R2.

It is not necessary to install the resistor R5 that shunts the output terminals. When the button is released, capacitor C1 is discharged to the load through resistor R2. If the load impedance is very high (that is, comparable to the value of R2), or the load contains active devices such as, say, LEDs, the load voltage when Q2 is turned off may be large enough to turn on transistor Q1 through resistor R4 and prevent the circuit from switch off. Resistor R5, when Q2 turns off, pulls the OUT (+) terminal to the 0V rail, causing Q1 to turn off quickly and allowing the circuit to properly transition to the off state.

With the right selection of transistors, the circuit will operate over a wide range of voltages and can be used to drive loads such as relays, solenoids, LEDs, etc. However, keep in mind that some DC fans and motors continue to spin after the power is turned off. This rotation can create a back emf large enough to turn on transistor Q1 and prevent the circuit from turning off. The solution to the problem is shown in Figure 1b, where a blocking diode is connected in series with the output. In this case, you can also add resistor R5 to the circuit.

Figure 2 shows another circuit designed for loads connected to the top power rail, such as the electromagnetic relay shown in this example.

Note that Q1 has been replaced by a pnp transistor, and Q2 is now an N-channel MOSFET. This circuit works exactly the same as the circuit described above. Here, R5 acts as a pull-up resistor, connecting the OUT (-) output pin to the +V S bus when Q2 turns off, and causing Q1 to turn off quickly. As in the previous circuit, resistor R5 is an optional component, and is installed only for certain types of loads mentioned above.

Note that in both circuits the time constant C1, R2 is selected based on the required contact bounce suppression. Typically, a value from 0.25 s to 0.5 s is considered normal. Smaller time constants can lead to unstable operation of the circuit, while larger ones increase the waiting time between closing the button contacts, during which a sufficiently complete charge and discharge of capacitor C1 must occur. With the values ​​​​indicated in the diagram C1 = 330 nF and R2 = 1 MOhm, the nominal value of the time constant is 0.33 s. Usually this is enough to eliminate contact bounce and switch the load in about a couple of seconds.

Both circuits are designed to latch and release the key in response to momentary contact closures. However, each of them was designed in such a way as to guarantee correct operation even when the button is pressed for any length of time. Consider the circuit in Figure 2 when Q2 is off. If the button is pressed to turn off the circuit, the gate is connected to the 0V potential (since capacitor C1 is discharged) and the MOSFET is closed, allowing the common point of resistors R1 and R2 to connect to the +V S rail through resistor R5 and the load impedance. At the same time, Q1 is also turned off, causing the gate of Q2 to be connected to the GND bus through resistors R3 and R4. If the button is immediately released, C1 will simply charge through resistor R2 to a voltage of +V S. However, if you leave the button closed, the gate voltage of Q2 will be determined by the potential of the divider formed by resistors R2 and R3+R4. Assuming that when the circuit is unlocked, the voltage at the OUT (-) pin is approximately equal to +V S, the following expression can be written for the gate-source voltage of transistor Q2:

Even if the +V S voltage is 30 V, the resulting 0.6 V voltage between gate and source is not enough to turn the MOSFET back on. Therefore, when the button contacts are open, both transistors will remain off.

If you are faced with the task of turning on and off a device or several devices with one button, and you are looking for such an option, then you have clearly come to us at the right place. Here you will be offered several schemes for implementing similar projects on different microcircuits, and therefore with different operating principles, but with the same result. Well, let's talk about everything in order!

Control of one device (on/off) from one button (NE555)

We won’t bother too much about the first scheme, since the scheme is not our original idea, besides, this scheme has already been disassembled everywhere on the Internet. We saw that there is even a video about this. If you want, you can search.

Essentially, this circuit works on the NE555 timer chip. Yes, the microcircuit is already legendary and has achieved fame. Here, from this very timer, a multivibrator was created. So, if you create feedback on a timer, you get a multivibrator. And this very connection is created by pressing a button. As a result, the timer enters multivibrator mode and, with a certain frequency, begins to produce output pulses of either a one or a zero. As a result, it is this impulse that will control the power and indication circuit on a transistor with a relay and an LED.

What could be the downsides? Well, the main disadvantage is that the timer remains a timer, that is, he is not particularly interested in how many times you pressed the button, he is more interested in how to quickly charge or discharge a 1 uF capacitor. That is, it is possible to skip switching on and off, not explicit and inaccurate operation. Some hams call this "contact chatter", but that term has nothing to do with it. This is the normal operation of the timer, nothing more. So, with this option everything is clear.

Control of several or one device (on-off) from one button (K155IE7)

Now the option is on the counter. This is the principle here. There is a binary counter on the K155ie7 chip, at its output the potential changes with the input signal. Again, it's either a one or a zero. There are four exits in total. The first output on leg 3 changes its potential with every 1 press, the second on leg 2 with every 2, etc. In the end, what happens? It turns out that with one click you can control not only one device, but 4 at once, that is, according to the number of outputs. Here the main thing is to convert the low current signal into a high current signal. It is for this purpose that on the output leg we need, it is enough to “hang” a power module assembled on a 4n25 optocoupler, a transistor and a relay.

Also, in addition to controlling one, two, three or four devices, it will be possible to use such a scheme as a code key, that is, a combination lock. Here you can install a second counter and, depending on the high potentials on certain legs, provide power to operate the control locking element of the lock. We will not develop this topic, since it is better to make our own thematic article on this matter. We can only summarize that this scheme is not much more complicated than the first one; at the same time, it works with one click clearly and without deviations, and besides, it can control the power of 4 devices at once. This is exactly what we needed to achieve!
And now, whoever was too lazy to read and understand all this, we suggest you watch the video, which describes exactly the same thing.

LED bulbs How much does a charger consume and is it possible to save money on it or why do you still need to disconnect charging from the outlet? Commands for enabling and disabling options for mobile operators (MTS, Beeline, Megafon) Resistor color coding (nominal resistance and power)
Electric cable heating systems (ECSO) are an excellent solution for a modern home
Schneider Electric: new products in the Odace series

If you notice an error, select a piece of text and press Ctrl+Enter
SHARE:
Computers and modern gadgets