# PWM with MOSFet- make it linear

there maybe wrong assumption in my question , so forgive me, i am here to learn .

So controlling a light(LED) with MCU that outputs PWM, into a MOSFET N-CHANNEL, as described in this little image:

so if i check the voltage in the gate, i can see clearly that it goes linearly up from 0 to 3.3V . (vcc is 5v)

But when you look at it, the led is really not dimming linearly at all, and has these steps. As we know the ID is proportional to (VGS-VT)^2 , and that means if the gate goes up linearly , the output will be nonlinear .

But, i do want a completely linear experience, and i was wondering a few things :

1. because ID is proportional to (VGS-VT)^2, i can put the voltage in the gate to be square(V), and so when i move up a linear slider, the output may be linear (?? )

2.the fact that i goes from 0 to -3V, maybe has to do with the specific MOSFET, that create this effect?

Bottom line, i see all the time,that you can use a MOSFET to dim a light, but he is not a linear animal ,and usually these circuits dont add any other parts to the circuit .

• If the MOSFET isn't saturating then you're using the wrong MOSFET. – Ignacio Vazquez-Abrams Dec 5 '14 at 17:29
• Why is your gate voltage doing anything resembling "goes linearly up from 0 to 3.3V". You should have a square wave there which alternates between 0 and 5V (your vcc). – brhans Dec 5 '14 at 17:37
• @brhans , as you know, a square wave in PWM high frequency , is exactly like linear voltage if you change the duty cycle. the output INDEED as the vcc, which is 3.3V, because thats my design . – Curnelious Dec 5 '14 at 17:53
• @Curnelious The way a PWM is typically used to drive a MOSFET is most definitely not in any way "exactly like linear voltage". The PWM should be driving the MOSFET hard into saturation and fully off for each cycle. In this way the MOSFET is then "PWMing" your load, which then appears much the same as a "linear voltage". The point being - your MOSFET is supposed to be operating as a switch and not in any in-between state. – brhans Dec 5 '14 at 19:05
• Pedantic mode on: For a MOSFET operating as a switch, you want to be in the linear region. The saturation region is the constant-current region. – W5VO Dec 5 '14 at 23:50

It looks like you are taking a wrong approach here for designing your requirements. Typically, if you want to control the LED intensity with PWM, you should make sure that the PWM high voltage (3.3V in your case) will open the FET completely (turn it on, bring to saturation region), while the low voltage will close it (turn it off). In that way the LED will blink with your PWM frequency, and the duty cycle will affect how much time out of the total it will be lit. If the frequency is high enough, the flickering won't be visible, and you will get nice dimming effect.

• Just a comment- you're not the only person to refer to opening a MOSFET (in the sense of turning it on). Isn't there some cognitive dissonance with 'open circuit'? – Spehro Pefhany Dec 5 '14 at 18:18
• @Curnelious (1) 500Hz is not high. (2) This is exactly the way to dim an LED (believe me, it's my profession, and I have some experience). – Eugene Sh. Dec 5 '14 at 19:22
• @Curnelious Forget about equations. When driven with a voltage that is high enough to get it to saturation and frequency low enough (and 500Hz is low enough) to ignore the transition effects, the FET is effectively a controlled switch. So just think about it this way. – Eugene Sh. Dec 5 '14 at 19:29
• Ok, I am here not for arguing. I just know. You - don't. This is why you are asking and I am answering. If you think you know better - why asking? If you look up to the comments on your question, you will notice @brhans commented exactly the same thing. So you can take it or leave it. – Eugene Sh. Dec 5 '14 at 19:58
• @Curnelious This is the normal way to dim an LED with PWM. Eugene is correct (as are all the other folks who made similar comments). – Spehro Pefhany Dec 5 '14 at 20:45