PWM, Low Pass Filter, Transistor, & P Channel MOSFET

My goal was to use PWM output from Arduino (0-5V) and a low pass filter to smooth out that voltage. I then wanted to feed that voltage into the gate of a P Channel MOSFET which would normally be pulled up to 12V via a transistor.

So the goal was have either 12V at gate (off), or somewhere between 0 and 5V (more on or less on respectively). And my hope was I could control a DC computer fan with this smooth voltage. (Someone told me you can’t use PWM on an older computer fan). If I had a newer fan I suppose all the circuit issues would go away and I could just feed the PWM directly into the fan.

I had a couple issues. THe point which I wanted to be at 0-5V and 12V was not going between 0 and 5V, it was simply either 12V or 0V depending on if I had Arduino PWM active or not.

I thought about it a while and realized the transistor was current controlled not voltage controlled and so I decided to move my low pass filter from the base of the transistor to the gate of the MOSFET.

So the point between the pull up resistor and transistor was a pwm as well but going between 0V and 12V. So I would have expected the low pass filter to smooth out the PWM properly and result in a smooth voltage somewhere between 0V and 12V going into the MOSFET gate which would then allow fan speed control.

The problem was that when I added the low pass filter to gate of MOSFET I was getting weird issues where my PWM would drop form 12V HIGH to like 1V or 0.5V HIGH depending on resistor I used in filter.

Was I like inadvertently creating a voltage divider or something? Below is my schematic. Any help is appreciated.

Why can’t you use PWM on the computer fan? Is it a “smart fan” or something? Or just a standard box fan kind of fan?
You need 0V to turn a standard P-channel MOSFET on, 12V to turn it off.

I actually had the intentions of making that exact circuit you posted previously, but a person on the forum said you can't put PWM on 12V line (http://forum.arduino.cc/index.php?topic=256147.msg1811910#msg1811910).

So I started trying to play with the low pass filter.

WIll it work with PWM?

Is the fan from a ripped apart power supply? Or just a simple box fan that would have sucked air thru the body of a desktop computer. If just 2 wires and no obvious components added, I think the simple transistor design would do fine.

I used this circuit

https://www.flickr.com/photos/33177304@N03/4745203653

Is the fan from a ripped apart power supply?

It was from an old PC and I'm not sure if it was just a case fan or a cpu fan or something like that, but it has three wires. 12V, Ground, and a wire that from my understanding is connected to a hall effects sensor to determine RPM the fan is spinning at.

I used this circuit

I will have to test that one.

Just a heads up the circuit Grumpy_Mike posted does work.

Interestingly enough however there appears to be a voltage drop across the collector and emitter of the transistor though. Is that normal. Which item on datasheet specifies voltage drop across collector and emitter?

wesOOOOOOO, Vce is the collector-emitter voltage.

Mike, What's this instrument? https://www.flickr.com/photos/33177304@N03/3349467267/in/photostream/

I am using a 2N4401.

It says the Vce(sat) is .4V to .75V but mine measures at 4.5 volts drop across collector and emitter. I have my DC supply set to 13.2Volts and the other voltage is being dropped across the two resistors shown in the picture Mike posted.

Why is my V drop so much higher? I am using tiny amounts of current. My DC supply doesn't even register current draw.

Are you sure you're using the right value resistors? If one of those resistors is a decade out I calculate you'd get about 5.5 V Vce, because the transistor is not being driven into saturation. What value resistors are you using?

Actually I changed my resistor values around until I got values I was happy with.

My initial problem was I didn't actually know how to solve for Vce, but I found a good article online explaining how to determine Vce and I was able to build an excel spreadsheet of different input voltages and what output voltages they would map too and it was very helpful.

My previous resistor values were nowhere near correct.

Mike, What's this instrument?

It is my Arduinocaster:- http://www.youtube.com/watch?v=ehy9xgl4YCs

So like an automated guitar with harpsichord kind of sound, that's pretty neat.

wes000000: Interestingly enough however there appears to be a voltage drop across the collector and emitter of the transistor though. Is that normal.

Yes it is. That is how the circuit works. Most circuits here have the emitter connected straight to ground because the transistor is being used as a switch. To do this you need the transistor saturated, that is as hard on as it can go.

In this circuit the transistor is acting as a linear amplifier. The resistor in the emitter acts as a negative feedback mechanism reducing the gain of the transistor to allow the change in the voltage, applied to the base resistor, to be reflected in the change in voltage on the collector. This allows the FET to be driven in the linear region and give you the proportional control you are looking for. Any restriction of the current in the collector circuit shows up in an increase of voltage across the collector / emitter. That is how transistors work. Think of them as a current controlled (base current) rheostat, with the collector / emitter representing the rheostat. (Yes I know it is not quite like this but in terms of thinking about the circuit it is practically the same)

The PWM filter is on the base side of the circuit allowing you to use higher impedances in the RC filter (bigger R smaller C), then the transistor reduces that impedance and also amplifies it to to the 12V range you need for controlling the FET. I found you need about 34% PWM to start the motor moving.

CrossRoads: So like an automated guitar with harpsichord kind of sound, that's pretty neat.

Well it is MIDI so it can sound like however you want. But I wanted it to have a finger picking acoustic guitar playing style instead of the distorted power chords you get in a lot of 'Keytars' as they are called.

I did it back in 2009. I can even play "House of the rising sun" on it. But as you heard from my "Post your Code" efforts, my voice isn't the greatest :)

@Grumpy_Mike

I found this earlier which I felt explained it pretty well (https://www.wisc-online.com/learn/career-clusters/stem/sse1302/transistor-fundamentals--voltage-divider-biased-npn-transistor). This page calls it a transistor based voltage divider. Is that the same thing?

Yes it is. That is how the circuit works.

Ok good to know.

Most circuits here have the emitter connected straight to ground because the transistor is being used as a switch. To do this you need the transistor saturated, that is as hard on as it can go.

If it is current controlled then how do you know when it is saturated? For instance if I had a load on transistor that took 100mA, but my base current and gain were such that only 50mA were allowed to flow I am assuming that would not be saturated. But does 100mA constitute saturated, or 150 or 200mA? Like at what point is it saturated?

The resistor in the emitter acts as a negative feedback mechanism

Like in an op amp or something?

Any restriction of the current in the collector circuit shows up in an increase of voltage across the collector / emitter.

So the less the base current the more the resistance? And so basically transistors are like current controlled resistors?

allowing you to use higher impedances in the RC filter (bigger R smaller C), then the transistor reduces that impedance

Does the higher impedance (then lower) impedance have an advantage?

This page calls it a transistor based voltage divider. Is that the same thing?

I don't know because the page would not let me see anything. I have never come across it being called that but it could make sense.

If it is current controlled then how do you know when it is saturated?

It is saturated when an increase in base current produces no increase in collector current.

For instance if I had a load on transistor that took 100mA, but my base current and gain were such that only 50mA were allowed to flow I am assuming that would not be saturated.

Correct.

But does 100mA constitute saturated, or 150 or 200mA? Like at what point is it saturated?

When a transistor is saturated there is a fixed voltage between emitter & collector, this is normally 0.7V although at high currents this can increase, in the data sheet this is called Vsat. We say the transistor is "Hard on" in other words the rheostat is turned down as much as it will go.

So the saturation current for any circuit is the voltage across the load resistor over (divided by ) the resistance of the load resistor. The voltage across the load resistor is the supply voltage minus the Vsat voltage.

Like in an op amp or something?

Yes :) In fact transistors were around first and op amp feedback used to be described as "like the emitter resistor".

So the less the base current the more the resistance?

Yes.

Does the higher impedance (then lower) impedance have an advantage?

The bigger a capacitor is the more expensive it is (in general ) so it is better to have a high resistor and a small capacitor. However such a high impedance will not drive very much, so in a simple RC filter you have to have the impedance low enough to drive the load. The transistor converts the impedance so you can have a low impedance output to drive a load.

Awesome response, thanks for answering all the questions.