I am using a BC338 as a switch to turn a 12v computer fan on/off. The fan is rated 0.3 amp.
this is your typical npn switch circuit.
arduino to base resistor to transistor base, transistor emitter to gnd, transistor collector to fan ground, fan +v to 12v. diode across fan. There is also a resistor from base to gnd.
I tried 1k and 4.7k base resistor and got the same result. base to gnd resistor is 47k.
When fan is on, V CE is about 1v (less actually).
when I disconnect the base signal or switch arduino pin to low, V CE is about 5v, so fan is still getting 7v so it is still spinning.
I tried this on ULN2803 and result is the same.
Any ideas how to make the V CE higher so the fan will turn off?
The fan is a 4 pin fan so I have connections to the PWM and Tach pins. PWM is connected to an arduino pwm pin, and tach pin is connected to an arduino input pin with pull up enabled. Not sure if this is affecting the transistor switch or not, but though I'd mention it. The pwm and tach circuit works fine. I can control fan speed and get rpm value. Just that I can't completely switch the fan off.
but as I said, I tested on ULN2803 and the result is exactly the same. I even tried using MOSFET and same result.
I have not tried disconnecting the pwm and tach to isolate the problem further, but I doubt it affects the V CE. The tach signal is open-collector from the fan, so it should be fine to pull it up to 5v instead of 12v.
I used the same circuit on another computer fan, rated 0.15 amp, and it turns off just fine. But when I measured the V CE, its the same 5v. But somehow, with this other fan, it stops spinning even if voltage across it is still 7v.
and yes, the connection is correct, otherwise the fan will not even turn on no? plus on ULN2803, there is no way to mix up collector and emitter.
ok, I see the problem is caused by connecting the arduino ground to the +12v power supply ground. If I disconnect the arduino gnd, then the V CE goes to +12 when I disconnect the base.
The problem now is, the PWM and Tach signals are not properly grounded (they essentially float on the V CE saturation voltage level. And the result is arduino is not able to detect the level change of the tach signal.
perhaps this one needs a PNP circuit in order to have the proper ground connection.
ok, I see now the load needs to be grounded, due to the additional pwm and tach connections. The 5v I am seeing is actually coming from the arduino pin and from the pullup of the input pin (tach pin). so that output pin is essentially powering the fan when the npn transistor is supposed to be off. so the standard npn switch will not work. I'll need something like this
hopefully this info may be helpful to others who may run into this.