Push buttton as a on/off Switch.  - Page 1
Forum section: electronics / beginners

author: Michaelaudio
author_rank: Regular Contributor
timestamp: January 13, 2021, 08:42:58 am
content: So i wanna use a button as a in/Off switch an thought about using a CD4516 and using the Q0 output, this will work but its a bit odd bc i would just use this single output of the IC. Is there another simple reliable solution for it? I dont want that the circuit for it oscilates, so i dont wanna use the circuit Dave showed a few years ago.

author: Ian.M
author_rank: Super Contributor
timestamp: January 13, 2021, 10:10:27 am
content: See the two inverter toggle latch circuit presented by eblc1388 here:https://www.eevblog.com/forum/beginners/help-on-how-to-choose-an-ic-for-a-project/

author: Michaelaudio
author_rank: Regular Contributor
timestamp: January 13, 2021, 10:24:52 am
content: Seems the 74LVC2G04 is what i need, i will use this to Power in or Off a battery powered BT speaker so the button circuit will Always be powered and i dont have to worrry about the state of the Output.

author: Ian.M
author_rank: Super Contributor
timestamp: January 13, 2021, 10:35:20 am
content: It depends on the supply voltage - a 74LVC2G04 is only good up to 5.5V, so that limits you to a single LiPO or three AA cells. If you need to control a higher voltage the simplest option is probably still 4000 series CMOS even if 2/3 of the gates in the IC are unused.Also don't forget you'll need a MOSFET to actually switch power to your load circuit.

author: Michaelaudio
author_rank: Regular Contributor
timestamp: January 13, 2021, 10:52:25 am
content: I could use a 7805 but Well.. I also found another solution with a 4013 but that would be nearly the Same as my 4516 solution. The 4516 circuit works fine, only negative Point is that i have to hold down the button for quite Long when i wanna Turn Off, any suggestions for this?

author: Ian.M
author_rank: Super Contributor
timestamp: January 13, 2021, 11:13:42 am
content: A 4013 dual D flipflop based latch is likely to be more complex than the toggle latch circuit by the time you've added debouncing for the button. If you dont debounce the button it will toggle the output a random number of times whenever you press it, and possibly also when you release it, so the button behavior is extremely unpredictable - it may fail to switch or may switch then revert when released.I recommend simply building the toggle latch circuit (which is known to be reliable) with 4000 series buffered inverters, or NOR or NAND gates wired as inverters. Tie inputs of unused gates to ground, don't leave them floating.However if you want more complex functionality i.e. using one button for on/off and also other control functions, or wakeup on any button, or adding timed power-off you'll end up needing a MCU with an extremely low power sleep mode, powered via a micropower LDO regulator, which removes the battery voltage constraint.

author: ledtester
author_rank: Super Contributor
timestamp: January 13, 2021, 11:22:47 am
content: Quote from: Michaelaudio on January 13, 2021, 10:52:25 amCan you show us a schematic of your 4516 circuit?

author: Michaelaudio
author_rank: Regular Contributor
timestamp: January 13, 2021, 11:38:50 am
content: @Ian u mean somethig Like this?Pics attached

author: Ian.M
author_rank: Super Contributor
timestamp: January 13, 2021, 11:44:49 am
content: Yep a NAND (or NOR) gate with all its inputs strapped together *IS* an inverter, so that *IS* the two inverter toggle latch circuit (with an additional capacitor to force the initial state).

author: Michaelaudio
author_rank: Regular Contributor
timestamp: January 13, 2021, 12:06:19 pm
content: Yea i knowI Just had to remember bc i did nothing with digital stuff for over 2 years, its interessting how quick u "forget" things u learned 3 years ago.I will draw a finished schematic and Post it Here.

author: Ian.M
author_rank: Super Contributor
timestamp: January 13, 2021, 12:15:08 pm
content: Another toggle latch 'trick', when the load only needs a low current is to use a hex inverter chip, and parallel five of them to make one of the inverters in the latch, then power the load directly from the output of the paralleled inverters.

author: Michaelaudio
author_rank: Regular Contributor
timestamp: January 13, 2021, 08:10:44 pm
content: I guess this should Work.

author: Peabody
author_rank: Super Contributor
timestamp: January 13, 2021, 10:41:17 pm
content: Quote from: Michaelaudio on January 13, 2021, 08:10:44 pmDoesn't R2 have to connect to the inputs of U?A?I'm confused by your use of an N-channel mosfet, assuming this is a high-side switch. And what's the voltage on the gate of Q3 when Q2 is off? I think if you use a P-channel mosfet, you don't need Q2 or R5.What about using an 8-pin microcontroller instead of all those parts. It would be in deep sleep until awakened by the pushbutton, and then it would invert the output driving the mosfet, wait for the botton to be released, and go back to sleep. Probably a minor fraction of a microamp current draw.Edit: If your battery is higher than about 5.5V, the microcontroller might not be a good choice. Also, note that if the system powers up in the wrong state, you can drive Q1 from the output of U?A instead of from the output of U?B.

author: Ian.M
author_rank: Super Contributor
timestamp: January 13, 2021, 11:28:58 pm
content: No it won't work. In addition to Peabody's comments, Q1's B-E junction would hold the toggle latch output low when it was supposed to be high, causing it to rapidly revert to the off state.

author: Peabody
author_rank: Super Contributor
timestamp: January 13, 2021, 11:33:27 pm
content: Yes, I should have noticed the absence of a base resistor.If the caps are all discharged to begin with, how does this circuit come up? Well, I mean how does the output of Q?B come up when power is applied? It seems it would come up low because of C2 (assuming R2 is wired correctly).

author: Peabody
author_rank: Super Contributor
timestamp: January 14, 2021, 12:19:40 am
content: Anyway, I think this would work. R3 and R5 could be a lot bigger, and R4 probably isn't needed at all.

author: Ian.M
author_rank: Super Contributor
timestamp: January 14, 2021, 03:29:46 am
content: The toggle latch has complimentary outputs. C2 sets the initial state as pin 3 high, pin 4 low. Simply drive the gate of the P-MOSFET from pin 3 if you want it to power up OFF. You can do away with the bipolar driver transistor(s). I'd keep the series gate resistor, and fit it as close as possible to the MOSFET gate pin as a 'gate stopper' to prevent it acting as a RF oscillator in common gate and 'chirping' during the transitions.

author: ledtester
author_rank: Super Contributor
timestamp: January 14, 2021, 05:37:29 am
content: Quote from: Peabody on January 13, 2021, 11:33:27 pmIf you are concerned about power-up behavior, I'd look into using a D-flipflop with /Q routed back to the D input. There was a discussion of such an design in this thread:https://www.eevblog.com/forum/projects/press-and-hold-latching-circuit-questions/msg3235690/#msg3235690Look for one that has Set and Reset control pins such as:- 74LVC1G74- 74x74- 74x79- CD4013By using R's and C's at those control pins you can make the flip-flop come in whatever state you want.

author: Michaelaudio
author_rank: Regular Contributor
timestamp: January 14, 2021, 07:09:45 am
content: @Peabody yes ur right, i missed the connection!@ Ian i'll so that. It wouldnt matter If i Connect the Gate of the P CH. to pin3 or pin4 right? Since the circuit is always connected to the battery (5x 18650 in series) the circuit is always in an on or off state (If i pushed the button once)

author: Ian.M
author_rank: Super Contributor
timestamp: January 14, 2021, 07:42:05 am
content: Which output of the toggle that you use only matters if you need a specific powerup state. As you don't you can use either and omit the small cap that forces the initial state.However you have another problem - when the battery is freshly charged, it is likely to go over 20V, which means you can't use 4000 series CMOS running from the full battery voltage. If you can tap the battery pack to connect the switch circuit Vss rail one cell up from ground, it will work OK and as the quiescent current consumption of a simple 4000 series CMOS gates chip is negligible, it won't significantly unbalance the battery, provided the button isn't held down for an extended period.If you don't like that idea (e.g. because your charging circuit doesn't do *ANY* cell balancing - though that's a problem in its own right) you'll need to complicate the circuit with a micropower voltage regulator to feed the toggle latch, then either use a low side N-MOSFET load switch, or a N-MOSFET as a level shifter to get the gate drive for the high side P-MOSFET load switch up to the battery positive rail.

author: Michaelaudio
author_rank: Regular Contributor
timestamp: January 14, 2021, 08:13:08 am
content: I will use a 7815, it wont produce much heat and i think its the simpliest solution. Im using a wondom S5 board so that should be fine for the cells.

author: eblc1388
author_rank: Frequent Contributor
timestamp: January 14, 2021, 08:40:14 am
content: Quote from: Michaelaudio on January 13, 2021, 08:10:44 pmYes, but marginally. The resistor value is wrong. What happens if one pushes the button too long?

author: Michaelaudio
author_rank: Regular Contributor
timestamp: January 14, 2021, 08:57:42 am
content: It will Switch on or off, No matter how long i press the button. It will turn into another state when i let go from the button and press it again.

author: Ian.M
author_rank: Super Contributor
timestamp: January 14, 2021, 09:10:21 am
content: A 7815 is absolutely unsuitable due to its high quiescent current.Please note eblc1388's comment on the resistor ratios. If the resistors are equal, the first gate input is held at 1/2 Vdd if you press the button for long enough, which makes its output uncertain, and it may even oscillate. Making R1:R2 > 5:1 guarantees the first gate input is either >80% Vdd or <20% Vdd so if you hold the button, its at a valid logic level, so the latch wont toggle again after it initially toggled on button down. Personally, I'd increase R1 to 680K and decrease C1 to 0.22uF.

author: Michaelaudio
author_rank: Regular Contributor
timestamp: January 14, 2021, 09:19:19 am
content: How about another linear Regulator or no LR at all? (I guess it will be Always a high qsc when i use a LR) Its for a BT speaker, and i'll use 3 amp Boards and a BT Modul, so idk If a Buck converter will inteoduce noise somewhere?Sounds legit, i'll fix that.

author: Ian.M
author_rank: Super Contributor
timestamp: January 14, 2021, 09:32:22 am
content: The quiescent current of the regulator drains your battery. The total quiescent current of the whole circuit should be under 30uA, as that is comparable to a good 18650 cell's self-discharge (1%/month). If you can get it under 5uA it will be entirely negligible.

author: Ian.M
author_rank: Super Contributor
timestamp: January 14, 2021, 10:54:30 am
content: Most ultra-low quiescent current fixed regulators have a max Vout of 5V. It would be advisable to swap out the CD4000 series CMOS chip for a 74HC one or possibly a74LVC2G04SMD dual inverter, for the toggle latch, then use a N-MOSFET with a max Vgs threshold <2.5V, with grounded source as a level shifter to get the latch output up to the P-MOSFET gate, which is referenced to the +Batt rail which may be up to 21V above ground. If your P-MOSFET's max Vgs is under +/-25V, you'll need a potential divider between the N-MOSFET drain and +Batt to drive the gate with a lower voltage swing. The choice of total resistance is a compromise between additional current when on and speed of switching on/off. I wouldn't go below 100uA through the divider when on.Alternatively, provided the charger circuit doesn't share a ground with the audio side of things or any other load on the same battery with a common ground, switch the negative side of the battery with a low Vgs threshold N-MOSFET as a low side switch.

author: Michaelaudio
author_rank: Regular Contributor
timestamp: January 14, 2021, 11:20:05 am
content: For simplicity id obv use a uC but i cant program anything so i have to do it that way.I guess i should be able to find a NMos with Vgs <2,5V and Pmos Vgs above 25V.Ultra Low qsc converters r always switching regularors, i assume.I have to use a bosst converter for the amps, to get it at 24V fixed. Do U think this could couse any Trouble? If not, then another one wont bei a Problem i think. Back in the das i build my First BT speaker and used Lead batteries with a boost converter and an amp Board, didnt couse any problems.

author: Ian.M
author_rank: Super Contributor
timestamp: January 14, 2021, 11:26:08 am
content: No. Many ultra-low quiescent current regulators are linear. It wouldn't make sense to use a switching regulator just for the toggle latch, which only needs a couple of uA quiescent, and few mA peak when it switches.I should note that if you can program an Arduino, you can program an ATtiny AVR MCU, using an Arduino running the ArduinoISP sketch as a programmer, and some ATtiny AVRs have low enough quiescent current to be viable for this application. However if you have negative aptitude for C programming, you may well be wise to avoid MCUs.

author: Michaelaudio
author_rank: Regular Contributor
timestamp: January 14, 2021, 11:49:49 am
content: I guess the MAX1615EUK+T will do the Job.I learned the verry basics of arduino programming 3 years ago but never did anything since then so i'll stay with the current solution

author: Michaelaudio
author_rank: Regular Contributor
timestamp: January 14, 2021, 07:57:08 pm
content: Its Not easy to find a P Mos with AT LEAST +/-25Vgs. I didnt quite understand it, If U wanna switch a fet on, u want Vgs as low AS possible?..

author: Ian.M
author_rank: Super Contributor
timestamp: January 14, 2021, 08:21:59 pm
content: Vgs(max) is a completely different parameter to Vgs_threshold(max).Vgs(max) is the limit above which the gate oxide may fail, destroying the MOSFET.Vgs_threshold is the gate voltage that is just enough to start turning the MOSFET on.Vgs_threshold(max) is the *LOWER* voltage limit at which *ALL* MOSFETs of the specified type will have started to turn on.Vgs(max) and Vgs_threshold(max) are not closely related except that a thicker gate oxide is more robust and also reduces the effect of gate voltage on the channel.As a rough rule of thumb you want gate drive of at least double Vgs_threshold(max) to get the Rds_on low enough to handle significant currents, but obviously less than Vgs(max) by an adequate safety margin.Power MOSFETs with Vgs(max) > +/-20V aren't particularly common. I did suggest using a potential divider to reduce the gate drive: A 3:1 resistor ratio (larger one as the gate pullup) would give you slightly over 15V of gate drive with fully charged batteries, dropping to about 11V at their safe discharge limit, which would be suitable for 20V Vgs(max) MOSFETs.

author: Michaelaudio
author_rank: Regular Contributor
timestamp: January 14, 2021, 08:36:29 pm
content: And i thought U mean Vgs(th), idk why. Sometimes a Lil knowledge refresh is all it takes, i got u know. Guess i wont need the devider, the FQD11P06TM hast a Vgs of +/-30V

author: Michaelaudio
author_rank: Regular Contributor
timestamp: January 14, 2021, 08:42:25 pm
content: It Looks Like this now.

author: ledtester
author_rank: Super Contributor
timestamp: January 14, 2021, 09:07:47 pm
content: What's your battery voltage?For the same price of a MAX1615 you could use a MAX16150 which will also handle all of the pushbutton logic:https://datasheet.octopart.com/MAX16150BWT%2BT-Maxim-Integrated-datasheet-140091574.pdfor have a look at the TI TPS3421 which is about 50% cheaper:https://www.ti.com/product/TPS3421?HQS=TI-null-null-octopart-df-pf-null-wwe

author: Michaelaudio
author_rank: Regular Contributor
timestamp: January 14, 2021, 10:03:18 pm
content: Oh thats nice, guess i'll use the 16150 then, so i can safe space.Its about 21V (5x 18650)

author: ledtester
author_rank: Super Contributor
timestamp: January 14, 2021, 10:10:22 pm
content: Note that the max Vcc for the MAX16150 is 6V.

author: Michaelaudio
author_rank: Regular Contributor
timestamp: January 15, 2021, 07:01:05 am
content: Im using a 5V Regulator, should be fine.

author: Michaelaudio
author_rank: Regular Contributor
timestamp: January 15, 2021, 02:29:54 pm
content: Any improvements i have to do?