Author Topic: 1 button power on\off + UI button  (Read 1849 times)

0 Members and 1 Guest are viewing this topic.

Offline ignislionTopic starter

  • Contributor
  • Posts: 29
  • Country: ru
  • Professional programmer, poor EE novice.
1 button power on\off + UI button
« on: April 09, 2019, 12:48:14 pm »
I am in the process of making a very simple beginner project in a somewhat serious manner with own PCB, plexiglass cover, lion battery with charger etc. all fancy and shining ready-to-use device, no more breadboard+modules crap. Just for fun and practice.

It is basically a bunch of sensors over atmega8 and display. Because you know everyone needs to know how many moisture you have in your air sometimes =)

What I am interested to do is 1 button device. 1 click to power on, then clicks to switch what to display then hold on to power off. To make this I mix some tricks I already know with parts I own.

The idea is when you press the button current goes to VCC through diode and powers on the controller which then pulls up MOSFET by PCON pin. then you can use the button to interact with SW pin by clicking. And if you press the button for a couple of seconds PCON goes low and power switches off.

Well, my question is "am I doing it right?". Because for me as a beginner it seems a little too easy to work fine =)

Thank you for your time!
 

Offline ignislionTopic starter

  • Contributor
  • Posts: 29
  • Country: ru
  • Professional programmer, poor EE novice.
Re: 1 button power on\off + UI button
« Reply #1 on: April 09, 2019, 12:54:38 pm »
Sorry I had to clarify +5V is a source of power VCC is just going to the controller and other stuff.
 

Offline ignislionTopic starter

  • Contributor
  • Posts: 29
  • Country: ru
  • Professional programmer, poor EE novice.
Re: 1 button power on\off + UI button
« Reply #2 on: April 09, 2019, 12:55:48 pm »
I swear there was someone's comment!
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 13216
Re: 1 button power on\off + UI button
« Reply #3 on: April 09, 2019, 01:01:48 pm »
That's not going to work unless you can drive PCON to about +7V when you want the BSH105 NMOSFET to stay on.  Its typ. gate threshold voltage is 0.58V, and to get it turned hard on, the gate needs to be  at least double the threshold voltage above the source, which is providing the MCU Vcc.

I assume SW is meant to be an output going to a MCU input pin.   The 100nF filtering cap  needs to go to ground not +5V_in otherwise you risk blowing the input pin when +5V is first applied, before the button is pressed and the MCU is powered.
 
The following users thanked this post: ignislion

Offline ignislionTopic starter

  • Contributor
  • Posts: 29
  • Country: ru
  • Professional programmer, poor EE novice.
Re: 1 button power on\off + UI button
« Reply #4 on: April 09, 2019, 01:27:45 pm »
Oh, I see.

So maybe use p-channel MOSFET?

The capacitor is a sad mistake.
 

Offline ignislionTopic starter

  • Contributor
  • Posts: 29
  • Country: ru
  • Professional programmer, poor EE novice.
Re: 1 button power on\off + UI button
« Reply #5 on: April 09, 2019, 01:34:35 pm »
I even can get IRLML5203 -
VGS ± 20 V
VGS(th)  -1.0 ––– -2.5 V
ID @ TA = 25°C -3.0
RDS(on)  98mOhm VGS = -10V, ID = -3.0A
It looks fine for this usage. Or I cant see something?
 

Offline AndyC_772

  • Super Contributor
  • ***
  • Posts: 4315
  • Country: gb
  • Professional design engineer
    • Cawte Engineering | Reliable Electronics
Re: 1 button power on\off + UI button
« Reply #6 on: April 09, 2019, 01:39:27 pm »
Usually this kind of thing is done by leaving the microcontroller permanently powered, but in a very low power sleep state. Most have a mode in which they can either run from a slow internal clock, or are stopped entirely but can wake up on an interrupt (eg. from an input being switched).

The trick then is to ensure that the rest of the circuit can also sit in a state where it draws essentially zero power. Switching the supply can be one way to do this, but it's not the only one.

What's the power source, and how low does the current draw need to get?
 
The following users thanked this post: ignislion

Offline ignislionTopic starter

  • Contributor
  • Posts: 29
  • Country: ru
  • Professional programmer, poor EE novice.
Re: 1 button power on\off + UI button
« Reply #7 on: April 09, 2019, 02:02:45 pm »
The power source is one cell of 18650 Li-ion and some step-up circuitry. Being honest I am not sure how low I need to go. essentially I just trying to do my best and see. The rest of the components needs to be powered off in some way because it is sensors with heaters and 0.36" LED display so there is no way to control its power consumption internally. Maybe I can use a MOSFET to cut power off the periphery and switch data pins to HIgh-Z. I think I going to try this on the breadboard.
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 13216
Re: 1 button power on\off + UI button
« Reply #8 on: April 09, 2019, 03:20:00 pm »
Show us the proposed system lineup - at least a full block diagram + schematics of interesting bits like the boost converter that provides the +5V supply, and the power switching circuit.

If you get the power switching wrong, it may appear to work, but actually leave a small load on the 5V rail when off.  The result would be the boost converter would slowly drain the 18650 cell, which would be disastrous if its ever stored with low charge and the cell isn't protected by a low voltage cutoff.
 

Offline ignislionTopic starter

  • Contributor
  • Posts: 29
  • Country: ru
  • Professional programmer, poor EE novice.
Re: 1 button power on\off + UI button
« Reply #9 on: April 12, 2019, 09:09:23 am »
Sry for a delayed answer! Here is what I have for a moment:

https://easyeda.com/ignisilion/weather
 

Offline ignislionTopic starter

  • Contributor
  • Posts: 29
  • Country: ru
  • Professional programmer, poor EE novice.
Re: 1 button power on\off + UI button
« Reply #10 on: April 22, 2019, 09:43:27 pm »
Well I havent done yet! =)


First of all, I am very curious why I ever have seen only p-MOSFET, "positive side" power on schemes? N-mosfets have better performance and it seems to me that there is not so must difference on which side of load to operate.
I kinda draw some schema and going to test it on weekend. Maybe you can say to me why I am wrong before I going to waste time.

Another question is it ok to just connect external 5v power directly to the controller when the battery is charging?? Like in screenshot. I need to use LDO in between but overall is it OK to connect 5v after step-up? it has diode anyway so i thought it is going to work.

Here is all the schema I have at the time: https://easyeda.com/ignisilion/weather
 

Offline ignislionTopic starter

  • Contributor
  • Posts: 29
  • Country: ru
  • Professional programmer, poor EE novice.
Re: 1 button power on\off + UI button
« Reply #11 on: June 03, 2019, 04:38:51 pm »
As for the power switching circuit here is on what I am stopped:
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 20360
  • Country: gb
  • 0999
Re: 1 button power on\off + UI button
« Reply #12 on: June 03, 2019, 04:53:35 pm »
In order for an N-MOSFET to switch the positive side, its gate voltage needs to be above its source voltage, which is connected to the load. If there's no higher voltage in the circuit, then it would need to be generated using some kind of boost converter, which is costly and increases complexity. It's just cheaper to use a P-MOSFET or an N-MOSFET and switch the negative side.

This sounds similar to another recent thread. Refer to the link below. It might be relevant.
https://www.eevblog.com/forum/beginners/push-button-power-circuit-for-arduino-trying-to-modify-it-for-12v-input/
 

Offline ignislionTopic starter

  • Contributor
  • Posts: 29
  • Country: ru
  • Professional programmer, poor EE novice.
Re: 1 button power on\off + UI button
« Reply #13 on: June 04, 2019, 08:05:12 pm »
Sorry, my message was badly composed. The stuff with VGS +/- is understood. My question was why i have seen so much pchannel high side switches other than nchannel low side? Because n mosfets have better rds on. It looks like i canr see something more
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9964
  • Country: us
Re: 1 button power on\off + UI button
« Reply #14 on: June 04, 2019, 11:50:47 pm »
Probably because we don't want any voltage drop when pulling to ground.

 
The following users thanked this post: ignislion

Offline ignislionTopic starter

  • Contributor
  • Posts: 29
  • Country: ru
  • Professional programmer, poor EE novice.
Re: 1 button power on\off + UI button
« Reply #15 on: June 05, 2019, 07:17:29 am »
That's a very good reason. Thank you!
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf