I was making a board with an atmega328 mcu (to be used with Arduino libraries) to do some one wire communication stuff. Since I was etching the board anyway, I decided to try and implement a simple software off functionality, without putting much thought into it. Once I etched and assembled the board, my one-wire stuff works fine, but the software off circuit does not. I was poking around and I can't understand why it does not work.
The idea is that pushing a momentary push button (for 2-3 seconds), will connect the battery to the 5V regulator which in turn powers the MCU. The first thing the MCU does is set a digital pin high (line labeled PWR in the below diagram), to latch the N-MOSFET Q1 and bypass the push button switch. When the switch is released, the circuit should remain powered through the MOSFET.
What in reality happens is that pushing the pushbutton powers up the board as expected. The gate of the FET is driven to 5V by the MCU as expected, but as soon as the pushbutton is released, everything turns off. It seems that the FET is not bypassing the pushbutton for some reason, but I can not understand why? The FET Vgs is 1.8V, R6, R7 and D1 are there so I can use another push on the button to generate an interrupt on the BTN line, then drive the PWR line low and switch off the board.
So the question is what is wrong here? Why doesn't Q1 MOSFET stay latched once the pushbutton (connected to PWRSW header) is released? I'm certain it is not something complicated, but I just can not understand why - perhaps because I've been staring at it for too long...
Answer
+5V with respect to GND is not high enough to turn on Q1, which is an N-channel MOSFET in the original schematic. The O.P. was thinking in the right direction, when he had looked-up the VGS. But with respect to what is the VGS taken? It's not taken with respect to GND. It's taken with respect to MOSFET's source is at +7.5V (or some such voltage required for the 7805). So, the if you drive the gate to +5V, then VGS < 0. It's negative. The N-channel MOSFET doesn't stay on, because it doesn't turn on in in the first place.
A high-side switch like this is usually done with a P-channel MOSFET and a second small transistor to control its gate. Like so:
(I didn't redraw all of the original circuit, but this should be enough to get the idea across.)
No comments:
Post a Comment