Resistor Selection to retain same brightness in LED PWM circuit

The resistor in series with the source isn't allowing the MOSFET to turn on completely, you need to move the resistor in series with the source to the top, in series with the LED.


PS: I am not looking for a constant current driver circuit solution.

And yet as pointed out in other answers what you have unintentionally built is a crude current sink.

If you just want to use the mosfet as a switch then (as other answers have said) the source of the mosfet needs to be connected to ground and the resistor needs to go between the mosfet and the LED (or between the LED and the 5V supply).

Can you please elaborate as to why it behaves as such? (as a current sink)

The current through the mosfet depends on the voltage between the gate and the source, but your gate is no longer grounded.

This sets up negative feedback, as the current in the resistor increases the voltage across the resistor increases which means the voltage between the gate and the source decreases.

Unfortunately predicting what the current will be is non-trivial. There is a graph of typical forward characteristics in the datasheet but.

  • It shows huge temperature dependence.
  • It's only valid for VDS > 2V.
  • It's only typical.
  • Reading precise values off graphs is never easy.

Looking at the 25C graph it suggests that at the currents we are working at there will likely be about 2.5V across the gate.That would leave about 0.8V across the resistor and a current in the resistor of about 133ma.

Your measured value is about 50% of this, there may be several things contributing to this discrepancy.

  • You are PWMing, your multimeter is likely measuring the average voltage not the peak.
  • The drain-source voltage is probablly more like 1V than, 2V. This may require a higher gate-source voltage to acheive the current.
  • The "3.3V" output from your microcontroller may well not be a full 3.3V.

Now question is how should I mathematically calculate R1

You did a fine job calculating the value but a crappy job in its placement. It needs to go directly in series with the LED and not in the source of the MOSFET.

Once you put it in the source, the MOSFET behaves like a constant current circuit and you force a much lower voltage across the source resistor. Your numbers imply to me a value of 0.36 volts and that tallies with the VGS(threshold) value for most common MOSFETs and the drive level of 3.3 volts on the gate.