I have designed a circuit using an N-Channel mosfet as a low side switch controlled by an Attiny13a, but it goes into a half on state when it starts up or I try to turn it off by resetting the MC. I have done a similar thing in the past with a P-Channel, but it is cheaper and easier to get made with the AO3400A mosfet.
Datasheet
https://media.digikey.com/pdf/Data%20Sheets/Alpha%20&%20Omega/AO3400A_ds.pdfAny ideas what I am doing wrong/how to fix it?
Voltage measurements on the mosfet with reference to battery ground:
With enable track to MC cut - G 0v S 0V D 4V - Everything off, works as intended
On - G 4v S 0V D 0V Everything on, works as intended.
Switch "off" - G 1.15v S 0V D 1.63V
Relevant Arduino code which should keep the circuit off on startup until and on button is held for 1s
// set PB0 to be output
DDRB |= (1 << PB0); //replaces pinMode(PB0, OUTPUT);
PORTB |= (1 << PB0); //replaces digitalWrite(PB0, LOW);
_delay_ms(1000);
PORTB |= (1 << PB0); //replaces digitalWrite(PB0, HIGH);
It's hard to get my head around low side switching as everything is backwards.
Circuit below:
