Author Topic: Push buttton as a on/off Switch.  (Read 1393 times)

0 Members and 1 Guest are viewing this topic.

Offline Michaelaudio

  • Regular Contributor
  • *
  • Posts: 120
  • Country: de
Push buttton as a on/off Switch.
« on: January 13, 2021, 08:42:58 am »
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.
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 9496
Re: Push buttton as a on/off Switch.
« Reply #1 on: January 13, 2021, 10:10:27 am »
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/
 
The following users thanked this post: Michaelaudio

Offline Michaelaudio

  • Regular Contributor
  • *
  • Posts: 120
  • Country: de
Re: Push buttton as a on/off Switch.
« Reply #2 on: January 13, 2021, 10:24:52 am »
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.
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 9496
Re: Push buttton as a on/off Switch.
« Reply #3 on: January 13, 2021, 10:35:20 am »
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.
 

Offline Michaelaudio

  • Regular Contributor
  • *
  • Posts: 120
  • Country: de
Re: Push buttton as a on/off Switch.
« Reply #4 on: January 13, 2021, 10:52:25 am »
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?
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 9496
Re: Push buttton as a on/off Switch.
« Reply #5 on: January 13, 2021, 11:13:42 am »
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.
 

Offline ledtester

  • Super Contributor
  • ***
  • Posts: 1177
  • Country: us
Re: Push buttton as a on/off Switch.
« Reply #6 on: January 13, 2021, 11:22:47 am »
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?

Can you show us a schematic of your 4516 circuit?
 

Offline Michaelaudio

  • Regular Contributor
  • *
  • Posts: 120
  • Country: de
Re: Push buttton as a on/off Switch.
« Reply #7 on: January 13, 2021, 11:38:50 am »
@Ian u mean somethig Like this?

Pics attached
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 9496
Re: Push buttton as a on/off Switch.
« Reply #8 on: January 13, 2021, 11:44:49 am »
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).
« Last Edit: January 13, 2021, 11:47:29 am by Ian.M »
 
The following users thanked this post: Michaelaudio

Offline Michaelaudio

  • Regular Contributor
  • *
  • Posts: 120
  • Country: de
Re: Push buttton as a on/off Switch.
« Reply #9 on: January 13, 2021, 12:06:19 pm »
Yea i know  ;D I 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.
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 9496
Re: Push buttton as a on/off Switch.
« Reply #10 on: January 13, 2021, 12:15:08 pm »
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.
 

Offline Michaelaudio

  • Regular Contributor
  • *
  • Posts: 120
  • Country: de
Re: Push buttton as a on/off Switch.
« Reply #11 on: January 13, 2021, 08:10:44 pm »
I guess this should Work.
 

Offline Peabody

  • Frequent Contributor
  • **
  • Posts: 955
  • Country: us
Re: Push buttton as a on/off Switch.
« Reply #12 on: January 13, 2021, 10:41:17 pm »
I guess this should Work.

Doesn'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.
« Last Edit: January 13, 2021, 11:28:10 pm by Peabody »
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 9496
Re: Push buttton as a on/off Switch.
« Reply #13 on: January 13, 2021, 11:28:58 pm »
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.
 

Offline Peabody

  • Frequent Contributor
  • **
  • Posts: 955
  • Country: us
Re: Push buttton as a on/off Switch.
« Reply #14 on: January 13, 2021, 11:33:27 pm »
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).

« Last Edit: January 13, 2021, 11:36:35 pm by Peabody »
 

Offline Peabody

  • Frequent Contributor
  • **
  • Posts: 955
  • Country: us
Re: Push buttton as a on/off Switch.
« Reply #15 on: January 14, 2021, 12:19:40 am »
Anyway, I think this would work.  R3 and R5 could be a lot bigger, and R4 probably isn't needed at all.
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 9496
Re: Push buttton as a on/off Switch.
« Reply #16 on: January 14, 2021, 03:29:46 am »
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.
 

Offline ledtester

  • Super Contributor
  • ***
  • Posts: 1177
  • Country: us
Re: Push buttton as a on/off Switch.
« Reply #17 on: January 14, 2021, 05:37:29 am »
If the caps are all discharged to begin with, how does this circuit come up?

If 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/#msg3235690

Look for one that has Set and Reset control pins such as:

- 74LVC1G74
- 74x74
- 74x79
- CD4013

By using R's and C's at those control pins you can make the flip-flop come in whatever state you want.
 

Offline Michaelaudio

  • Regular Contributor
  • *
  • Posts: 120
  • Country: de
Re: Push buttton as a on/off Switch.
« Reply #18 on: January 14, 2021, 07:09:45 am »
@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)
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 9496
Re: Push buttton as a on/off Switch.
« Reply #19 on: January 14, 2021, 07:42:05 am »
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.
 

Offline Michaelaudio

  • Regular Contributor
  • *
  • Posts: 120
  • Country: de
Re: Push buttton as a on/off Switch.
« Reply #20 on: January 14, 2021, 08:13:08 am »
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. 
 

Offline eblc1388

  • Frequent Contributor
  • **
  • Posts: 255
  • Country: gb
Re: Push buttton as a on/off Switch.
« Reply #21 on: January 14, 2021, 08:40:14 am »
I guess this should Work.

Yes, but marginally. The resistor value is wrong. What happens if one pushes the button too long?
 
The following users thanked this post: Michaelaudio

Offline Michaelaudio

  • Regular Contributor
  • *
  • Posts: 120
  • Country: de
Re: Push buttton as a on/off Switch.
« Reply #22 on: January 14, 2021, 08:57:42 am »
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.
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 9496
Re: Push buttton as a on/off Switch.
« Reply #23 on: January 14, 2021, 09:10:21 am »
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.
 
The following users thanked this post: Michaelaudio

Offline Michaelaudio

  • Regular Contributor
  • *
  • Posts: 120
  • Country: de
Re: Push buttton as a on/off Switch.
« Reply #24 on: January 14, 2021, 09:19:19 am »
 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.
« Last Edit: January 14, 2021, 10:18:13 am by Michaelaudio »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf