npn 3906 switch question

Thread Starter

fredric58

Joined Nov 28, 2014
252
i built a wav player with an adafruit micro sd reader/writer breakout board and a 2.5 watt mono pam 8302 amplifier which are controlled by. an atmega 328p-pu bare bones chip. the sd is powered from pin d7, the amp is powered from pin d8. it works well a a low volume. however, if you turn it up the speaker just buzzes. i found that the mega can not supply enough current to run them. so i would like to use the current power pins to switch on the 2 components using a bjt. it is a 5v reg supply. what resistor value should i use for each pin?

I'll be going from d7 and d8 to a resistor (UNKNOWN VALUE), then to the base. the 5v supply will go to the collector, the emitter to the Vin of each component.

thanks greatly
 

BobTPH

Joined Jun 5, 2013
9,003
2N3906 is a PNP transistor. And that is not how you would wire it.

Emitter to +5V, collector to + power on the board. Base, through a resistor to the output pin, - power on the board to ground.

Note that a low on the output pin turns it on and a high turns it off.

Bob
 

DickCappels

Joined Aug 21, 2008
10,187
The question is whether to use common collector or common emitter. In the common collector configuration you loose one Vbe drop (about 0.7V) from the power supply voltage. Common emitter doesn't have that problem,

If you want to switch the + power supply connections it is best to use a PNP with the the emitter on the +5V supply as BobTPH suggested. That way you will get the full power supply voltage to drive the peripheral components.

Just checking -do those parts operate from a +5V power supply?

Tell us the amount of current being drawn by those parts and somebody will check to see whether or not the 2N3906 is ok for the job and also calculate the resistor values.
 

BobTPH

Joined Jun 5, 2013
9,003
As Dick implied, a 2N2906 does not have enough current capacity. A bridged amplifier like the PAM 8302 will be using 5 / 8 = 0.625A or 625 mA peak into an 8 ohm speaker. A 2N2906 has a max current of 200 mA,

I would recommend using a logic level MOSFET.

Bob
 

BobTPH

Joined Jun 5, 2013
9,003
At 600 mA, you would need a base current of 60 mA to saturate. This is beyond the capability of an Arduino pin. A MOSFET is far superior.

Bob
 

ebeowulf17

Joined Aug 12, 2014
3,307
Why are you powering the SD and amp from the Arduino?
Connect the SD and amp directly to the required power.
Agreed.

I would also add that, if you do need them to turn on and off, it would be worth checking the specs and datasheets. Many modules these days have "enable" pins which allow you to use a logic level GPIO pin to turn them on and off without having to switch the power yourself.
 

Thread Starter

fredric58

Joined Nov 28, 2014
252
Why are you powering the SD and amp from the Arduino?
Connect the SD and amp directly to the required power.
Because I'm new and learning. It made it simpler to write the sketch. Now I'm using what powered the components to operate a logic level mosfet as a switch to a separate power supply. It works pretty good but think I might need to add a pull down resistor to the gate. Even though it turns off when the arduino logic goes low it has a slight delay. Kinda like the charge in a capacitor
It's real short but it gives a false trigger. Something like transient current would/could cause.
 

BobTPH

Joined Jun 5, 2013
9,003
The delay is probably due to a capacitor on the board you are powering. The MOSFET itself would not have a delay that you could notice without an oscilloscope.

Bob
 

ebeowulf17

Joined Aug 12, 2014
3,307
Because I'm new and learning. It made it simpler to write the sketch. Now I'm using what powered the components to operate a logic level mosfet as a switch to a separate power supply. It works pretty good but think I might need to add a pull down resistor to the gate. Even though it turns off when the arduino logic goes low it has a slight delay. Kinda like the charge in a capacitor
It's real short but it gives a false trigger. Something like transient current would/could cause.
The amplifier does have a shutdown mode, accessible via the "SD" pin. So, if you connect the amp Vin directly to 5V supply, then you can connect one of your digital logic pins to the amp SD pin and control its power that way.

I don't see any shutdown function on the micro SD card reader, although I don't know why you'd want to shut that down in the first place.

If I were you, I'd power both devices directly from 5V supply, use SD(shutdown) pin to control power to amp, and never turn off micro SD card.
 

Thread Starter

fredric58

Joined Nov 28, 2014
252
The delay is probably due to a capacitor on the board you are powering. The MOSFET itself would not have a delay that you could notice without an oscilloscope.

Bob

Uhm…what I noticed with a mosfet is if you put voltage to the gate, then take it away. It will stay on.

I don't know if the arduino going to a logic low, 0 current is the same as going to ground. I would think it is just zero out put

This change occurred when I put the MOSFET in. Since it only takes a minute amount of voltage to turn the MOSFET on. It could be possible that it is transient current from the Arduino? The components turn on and off three times a minute and the Arduino powers down between each on our cycle.
 

BobTPH

Joined Jun 5, 2013
9,003
Uhm…what I noticed with a mosfet is if you put voltage to the gate, then take it away. It will stay on.
Yes, but connecting it to a digital output does not do that. The output is either 5V or grounded. If you are worried about the state of the MOSFET if the Arduino is not powered or disconnected, then a resistor from gate to source (not to ground for a P-MOSFET) will keep it off.

Bob
 

Thread Starter

fredric58

Joined Nov 28, 2014
252
The amplifier does have a shutdown mode, accessible via the "SD" pin. So, if you connect the amp Vin directly to 5V supply, then you can connect one of your digital logic pins to the amp SD pin and control its power that way.

I don't see any shutdown function on the micro SD card reader, although I don't know why you'd want to shut that down in the first place.

If I were you, I'd power both devices directly from 5V supply, use SD(shutdown) pin to control power to amp, and never turn off micro SD card.
The SD is a logic high and it's more of a mute than a shut down. They get turned off when they're not in use because it's a battery operated project. And it only reads/writes data three times every minute. 5 seconds each time.
 

ebeowulf17

Joined Aug 12, 2014
3,307
The SD is a logic high and it's more of a mute than a shut down. They get turned off when they're not in use because it's a battery operated project. And it only reads/writes data three times every minute. 5 seconds each time.
The device draws only 1uA in shutdown mode. If you add a pull down resistor to your MOSFET gate, you may burn more power on the pull down resistor than this whole device uses in shutdown!

As for the micro SD, I've never looked into their power consumption, so I'll take your word for it on that issue. For some reason I thought it might be fussy about initializing if you were powering it up and down all the time, but it sounds like you've already got that part working, so disregard my micro SD fears!
 
Top