# 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