Author Topic: Attiny based N-Channel Mosfet switch does not turn off fully.  (Read 947 times)

0 Members and 1 Guest are viewing this topic.

Offline rohanwoodsTopic starter

  • Newbie
  • Posts: 3
  • Country: au
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.pdf

Any 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:
« Last Edit: May 24, 2021, 10:43:41 am by rohanwoods »
 

Offline Moriambar

  • Supporter
  • ****
  • Posts: 502
  • Country: it
Re: Attiny based N-Channel Mosfet switch does not turn off fully.
« Reply #1 on: May 24, 2021, 11:14:44 am »
If you're talking about Q1, in the schematic it's upside-down, meaning that gnd now is connected to drain while it should be connected to the source, and your load should have its return to ground on the drain of the tranny and not on the source
 

Online jpanhalt

  • Super Contributor
  • ***
  • Posts: 3762
  • Country: us
Re: Attiny based N-Channel Mosfet switch does not turn off fully.
« Reply #2 on: May 24, 2021, 11:19:05 am »
You seem to have the mosfet installed backwards.  The source needs to be connected to ground.  Clue: Look at the orientation of the diode.
 

Offline Peabody

  • Super Contributor
  • ***
  • Posts: 2141
  • Country: us
Re: Attiny based N-Channel Mosfet switch does not turn off fully.
« Reply #3 on: May 24, 2021, 03:02:52 pm »
I'm not sure the mosfet is backwards, depending on what you're trying to do.  Do you want the ATtiny to stay powered while you turn all the other stuff off?  If so, there have to be separate ground lines - one for the ATTiny, which is probably the same as battery ground, and the other line that goes through the mosfet to battery ground.  In your circuit, it looks like the ATtiny is trying to switch off its own ground.  Well, maybe I'm not reading it right, but it looks strange to me.
 

Offline madires

  • Super Contributor
  • ***
  • Posts: 8134
  • Country: de
  • A qualified hobbyist ;)
Re: Attiny based N-Channel Mosfet switch does not turn off fully.
« Reply #4 on: May 24, 2021, 04:16:40 pm »
The circuit's ground is BAT- but the ATtiny's GND pin isn't connected to BAT-. Therefore the ATtiny can't pull down the gate to ground.
 

Offline Peabody

  • Super Contributor
  • ***
  • Posts: 2141
  • Country: us
Re: Attiny based N-Channel Mosfet switch does not turn off fully.
« Reply #5 on: May 24, 2021, 04:34:26 pm »
Also, I don't understand SW1.  When that switch is closed, you have a direct short from Vcc to PB0, which is not a good thing if you try to take PB0 low.
 

Offline madires

  • Super Contributor
  • ***
  • Posts: 8134
  • Country: de
  • A qualified hobbyist ;)
Re: Attiny based N-Channel Mosfet switch does not turn off fully.
« Reply #6 on: May 24, 2021, 04:54:48 pm »
Yep! If SW1 is meant as a manual overwrite then there should be a resistor in series.
 

Offline rohanwoodsTopic starter

  • Newbie
  • Posts: 3
  • Country: au
Re: Attiny based N-Channel Mosfet switch does not turn off fully.
« Reply #7 on: May 24, 2021, 10:08:27 pm »
I have tried swapping the mosfet around so Source is GND(Load) and Drain is Bat-(Ground) and the mosfet just stays on, even if I completely disconnect the Gate.
This is supposed to be a self latching circuit. Everything should be off at the start, until SW1 is pressed. When SW1 is pressed the mosfet should turn on, enabling the microcontroller and the rest of the circuit. When the MC starts up it waits for 1 second(so SW1 has to be held for 1 second) then latches PB0 high to keep the mosfet on.
When SW2 is pressed the MC resets. The mosfet should then be turned off by the R2 pull down resistor, turning everything off.

Thanks for all the help so far everyone.

 

Offline ledtester

  • Super Contributor
  • ***
  • Posts: 3249
  • Country: us
Re: Attiny based N-Channel Mosfet switch does not turn off fully.
« Reply #8 on: May 24, 2021, 11:31:36 pm »
Quote
This is supposed to be a self latching circuit.


There are a lot of posts on the forum about soft power latching switches. For instance:

https://www.eevblog.com/forum/projects/attiny13a-power-button/msg3356266/#msg3356266
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf