Your favorite simple soft switch IC circuit - Page 1
Forum section: electronics / general

author: Skotosman
author_rank: Newbie
timestamp: June 17, 2025, 05:33:31 am
content: I am trying to make a simple soft switch IC circuit to control a p-MOSFET with a single button at low voltage, say 5V, controlling 5A. No power regulation needed.The desired soft switch behavior is just like your laptop power switch, such as in this Sparkfun MK2 designhttps://www.sparkfun.com/soft-power-switch-mk2-jst-2mm.html(with a lot of components). Times of behavior stated here are approximate.Specs:1. A short button push (~ 1 second) activates the p-mosFET and turns circuit ON.2. A second push activates your microprocessor (GPIO) line to softly turn off the power mosFET under processor control.3. And if things go really bad, or hung, a ~10 sec push of the button forces the p-mosFET off.I first tried a LTC2945 IC and p-mosFET, but while I could adjust caps of time turn ON for the PB, and activate the p-mosFET. It would only RAPIDLY turn OFF with a second PB press despite my best efforts to follow suggested spec sheet designs (or adjusting the second cap). I could not get it to soft turn off with a delay for some reason. Or disable the PB to allow the processor to turn the IC/mosFET off.https://www.analog.com/en/products/ltc2954.htmlThere are many many designs out there, videos and a few posts here.https://www.eevblog.com/forum/activate/?u=1058359;code=0a831f628eSo given the bewildering number of designs out there, can anybody suggest a simple IC to buy that uses just a few component to control the pmosFET, just like the single power button on your PC? What do they use?https://www.newark.com/c/semiconductors-ics/power-management-ics-pmic/drivers-controllers/pushbutton-on-off-controllersAny suggestions?

author: brucehoult
author_rank: Super Contributor
timestamp: June 17, 2025, 06:02:50 am
content: When you can buy an 8 pin microcontroller for $0.10 that needs no external components (internal clock etc), why even bother mucking about with timing things with multiple capacitors etc?

author: Skotosman
author_rank: Newbie
timestamp: June 17, 2025, 03:14:40 pm
content: Sort of like this one?http://www.mosaic-industries.com/embedded-systems/microcontroller-projects/electronic-circuits/push-button-switch-turn-on/microcontroller-latching-on-offAnd the microcontroller model you suggest?https://www.eevblog.com/forum/news/single-button-power-and-input-with-microcontroller/A PIC processor?As opposed to an LTC2955....Definitely cheaper, which is good.Skotosman

author: brucehoult
author_rank: Super Contributor
timestamp: June 17, 2025, 03:50:12 pm
content: That's a very old thread!The modern suggestion would be the $0.10 CH32V003.https://www.aliexpress.com/item/1005004895791296.htmlHmm .. I can't find the 50 packs of CH32V003 now ... but there is now the improved (e.g. 4k RAM instead of 2k) CH32V002 at $6.92 for 50 of the SOIC-8 or $6.29 (!) for 50 of the SOP-16:https://www.aliexpress.com/item/1005008493381343.html

author: brucehoult
author_rank: Super Contributor
timestamp: June 17, 2025, 03:52:31 pm
content: Found the CH32V003 packs here, a little cheaper at $5.26 for 50 of the SOIC-8.https://www.aliexpress.com/item/1005007316245783.html

author: Kasper
author_rank: Frequent Contributor
timestamp: June 18, 2025, 05:15:59 am
content: If your MPU can boot fast enough, you may find it easier if you use it to handle spec 1, the 1s turn on delay.Button press turns on MPU ASAP.When MPU boots, check button state.If button held for >1s, MPU enables PMOS.Else, MPU doesn't enable PMOS and PMOS turns off when button released.May also prefer a load switch or current limiter instead of a PMOS.

author: krish2487
author_rank: Frequent Contributor
timestamp: June 18, 2025, 06:50:31 am
content: Quote from: brucehoult on June 17, 2025, 03:50:12 pmOut of curiosity.. if there is a guide on using gcc to write and compile the code for these mcus??I just pulled the trigger on a 50 pack.. at that price.. its a steal.. and I just wanted to dirty my hands with them.. :-D

author: brucehoult
author_rank: Super Contributor
timestamp: June 18, 2025, 08:15:08 am
content: Quote from: krish2487 on June 18, 2025, 06:50:31 amTons of them. They're very popular. The WCH documentation is pretty good, but when there's a gap you can just refer to STM32 (Arm!) docs for peripherals register definitions etc.Note that you do need the WCH-LinkE programmer as they use a custom 1-wire flashing/debug protocol (no, they can't use Arm's, that's proprietary). You *can* emulate that with a Pi Pico or something, the OpenOCD fork source is available and the protocol is documented, but the official programmers are only a couple of bucks so there's really no point in getting clever when you're new to them.As well as the WCH dev board kit (bundled with a WCH-LinkE) you can also get 4rd party dev boards. I have a bunch of nanoCH32V003 from Muse Lab, which you can also get with their own version of the WCH-LinkE.https://www.aliexpress.com/item/1005005221751705.htmlI see they now also give you a same-price choice of 003 (original) or improved 002 and 004.I got ten of them a couple of years back. They work great and are more breadboard / protoboard / stripboard friendly, or even custom PCB if you prefer to solder a 0.1" DIP module rather than a tiny chip.Our intelligent and handsome host made a video of going in blind and trying to get a CH32V003 dev board going a couple of years back:There are a ton of projects around the internet using them:https://www.olimex.com/Products/Retro-Computers/RVPC/open-source-hardwareThat's running PS/2 keyboard, bit-banged VGA output, and a buzzer all from a single 8-pin MCU as the only active component. (ok ok there's a transistor driving the piezo)That last video is by Charles Lohr who also made his own popular version of the header files, called ch32fun (formerly CH32V003Fun, but now more general)https://github.com/cnlohr/ch32fun

author: krish2487
author_rank: Frequent Contributor
timestamp: June 18, 2025, 08:38:50 am
content: Quote from: brucehoult on June 18, 2025, 08:15:08 amThanks!!I have to order the programmer separately.. or repurpose a pi pico I have with me.. I ll stick with makefiles and CMSIS style header access for now.... I purchased the 002 variant.. and at this price.. its a win win always...and I get to dip my toes into the risc v world..

author: brucehoult
author_rank: Super Contributor
timestamp: June 18, 2025, 08:54:46 am
content: Maybe you already found the Pico code. This seems to be the most active fork:https://github.com/kholia/picorvdI haven't tried this. IMHO the only reason not to use the official programmer is if you don't want to wait a week or two for it to come from China, but if you're waiting for the chips anyway ....A benefit of the Muse Lab version, by the way, is it does flash/debug on one pin and UART on other pins at the same time. The headers let you choose where printf() goes to, the default is PD5 (TX) (and PD6 is default RX).

author: krish2487
author_rank: Frequent Contributor
timestamp: June 18, 2025, 10:00:42 am
content: I think I ll order a programmer as well.. as you said... in for a penny.. in for a pound.. :-D

author: brucehoult
author_rank: Super Contributor
timestamp: June 18, 2025, 10:20:38 am
content: Quote from: krish2487 on June 18, 2025, 10:00:42 amProgrammer and pre-made dev board :-)I remember when that kind of thing was a $500 investment, not $5! And thousands for the compiler.

author: Njk
author_rank: Frequent Contributor
timestamp: June 18, 2025, 12:31:32 pm
content: In my mind, a soft switch is associated with Asterisk and stuff like that. The name seems stolen

author: Buriedcode
author_rank: Super Contributor
timestamp: June 19, 2025, 09:24:51 pm
content: PIC10F for projects that have no MCU, but often they do, so I just use 2 spare IO of the host MCU. A PMOS, NPN, and a few passives.For the PIC years ago as an afternoon project I did a few versions from basic, to ones that detect button patterns to enter a debug mode. But thats more feature-creep that utility.

author: Skotosman
author_rank: Newbie
timestamp: June 20, 2025, 09:10:28 pm
content: Thanks everyone.This is great stuff, and I should use one. The problem is I am working on a main project (with programming and PC board design) and I do not want to get too distracted...Or I will not finish anything.I can get a Pi pico at the Microcenter to burn them I guess. (I know the Picos have microcontrollers in them). Then order a bunch from China (tariff unknown).So I read they run some sort of reduced C I read to program the units..Is there a repository of these reduced C programs for the microcontrollers like what I need for a soft switch?And they are fairly low power in sleep mode for a battery application? (I have a pretty large battery in this project).What do you suggest to gate a pMosFET and a switch- will all the suggestions above work OK, and one wire programming. Or get a programmer from China?Also if this was industrial, how are these guys programmed in mass?

author: Kasper
author_rank: Frequent Contributor
timestamp: June 20, 2025, 11:19:14 pm
content: Does your MPU / PC board boot in under 1 second?

author: brucehoult
author_rank: Super Contributor
timestamp: June 21, 2025, 12:47:01 am
content: Quote from: Skotosman on June 20, 2025, 09:10:28 pmWCH?RISC-V is a full 32 bit, 16 registers (in the 003, 32 in the bigger chips), 3-address, orthogonal, modern RISC instruction set just as capable as MIPS, Arm, i386 (at least the FPU-less versions). It's fully supported by gcc and LLVM and all the dozens of programming languages that use those ecosystems.If you mean PIC then that's a wacky 1970s ISA unfriendly to compilers and stack-based languages such as C. It can be done, but the code (and code density) is just awful.