Press and Hold Latching Circuit Questions - Page 1
Forum section: electronics / projects

author: Kuusou
author_rank: Regular Contributor
timestamp: September 16, 2020, 07:33:04 am
content: So I'm attempting to layout this circuit I found fromhttp://www.discovercircuits.com/H-Corner/Press-and-Hold-Latching-Circuit.htminto my PCB layout for a project of mine. I've been looking for a long press on AND off latch and this is the only circuit I've personally come across to do what I want. The following text is from the site:"A Discover Circuits visitor needed a latch circuit which could operate using a power supply voltage ranging from 3v to 24v. He wanted to use a tiny pushbutton switch to turn on and off power to a load. However, he wanted a 2 second delay between the switch activation and the state change of the output. The delay would prevent accidental activation of the circuit from a quick push button switch closure. The circuit below performs this function. A dual Schmitt trigger inverter IC and a single flip/flop IC form the heart of the circuit. The A1A section performs the 2 second delay function.The Q output of the flip/flop is inverted by the A1B inverter section and fed to the flip/flop’s data input. This configuration forms a data type flip/flop which changes state with each leading edge pulse from the A1A inverter. The transistor chosen should be able to handle about an Amp of current. I used a 3.3v shunt type voltage regulator, which draws about 15ua of current from the supply voltage to limit the voltage fed to the circuit to 3.3v but the circuit can operate fine from a 3v supply. In fact, the latch circuit will operate below 1v but at such a low voltage the Q1 transistor will not fully turn on. If the supply voltage is limited to 5v, the shunt regulator is not needed and the circuit will operate while drawing a very low current of about 1ua."Being new to PCB design and electronics in general, I have several questions. My project is powered from a single cell lipo that goes to this switch, and then to a boost converter which will boost the voltage up to 5 volts to run everything. It appears that in this original schematic they had a need for up to 24v, and as a result of that they've used a "shunt type voltage regulator", which is suppose to limit the current to the switch to 3.3V. It says you can remove this if the voltage is limited to 5V. So I believe I've made this change correctly but would like someone to confirm.My second question is concerned with my PCB layout. In the schematic it has 3.3V going to each of the IC's but no decoupling caps. I've included those caps in my schematic, are they correct and am I feeding power to them properly on the PCB layout? B1 is the battery terminal so the lipo will be directly connected to those pads.My other questions is the 4 wire junction of the schematic, In my schematic that would be the junction of D5, R5, and C3 leading to pin 1 of U4. These are always rather confusing to me and I'm unsure exactly how to lay this out, so I've used a via. Is this acceptable/will it work?So basically I'm just hoping someone could take a look over my PCB layout and make sure I'm not making any obvious mistakes. I should mention that the green pads on the PCB layout image are the switch for the circuit which is located on the underside of the board. R5 IS connected to the switch, its just the trace is underneath another one on the top layer so its not visible.Below is my list of components I'll be using, as far as I can tell they appear to match whats in the original schematic.Gate/Inverter:https://lcsc.com/product-detail/Gates-and-Inverters_Texas-Instruments_SN74LVC2G14DBVR_Texas-Instruments-Texas-Instruments-SN74LVC2G14DBVR_C12401.htmlFlip Flop:https://lcsc.com/product-detail/Flip-Flops_Texas-Instruments_SN74LVC1G79DBVR_Texas-Instruments-Texas-Instruments-SN74LVC1G79DBVR_C42878.htmlDidoe:https://lcsc.com/product-detail/Switching-Diode_1N4148W_C81598.html/?href=jlc-SMTMOSFET:https://lcsc.com/product-detail/MOSFET_Shikues-FDN337N_C475694.html/?href=jlc-SMTBelow is my current schematic and PCB layout.

author: ledtester
author_rank: Super Contributor
timestamp: September 16, 2020, 07:46:04 am
content: QuoteWill this also shutdown the boost converter?

author: Kuusou
author_rank: Regular Contributor
timestamp: September 16, 2020, 07:47:22 am
content: I believe so, this is suppose to be a soft latch switch, so one button to control both on and off functions. Q1 leads to the boost converter although the silk screen is very tiny for some reason on the pcb layout. I hope i'm not missing something obvious and this wouldn't actually turn it off! That's why I'm posting here for help lol

author: strawberry
author_rank: Super Contributor
timestamp: September 16, 2020, 08:59:19 am
content: SN74LVC1G80 or connect Data to Q1 drain through resistor

author: Zero999
author_rank: Super Contributor
timestamp: September 16, 2020, 09:52:10 am
content: Why not use a microcontroller and a suitable low drop-out regulator? There are plenty of cheap, six pin MCUs available: ATtiny4 and PIC10F200 spring to mind. The NCP730 is a decent LDO, capable of working up to 38V and will withstand surges of up to 40V.

author: badgerthing
author_rank: Contributor
timestamp: September 16, 2020, 11:09:52 am
content: I can't speak for the circuit myself, but why have you used two dual inverter ICs, but only used one inverter in each?Just use a single LVC2G14.

author: Zero999
author_rank: Super Contributor
timestamp: September 16, 2020, 01:03:18 pm
content: Even if you don't want to use an MCU, the circuit is much more complicated than necessary. Use the 74LVC1G74, which has Schmitt trigger inputs and the LVC2G14 is superfluous. I'd still recommend a LDO, over a shunt regulator.https://assets.nexperia.com/documents/data-sheet/74LVC1G74.pdf

author: ledtester
author_rank: Super Contributor
timestamp: September 16, 2020, 03:56:59 pm
content: Just noticed that VCC of U6 is not connected in your schematic.

author: ledtester
author_rank: Super Contributor
timestamp: September 16, 2020, 04:02:17 pm
content: A question about the original design...QuoteInstead of an inverter could one use the /Q output of the flip-flop? Or are there other considerations like what happens at power-up?

author: Zero999
author_rank: Super Contributor
timestamp: September 16, 2020, 07:51:59 pm
content: Quote from: ledtester on September 16, 2020, 04:02:17 pmThe 74LVC1G79 doesn't have an inverting output pin. It's the wrong IC for the job.https://datasheet.lcsc.com/szlcsc/1811011912_Texas-Instruments-SN74LVC1G79DBVR_C42878.pdfEDIT:Here's a schematic with the 74LVC1G74.

author: Kuusou
author_rank: Regular Contributor
timestamp: September 16, 2020, 11:15:07 pm
content: Wow thanks for catching that. So the above schematic looks simpler and uses less parts and will have the same desired effect of a long press to turn on and off?

author: Kuusou
author_rank: Regular Contributor
timestamp: September 16, 2020, 11:17:27 pm
content: Quote from: Zero999 on September 16, 2020, 01:03:18 pmWell I'm not sure what you mean. In my design i'm not using the shunt regulator because the board is powered by a 3.3V lipo and goes to this switch, then to a boost converter to run everything at 5V so I removed that aspect of the design. Also my concern with using a MCU would be programming the chip.

author: Kuusou
author_rank: Regular Contributor
timestamp: September 16, 2020, 11:35:18 pm
content: Quote from: Zero999 on September 16, 2020, 07:51:59 pmOk so I'm confused by this schematic of yours. It appears that you're using the IEC logic symbol from the datasheet but I'm not sure how to match that up with the IC's actual pin configuration. I'm guessing 1D is the data input, C1 is suppose to be the clock input? R would be the asynchronous reset-direct input and S would be the asynchronous set-direct input? I'm unsure which pin is suppose to lead to the gate of the MOSFET or which pin is leading from the ic back into the data input.Also why are there two 3.3V going to the IC?Also I'm not able to find that exact IC however I did find the following that's available at JLCPCB:https://lcsc.com/product-detail/74-Series_TI_SN74LVC1G74DCUR_SN74LVC1G74DCUR_C70285.html/?href=jlc-SMTWould this work? It appears to be relatively the same, the other aspect I'm confused about is that the datasheet lists another IC in a typical power button circuitSorry for what I'm sure are noobish questions but I REALLY appreciate all the help!

author: ledtester
author_rank: Super Contributor
timestamp: September 17, 2020, 01:44:38 am
content: QuoteThe little right-angle triangles just indicate that those pins are active-low. The outputs on the right side of the chip are Q and /Q (has the triangle next to it).The "10.2 Typical Power Button Circuit" is basically the same, but it has a nice feature in that it ensures the flip-flop is cleared at power up through the RC-timer at /CLR. There is a similar RC-timer at the A input of the SN74LVC1G17.That prompts the question -- what behavior do you want when power is applied? Should the switch be off and the user has to press the button to turn it on, or should power be immediately applied to the application?The SN74LVC1G17 squares up the push button input. It might not be needed. You will need R2, D1, R3, C2 from the original and Zero999's circuit to get the 2 second delay - those component replace the RC timer at input A.

author: Kuusou
author_rank: Regular Contributor
timestamp: September 17, 2020, 02:07:42 am
content: Quote from: ledtester on September 17, 2020, 01:44:38 amSo why the double 3.3V inputs?I'm not sure I understand the question. This switch is between the battery and the boost converter. So once I hook the battery up to the terminals the user will only have the button to control it. It's either in an on or off state correct? If I hook the battery up and the circuit powers up I'll simple press the button to turn it off and it will remain that way. I guess the only thing I could see is if the battery fully drained and the user went to plug it in, could that cause the entire device to turn on? That wouldn't be desired however its not exactly make or break. Ideally that wouldn't happen though.

author: ledtester
author_rank: Super Contributor
timestamp: September 17, 2020, 02:26:34 am
content: Quote from: Kuusou on September 17, 2020, 02:07:42 amThe /R and /S pins are digital inputs. Connecting them to 3.3V sends a logical HI signal to them.QuoteWhen you apply power to the circuit (i.e. connect it to a battery pack or some other DC power source) the flip-flop will assume either a 0 or 1 output. There are three possibilities:- you can force it to be a 0 at power up- you can force it to be a 1 at power up- you can leave things to chanceIf the flip-flop is a 0 at power up the user will have to press the button to turn the MOSFET on.If the flip-flop is a 1 at power up the MOSFET will turn on and power will be applied to the rest of the application immediately.

author: Kuusou
author_rank: Regular Contributor
timestamp: September 17, 2020, 02:52:15 am
content: Quote from: ledtester on September 17, 2020, 02:26:34 amSo if the flip-flop is at 1 then after the application is turned on once the battery is connected won't simply pressing the button again turn it off? Also how to determine which state is set? I guess it would be best to have it set to 0 so that in the invent it loses all power it reverts to being off rather than on.

author: ledtester
author_rank: Super Contributor
timestamp: September 17, 2020, 03:09:28 am
content: QuoteThe flip-flop doesn't have any state when there is no power. It doesn't remember anything after you disconnect power.When you apply power the flip-flop will either assume a state of 0 or 1. You can influence what its initial state is at power up through an RC-timer like the /CLR pin has in the "10.2 Typical Power Button" schematic.Note that this power-up state is the state of the flip-flop before the user has pressed any buttons.If you force the power-up state to be a 0 then once the user inserts batteries or plugs the device into a wall adaptor the user will still have to press the button to "turn it on".Otherwise, the application will turn on once the device goes form an un-powered state to a powered state (i.e. you insert the last needed battery or plug it into an AC adaptor.)

author: Kuusou
author_rank: Regular Contributor
timestamp: September 17, 2020, 04:17:15 am
content: I'm completely unsure how I'm suppose to determine the value for the resistor and cap on the RC circuit (R6 & C13) to ensure that the CLR pin stays at 0 on power up. I just picked those values but I have no ideaI've checked the datasheet herehttps://datasheet.lcsc.com/szlcsc/Texas-Instruments-TI-SN74LVC1G74DCUR_C70285.pdfand can't find any mention of how to determine the values.

author: ledtester
author_rank: Super Contributor
timestamp: September 17, 2020, 04:54:58 am
content: It will be about R*C (R measured in ohms, C measured in Farads).1K * 100nF = 100 microsecondsThe same applies to the RC-timer at the input when the switch is closed:4.7M * 470nF = 2.2 secs.And at power up the R4 and C3 will produce a rising edge of CLK after:100K * 470 nF = 47 millisecondsGiven that, I might change the /CLR RC timer (R6, C13) to 100 milliseconds so that /CLR remains low until after the R4 and C3 produce the rising edge on CLK.

author: Kuusou
author_rank: Regular Contributor
timestamp: September 17, 2020, 05:09:04 am
content: Quote from: ledtester on September 17, 2020, 04:54:58 amOk I think I get it. So if I change the resistor value from 1k to 100K and the capacitor to 100nF that would produce 100 milliseconds correct?

author: Kuusou
author_rank: Regular Contributor
timestamp: September 17, 2020, 05:21:03 am
content: Another issue I'm just now realizing is that because this device is the switch between my battery and the boost converter won't that be an issue in terms of amps going through the system? This board can draw up to about 1.3 amps, wouldn't that fry this IC?

author: ledtester
author_rank: Super Contributor
timestamp: September 17, 2020, 05:46:00 am
content: Which IC? Only the MOSFET will be handling large currents.

author: Kuusou
author_rank: Regular Contributor
timestamp: September 17, 2020, 05:48:35 am
content: Quote from: ledtester on September 17, 2020, 05:46:00 amI guess I'm confused because the 3.3V from the battery goes to the IC and through it, then to the MOSFET...maybe i'm missing something obvious but wouldn't the draw from the boost converter damage the IC or you're saying the MOSFET would be what takes the brunt of that? Sorry i'm still a noob when it comes to understanding this stuff

author: ledtester
author_rank: Super Contributor
timestamp: September 17, 2020, 05:52:35 am
content: Yes - the flip-flop controls the MOSFET, but the current from your application circuit only flows through the MOSFET.

author: Kuusou
author_rank: Regular Contributor
timestamp: September 17, 2020, 05:54:50 am
content: Quote from: ledtester on September 17, 2020, 05:52:35 amI guess i'm just confused because the MOSFET controls the voltage and current flow between the source and drain. Ok but in this schematic the source is just connected to ground, shouldn't it be connected to the 3.3V of the battery?

author: ledtester
author_rank: Super Contributor
timestamp: September 17, 2020, 06:22:36 am
content: Here is a crude schematic:The return for the boost converter needs to be connected to GND. If it was connected to 3.3V there wouldn't be any voltage potential for it to work with.

author: ledtester
author_rank: Super Contributor
timestamp: September 17, 2020, 07:04:42 am
content: I think it would be really helpful to prototype this up on a breadboard and experiment with it.Get some DIP package versions of these gates so they are easy to use on a breadboard, like:74HC74 for the D flip-flop (you'll get two in this package)74HC14 for the Schmitt triggersI couldn't find any DIP package Schmitt trigger buffers, but you can make one by connecting two Schmitt trigger inverters (i.e. the 74HC14 chip) in series.Then you can play with the R and C values, try different MOSFETs, etc.

author: Kuusou
author_rank: Regular Contributor
timestamp: September 17, 2020, 08:05:12 am
content: Quote from: ledtester on September 17, 2020, 06:22:36 amOk so your schematic makes sense to me, I've obviously got this setup wrong. I'm not sure how to connect the 3.3V from the battery to the boost converter correctly. Below is my current schematic. How should I connect the 3.3V to the boost converter as in your example schematic.

author: ledtester
author_rank: Super Contributor
timestamp: September 17, 2020, 10:19:31 am
content: Your boost converter has an enable pin -- just connect it to the Q output of the flip-flop and forget the MOSFET.

author: Zero999
author_rank: Super Contributor
timestamp: September 17, 2020, 12:54:39 pm
content: Just a couple quick notes:Yes, connecting an RC circuit to the reset pin will ensure it always starts with the output off. The reset pin needs to be pulled up via a resistor, with the capacitor going to 0V and it should have a considerably longer time constant, than R"*C2.The circuit I posted will only reliably work with a flip-flop with Schmitt trigger inputs.It's odd. The Texa Instruments data sheet for the SN74LVC1G74 says nothing about Schmitt trigger inputs, but nexperia's data sheet says it has them:https://datasheet.lcsc.com/szlcsc/1806150327_Texas-Instruments-SN74LVC1G74DCUR_C70285.pdfhttps://assets.nexperia.com/documents/data-sheet/74LVC1G74.pdfThe Philips datasheet for the 74HC(T)74, which is also available in through hole, says it has Schmitt trigger inputs.http://i2c2p.twibright.com/datasheet/74HC_HCT74_3.pdfThe 74HCS74 is another example of a D flip-flop, with Schmitt trigger inputs.https://www.ti.com/lit/ds/symlink/sn74hcs74-q1.pdf

author: Kuusou
author_rank: Regular Contributor
timestamp: September 17, 2020, 03:36:55 pm
content: Quote from: ledtester on September 17, 2020, 10:19:31 amOk but I don't understand how the 3.3V is suppose to connect to the boost converter. If the Q output of the flip-flop is just directly connected to the boost converter how is it going to draw up to 1.5 amps of current??? Wouldn't it have to go through that IC?how does this work like in your example, where does that connection line go???

author: Kuusou
author_rank: Regular Contributor
timestamp: September 17, 2020, 03:39:13 pm
content: Quote from: Zero999 on September 17, 2020, 12:54:39 pmOk so this IC won't work. I'm only able to use JLCPCB components so I'm limited in that respect. I've foundhttps://lcsc.com/product-detail/74-Series_Nexperia_74AHC74PW-118_74AHC74PW-118_C71900.html/?href=jlc-SMT,its a dual flip flop but should do the same job.So how much longer should the time constant be? Longer than 100 milliseconds, longer than 2 seconds???

author: S. Petrukhin
author_rank: Super Contributor
timestamp: September 19, 2020, 02:12:17 pm
content: The most reliable way is to use a switch or a button with a lock.But there is another good way: the button simply supplies power to the circuit, the MCU turns on and picks up the button using a simple MOSFET key. This way the processor will be able to turn itself off. If you need to turn off the same button, then it should be applied to the input of the processor so that it can detect pressing during operation and turn off the power. When connecting the battery directly to the MCU, it is more convenient to use deep sleep/stop and the wake button.And there is also a specialized simple chip:https://lcsc.com/product-detail/Interface-Specialized_Maxim-Integrated-MAX16054AZT-T_C79401.htmlit is very comfortable, small and fulfills all your wishes.

author: Zero999
author_rank: Super Contributor
timestamp: September 20, 2020, 08:34:37 am
content: Quote from: Kuusou on September 17, 2020, 03:39:13 pmThat IC should be fine.Quote from: datasheetQuoteIt needs to be longer than 100k*470nF, to ensure it ignores the pulse from the capacitor at the input charging up.

author: jfiresto
author_rank: Frequent Contributor
timestamp: September 20, 2020, 09:54:05 am
content: Quote from: Zero999 on September 20, 2020, 08:34:37 amYou might double-check the data sheet. A "slower" clock input might still need an order 1 µs rise and fall time to satisfy the internal, M/S clocked logic block.

author: Zero999
author_rank: Super Contributor
timestamp: September 20, 2020, 10:50:30 am
content: Quote from: jfiresto on September 20, 2020, 09:54:05 amWhy? The Schematic shows a Schmitt trigger on the clock input pin. See page 3, figure 4. A slow rising/falling clock would be internally converted to a fast/rising falling complementary clock.

author: S. Petrukhin
author_rank: Super Contributor
timestamp: September 20, 2020, 11:00:55 am
content: Guys, don't waste your time. Explore the MAX16054.https://lcsc.com/product-detail/Interface-Specialized_Maxim-Integrated-MAX16054AZT-T_C79401.html

author: jfiresto
author_rank: Frequent Contributor
timestamp: September 20, 2020, 11:57:22 am
content: I was studying the MAX16054 on/off (and MAX6816-MAX6818 momentary) datasheets a few days ago to get a feel for a longest, tolerable switch debouncing delay. I would think 80 ms after the last switch transition might start to be noticeable.

author: jfiresto
author_rank: Frequent Contributor
timestamp: September 20, 2020, 12:01:23 pm
content: Quote from: Zero999 on September 20, 2020, 10:50:30 amBecause I do not see the word "unlimited", and when I design, I think Murphy was an optimist.

author: Zero999
author_rank: Super Contributor
timestamp: September 20, 2020, 02:35:58 pm
content: Quote from: jfiresto on September 20, 2020, 12:01:23 pmThat's why I initially recommended the 74HCS74, which is available from Digikey and other suppliers.https://www.digikey.com/product-detail/en/texas-instruments/SN74HCS74DR/296-SN74HCS74DRCT-ND/12352516Presumably the original poster can't buy from DK? If so, I'd buy some of the NXP parts and test them. If the data sheet is correct, then they should work with unlimited rise and fall times of the input clock pulse.

author: jfiresto
author_rank: Frequent Contributor
timestamp: September 20, 2020, 03:09:52 pm
content: Quote from: Zero999 on September 20, 2020, 02:35:58 pmThat one looks good, but is it special? I can find it in stock at Digikey and Mouser, but that is about it. None of the half dozen European distributors I use carry it.EDIT: Ahhh, it is part of a new logic family, since May 2019, with unrestricted Schmitt trigger inputs. That could explain why many do not (yet?) carry it.

author: S. Petrukhin
author_rank: Super Contributor
timestamp: September 20, 2020, 03:20:17 pm
content: Quote from: jfiresto on September 20, 2020, 11:57:22 amDo you think there is a need to press the power button faster than 10 times per second? Or the 50 mS power-on delay will be visible?

author: jfiresto
author_rank: Frequent Contributor
timestamp: September 20, 2020, 03:27:28 pm
content: Probably not for this application, but in my case, the 80 ms adds to a camera's shutter delay.

author: S. Petrukhin
author_rank: Super Contributor
timestamp: September 20, 2020, 03:51:49 pm
content: Quote from: jfiresto on September 20, 2020, 03:27:28 pmSo you use an RC circuit with a sufficiently large resistance, it will give a delay also.If time is critical for you, use the switch contacts button with RS-trigger (latch).Debounsing always requires a time delay.If you can react to the first front to turn it on instantly, you will have to be deaf for a while to turn it off.

author: jfiresto
author_rank: Frequent Contributor
timestamp: September 20, 2020, 05:19:43 pm
content: Quote from: S. Petrukhin on September 20, 2020, 03:51:49 pmI did as you suggest and first used an SPDT multimec NCNO push button to drive an S-R latch. After a bit of button pushing, confirmed with historical research, I changed to a lighter, 2 Newton SPST switch, an RC filter and a schmitt trigger block with a typical 20 ms and worst case 60 ms filter delay. These delays should be much shorter than waiting 20–80 ms after the final switch transition, as the above Maxim parts do, since any previous bounces will have already pushed the schmitt trigger partway toward the final input threshold. I mention this as something for the OP to ponder – if he is in to that.

author: Kuusou
author_rank: Regular Contributor
timestamp: September 25, 2020, 11:34:38 pm
content: Thanks for all the help guys, and sorry for the delayed response, I've been busy with work.Quote from: S. Petrukhin on September 20, 2020, 11:00:55 amMy issue with this IC is it's extremely expensive for what it does, in fact its more expensive than the Atmega328P, because of that I'd rather not go this route.Below is my current set up, I've found a cheap Schmitt trigger IC from JLCPCBhttps://lcsc.com/product-detail/Logic-ICs_ON-Semicon_NC7S14M5X_ON-Semicon-ON-NC7S14M5X_C7416.html/?href=jlc-SMTI believe would allow me to usehttps://lcsc.com/product-detail/74-Series_TI_SN74LVC1G74DCUR_SN74LVC1G74DCUR_C70285.html/?href=jlc-SMTboth of these components together only cost about $0.45.My main concern is whether or not I've got the schematic set up properly. Would using the schmitt trigger IC allow me to use the SN74LVC1G74DCUR? It was suggested to forgo the MOSFET all together since the boost converter IC (FPS291LR-G1) has an enable pin. I also had the Vcc line for the boost converter set up incorrectly in my previous schematics I believe. Can someone confirm that it is correct to run a separate 3.3V line to the Vcc line of the boost converter IC and then use the SN74LVC1G74DCUR turn on and off the enable pin of the boost converter IC? Or is this just going to switch the power from 3V to 5V and still have power running to the rest of the board?

author: Zero999
author_rank: Super Contributor
timestamp: September 26, 2020, 04:02:49 pm
content: I don't see why that wouldn't work.My advice would be to build it on a bread board or strip board first. Use DIL adaptor boards for the SMT components, or glue them to the board and connect the pins with solderable enamelled copper wire.

author: Kuusou
author_rank: Regular Contributor
timestamp: September 26, 2020, 07:44:04 pm
content: Quote from: Zero999 on September 26, 2020, 04:02:49 pmWell 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

author: julian1
author_rank: Frequent Contributor
timestamp: September 26, 2020, 08:27:22 pm
content: Quote from: Kuusou on September 26, 2020, 07:44:04 pmYes, 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.

author: Kuusou
author_rank: Regular Contributor
timestamp: September 26, 2020, 09:59:25 pm
content: Quote from: julian1 on September 26, 2020, 08:27:22 pmI'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.

author: Kuusou
author_rank: Regular Contributor
timestamp: September 26, 2020, 10:00:08 pm
content: I think I've figured out how to cut off power to the entire boost converter circuit using the schematic below.I'm using aBJTwhich has its base connected to the Q pin of the flip flop. Which is has its collector attached to the gate of aP-Channel MOSFETwhich 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.

author: Peabody
author_rank: Super Contributor
timestamp: September 27, 2020, 01:48:59 am
content: 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.

author: ledtester
author_rank: Super Contributor
timestamp: September 27, 2020, 02:40:13 am
content: 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.QuoteWhat about a slide switch with a shorter "knob" like this:https://www.digikey.com/product-detail/en/c-k/S202131SS03Q/CKN11024-ND/3754439Or 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

author: Kuusou
author_rank: Regular Contributor
timestamp: September 27, 2020, 02:50:52 am
content: Quote from: ledtester on September 27, 2020, 02:40:13 amThat'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

author: Kuusou
author_rank: Regular Contributor
timestamp: September 27, 2020, 03:08:59 am
content: Quote from: Peabody on September 27, 2020, 01:48:59 amThanks for your response. I was trying to follow this circuit layoutand 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?

author: Zero999
author_rank: Super Contributor
timestamp: September 27, 2020, 09:45:18 am
content: Quote from: julian1 on September 26, 2020, 08:27:22 pmSorry, 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_converterQuote from: Kuusou on September 26, 2020, 10:00:08 pmWhy 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.

author: Peabody
author_rank: Super Contributor
timestamp: September 27, 2020, 02:34:43 pm
content: Quote from: Kuusou on September 27, 2020, 03:08:59 amYou 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.

author: Kuusou
author_rank: Regular Contributor
timestamp: September 27, 2020, 07:39:51 pm
content: Quote from: Peabody on September 27, 2020, 02:34:43 pmOk 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?

author: jfiresto
author_rank: Frequent Contributor
timestamp: September 27, 2020, 08:10:29 pm
content: 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 copyof 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.

author: Peabody
author_rank: Super Contributor
timestamp: September 27, 2020, 08:59:19 pm
content: 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.