Author Topic: Press and Hold Latching Circuit Questions  (Read 13279 times)

0 Members and 1 Guest are viewing this topic.

Offline KuusouTopic starter

  • Contributor
  • Posts: 39
  • Country: us
Re: Press and Hold Latching Circuit Questions
« Reply #50 on: September 26, 2020, 09:59:25 pm »


Well apparently on another forum they're saying that all this does is switch the power from 3.3V to 5V. They're saying that the boost converter output pin will be reading 3.3V. I'm unsure how to completely switch off power from the converter until the button is pressed  |O

Yes, that's correct. You can see that DC voltage from 3.3V will flow through the inductor, through the schottky diode to the output 5.5V labelled line.

So you would need to add your power mosfet following the Boost converter to switch the output on/off.

Your control circuitry would then optionally enable/disable the boost converter, as well as the output mosfet.

The impression of the initial post is to control power safely. If that is the case, then mechanical switches with latched behavior and/or mechanical relays might be better. They behave more robustly for the state/transitions during power up/down and for failure scenarios.

I've used mechanical switches in previous iterations of this project, the problem is that they're easily switched on during transport/shipping and will completely drain the battery as a result. That's the main reason I'm switching to a soft latching switch that requires a long press to turn on. A mechanical switch would definitely make my design simpler but in this particular case its just not a viable option.
 

Offline KuusouTopic starter

  • Contributor
  • Posts: 39
  • Country: us
Re: Press and Hold Latching Circuit Questions
« Reply #51 on: September 26, 2020, 10:00:08 pm »
I think I've figured out how to cut off power to the entire boost converter circuit using the schematic below.



I'm using a BJT which has its base connected to the Q pin of the flip flop. Which is has its collector attached to the gate of a P-Channel MOSFET which acts as a switch for the main power going into the boost converter circuit. Please let me know if you believe this will work, any feedback is very much appreciated.
 

Offline Peabody

  • Super Contributor
  • ***
  • Posts: 2007
  • Country: us
Re: Press and Hold Latching Circuit Questions
« Reply #52 on: September 27, 2020, 01:48:59 am »
I believe you can just drive the mosfet gate directly from the /Q output of the flipflop, and do away with the NPN transistor.  The NPN inverts the Q output, but /Q is always the opposite of the Q output too, so you get an inverted Q either way.

If you use the NPN, you'll need a base resistor for it, and a pullup resistor on the mosfet gate.  But if you just drive the gate directly from /Q, I don't think you'll need either resistor.
« Last Edit: September 27, 2020, 01:58:23 am by Peabody »
 

Offline ledtester

  • Super Contributor
  • ***
  • Posts: 3036
  • Country: us
Re: Press and Hold Latching Circuit Questions
« Reply #53 on: September 27, 2020, 02:40:13 am »
In your circuit with the NPN you're missing a base resistor. But as Peabody said I would try using the /Q output to drive the P-channel MOSFET.

Quote
I've used mechanical switches in previous iterations of this project, the problem is that they're easily switched on during transport/shipping and will completely drain the battery as a result.

What about a slide switch with a shorter "knob" like this:

https://www.digikey.com/product-detail/en/c-k/S202131SS03Q/CKN11024-ND/3754439

Or go for an even flatter switch like the 110/220 selector you see on ATX power supplies.

Or even the the ol' battery protection pull tab:

https://www.fierceelectronics.com/components/pull-tabs-insulate-batteries-during-shipping-and-storage


 

Offline KuusouTopic starter

  • Contributor
  • Posts: 39
  • Country: us
Re: Press and Hold Latching Circuit Questions
« Reply #54 on: September 27, 2020, 02:50:52 am »
In your circuit with the NPN you're missing a base resistor. But as Peabody said I would try using the /Q output to drive the P-channel MOSFET.

Quote
I've used mechanical switches in previous iterations of this project, the problem is that they're easily switched on during transport/shipping and will completely drain the battery as a result.

What about a slide switch with a shorter "knob" like this:

https://www.digikey.com/product-detail/en/c-k/S202131SS03Q/CKN11024-ND/3754439

Or go for an even flatter switch like the 110/220 selector you see on ATX power supplies.

Or even the the ol' battery protection pull tab:

https://www.fierceelectronics.com/components/pull-tabs-insulate-batteries-during-shipping-and-storage

That's wayyyyy too expensive. Also this goes into a case and its rather small. All the switches I've looked at are way too large to fit. Also a pull tab wouldn't work because its ran off a lipo and even after shipping/transport I don't want someone to put the project in their bag and have it turned on. Switches just won't work this project in particular, plus at this point i'm determined to make this work hahaha
« Last Edit: September 27, 2020, 03:29:57 am by Kuusou »
 

Offline KuusouTopic starter

  • Contributor
  • Posts: 39
  • Country: us
Re: Press and Hold Latching Circuit Questions
« Reply #55 on: September 27, 2020, 03:08:59 am »
I believe you can just drive the mosfet gate directly from the /Q output of the flipflop, and do away with the NPN transistor.  The NPN inverts the Q output, but /Q is always the opposite of the Q output too, so you get an inverted Q either way.

If you use the NPN, you'll need a base resistor for it, and a pullup resistor on the mosfet gate.  But if you just drive the gate directly from /Q, I don't think you'll need either resistor.

Thanks for your response. I was trying to follow this circuit layout


and I just realized I forgot to add the resistors in my layout!. I'm confused as to why /Q works but Q doesn't? I'm sorry for being a noob with this stuff, I was hoping you could try to explain? My understanding is that the pulse sent to the flip flop becomes inverted by attaching /Q to the data input pin. So the pulse leading edge hits the IC, it says turn on but because /Q is inverted and is attached to the data pin it stays off until the low end of the pulse hits which is not until the end of a 2 second delay due to the rc timer circuit and hence I get my long press to turn on the power. If I use /Q to drive the gate instead of Q wouldn't that completely ignore the delayed start I'm looking for?

Looking at this more closely I think I'm seeing another issue. The flip flop doesn't remember states, I want to make sure that the board isn't powered on when plugged into power to charge the battery. I've got an RC circuit on the CLR pin (R6 & C6) I'm just insure of whether this circuit is pulling the pin low or high. I believe its pulling it low but I want to be sure.

Assuming that using /Q would remove the delayed start then would this solution would still work correct?
« Last Edit: September 27, 2020, 06:28:11 am by Kuusou »
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19523
  • Country: gb
  • 0999
Re: Press and Hold Latching Circuit Questions
« Reply #56 on: September 27, 2020, 09:45:18 am »


Well apparently on another forum they're saying that all this does is switch the power from 3.3V to 5V. They're saying that the boost converter output pin will be reading 3.3V. I'm unsure how to completely switch off power from the converter until the button is pressed  |O

Yes, that's correct. You can see that DC voltage from 3.3V will flow through the inductor, through the schottky diode to the output 5.5V labelled line.

So you would need to add your power mosfet following the Boost converter to switch the output on/off.

Your control circuitry would then optionally enable/disable the boost converter, as well as the output mosfet.

The impression of the initial post is to control power safely. If that is the case, then mechanical switches with latched behavior and/or mechanical relays might be better. They behave more robustly for the state/transitions during power up/down and for failure scenarios.
Sorry, I missed that. Yes, when the IC is disabled, its output transistor will be off, so the input voltage will flow through the diode to the output.

https://en.wikipedia.org/wiki/Boost_converter
I think I've figured out how to cut off power to the entire boost converter circuit using the schematic below.



I'm using a BJT which has its base connected to the Q pin of the flip flop. Which is has its collector attached to the gate of a P-Channel MOSFET which acts as a switch for the main power going into the boost converter circuit. Please let me know if you believe this will work, any feedback is very much appreciated.
Why not put the MOSFET on the output of the boost converter, after the diode, but before the divider? The current on the output will be lower than the input, which should give lower losses.

 

Offline Peabody

  • Super Contributor
  • ***
  • Posts: 2007
  • Country: us
Re: Press and Hold Latching Circuit Questions
« Reply #57 on: September 27, 2020, 02:34:43 pm »
I'm confused as to why /Q works but Q doesn't? I'm sorry for being a noob with this stuff, I was hoping you could try to explain? My understanding is that the pulse sent to the flip flop becomes inverted by attaching /Q to the data input pin. So the pulse leading edge hits the IC, it says turn on but because /Q is inverted and is attached to the data pin it stays off until the low end of the pulse hits which is not until the end of a 2 second delay due to the rc timer circuit and hence I get my long press to turn on the power. If I use /Q to drive the gate instead of Q wouldn't that completely ignore the delayed start I'm looking for?

Looking at this more closely I think I'm seeing another issue. The flip flop doesn't remember states, I want to make sure that the board isn't powered on when plugged into power to charge the battery. I've got an RC circuit on the CLR pin (R6 & C6) I'm just insure of whether this circuit is pulling the pin low or high. I believe its pulling it low but I want to be sure.

You have the flipflop configured to come up with Q low.  You've done that with the R/C on /CLR.  But /Q is *always* just the inverted state of Q.  So the flipflop will come up with Q low, but also with /Q high.  High is the state needed on the mosfet gate to keep it turned off.  When the first long button press occurs, CLK will go high, and  the state of /Q (high) will be latched via the D pin to Q, which will bring Q high and /Q low, which will turn the mosfet on.  Both Q and /Q change state *immediately after* the rising edge of the CLK.  Nothing happens on the falling edge.  You get a falling edge when the button is released. Then the next long press produces another rising edge, which brings /Q high again, which turns off the mosfet.

Your NPN circuit is just an inverter for Q.  When Q goes high, the NPN brings the mosfet gate low, and vice versa.  But you already have something that always produces  an inverted version of Q, and that's /Q.  It should work exactly the same, but without the extra parts.

I think you would find it really helpful if you could breadboard stuff like this and test it out with through-hole versions of these chips.

Edit:  You could also drive the mosfet gate directly from Q, but you would need to move the R/C over to the /PREset pin so the  flipflop would come up with Q high.

« Last Edit: September 27, 2020, 02:54:00 pm by Peabody »
 
The following users thanked this post: Kuusou

Offline KuusouTopic starter

  • Contributor
  • Posts: 39
  • Country: us
Re: Press and Hold Latching Circuit Questions
« Reply #58 on: September 27, 2020, 07:39:51 pm »
I'm confused as to why /Q works but Q doesn't? I'm sorry for being a noob with this stuff, I was hoping you could try to explain? My understanding is that the pulse sent to the flip flop becomes inverted by attaching /Q to the data input pin. So the pulse leading edge hits the IC, it says turn on but because /Q is inverted and is attached to the data pin it stays off until the low end of the pulse hits which is not until the end of a 2 second delay due to the rc timer circuit and hence I get my long press to turn on the power. If I use /Q to drive the gate instead of Q wouldn't that completely ignore the delayed start I'm looking for?

Looking at this more closely I think I'm seeing another issue. The flip flop doesn't remember states, I want to make sure that the board isn't powered on when plugged into power to charge the battery. I've got an RC circuit on the CLR pin (R6 & C6) I'm just insure of whether this circuit is pulling the pin low or high. I believe its pulling it low but I want to be sure.

You have the flipflop configured to come up with Q low.  You've done that with the R/C on /CLR.  But /Q is *always* just the inverted state of Q.  So the flipflop will come up with Q low, but also with /Q high.  High is the state needed on the mosfet gate to keep it turned off.  When the first long button press occurs, CLK will go high, and  the state of /Q (high) will be latched via the D pin to Q, which will bring Q high and /Q low, which will turn the mosfet on.  Both Q and /Q change state *immediately after* the rising edge of the CLK.  Nothing happens on the falling edge.  You get a falling edge when the button is released. Then the next long press produces another rising edge, which brings /Q high again, which turns off the mosfet.

Your NPN circuit is just an inverter for Q.  When Q goes high, the NPN brings the mosfet gate low, and vice versa.  But you already have something that always produces  an inverted version of Q, and that's /Q.  It should work exactly the same, but without the extra parts.

I think you would find it really helpful if you could breadboard stuff like this and test it out with through-hole versions of these chips.

Edit:  You could also drive the mosfet gate directly from Q, but you would need to move the R/C over to the /PREset pin so the  flipflop would come up with Q high.

Ok now I'm really confused. This is a p-channel mosfet. My understanding is that you have to drive the gate high to turn it on and allow current to flow from the source to drain.  You're saying it has to have voltage applied to the gate to keep it off, which is incorrect as far as my understanding goes. Unless I'm confused and by high you mean no voltage applied and low means voltage applied? What am I missing here?
 

Offline jfiresto

  • Frequent Contributor
  • **
  • Posts: 819
  • Country: de
Re: Press and Hold Latching Circuit Questions
« Reply #59 on: September 27, 2020, 08:10:29 pm »
A p-channel MOSFET works like a PNP transistor in that you pull the gate toward negative to turn it on.

If you want to learn more, download a copy of Don Lancaster's "CMOS Cookbook" from his website. He wrote it for people wanting to use the then, new and original 4000-series CMOS. Forty odd years later, it still holds up very well as a clear and practical text for learning digital design. You can answer your own question after reading and absorbing chapter one.
-John
 
The following users thanked this post: Kuusou

Offline Peabody

  • Super Contributor
  • ***
  • Posts: 2007
  • Country: us
Re: Press and Hold Latching Circuit Questions
« Reply #60 on: September 27, 2020, 08:59:19 pm »
 Well, both P-channel and N-channel mosfets are turned off if the gate and the source are at the same voltage.  An N-channel mosfet will turn on when the gate voltage goes above the source voltage.  A P-channel mosfet turns on when the gate voltage goes below the source voltage.  So an N-channel mosfet works like an NPN bipolar transistor, and a P-channel mosfet works like a PNP transistor.

So your circuit with the NPN would work (with the resistors added). If Q comes up low, the transistor would be off, and the gate pullup resistor (when added) would bring the mosfet gate up to the same voltage as the source, which turns off the mosfet.

Youtube is your friend.  I'll bet there are many videos there about how D flipflops and mosfets work.
 
The following users thanked this post: Kuusou


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf