# Electrical – Soft latching with button sensing and controlled power-off

arduinolatchmosfetpowertransistors

I'm new to electrical engineering and not yet familiar with all the terminology and methodology, please bear with me.

What the circuit should do

I want a pushbutton to power on the Arduino. Using the same pushbutton I want to send signals to the Arduino (e.g. power off after 2 sec press). Also there has to be a way to programmatically power off after x minutes.

My approach

Below the circuit I build to accomplish this task. My idea was to use a soft latch circuit. Q1 is turned off by the current flowing through R1 and R2 by default. When button 1 is pressed, current flows through Q1, R2, button 1, R3 and to GND. Q1, being activated, in turn activated Q3, which should permanently activate Q1. To "turn Q1 off" I power Q4 to shorten Q3 to GND. sense is there to determine if the button was pressed.

This circuit does not work as it is not latching. Is my approach right, but the circuit wrong, or is there generally a better solution to fulfill my requirements?

The basic circuitry seems reasonable in general principles. However -

• There MUST be a resistor (say 10K) from D13 to Q4 base (the "OFF" line" as the base clamps at well under 1V and overloads the D13 pin. This probably will not cause processor "misbehaviour", but may.

• The S1 to "sense" signalling needs work' and the value of Rs (see below) needs to be specified and to meet certain design requirements.

The sense input will probably be failing to signal the state of S1 once Q3 is on.The value of the sense to ground resistor (call it Rs) is not shown but is important. Too small and sense will not be pulled high initially

• eg if R2 = 10k then the R1/Rs divider will provide 9V x Rs/(Rs+R1) = 0.8v to "sense" when S1 is pressed. When Q3 is operated V_Q3_collector will be ~= 0V and Vsense will be even lower than before when S1 is pressed. So - once the latch is latched the processor will not be able to detect S1 presses.

• if Rs = 100k then when S1 is pressed Vsense = 9V/2 = 4.5V. A 3V3 processor will complain or just expire. If Rs is say 220K then Vsense > 5V when S1 pressed and a 5V processor will be equally set about.

Setting Rs to a "correct" value will allow a high to be signalled initially without damaging the processor, but nothing will currently allow S1 to signal a button press once Q3 is turned on.

Apart from the above, lack of latching suggests that either the latch is not working or that the processor is turning Q4 on when it ought not to

Certain conditions need to be met to allow the overall system to function.
The 'task' is to establish which of these (one or more) are not being met.
Guidelines are provided below t help yo to establish what is wrong.