I am trying to control a DC voltage using pulse with modulation (PWM) and an N-channel MOSFET. The way I have set up the circuit is as follows: enter image description here

However, instead of the motor I have a 100K resistor, in parallel with a 100microfarad (25V) capacitor in order to smooth out the voltage. I am measuring the voltage across this resistor to check if it is being regulated or not:

enter image description here

I am powering the load from the same Arduino (for the time being. I will power it with an external battery once I get PWM working). I have the following code running on the Arduino:

int pwmPin = 3; // connected to the MOSFET's gate
int val = 128;  // set between 0 and 255

void setup() {
   pinMode(pwmPin, OUTPUT);

void loop() {
   analogWrite(pwmPin, val);

However no matter what I set the value to, I see the output voltage to be the same value of 4.99V instead of being proportional to the duty cycle. This changes as I get very close to 0 (when val=10, V_out = 4.33V and when val=0, V_out = 0V).

Why is this happening? Is the transistor not fast enough? Is the capacitor not big enough? What am I doing wrong? Below are the datasheets for the components:

Transistor (TO-220)


Sorry if the post has become wordy. I have been downvoted in the past for not including enough details with my post (because I wanted to be concise) and now I am being cautious.

Any help is much appreciated!

Edit: Please disregard the values on the diagram. I have wired my circuit as shown but for the values, as explained in my post I am using the Arduino to power the load. Meaning that the positive pin of the load is connected to Arduino's 5V and the black line in the diagram is connected to the ground of the Arduino. (I did not make the diagram myself and I was myself confused about the 0-60V+ and 0-60- notation, I'm assuming it means the 10K resistor was chosen such that such a range of values would not damage the circuit) I have also included the datasheet to the specific transistor I am using. Thank you for the answers so far.

  • \$\begingroup\$ Even after your edit, your load voltage inputs are mislabeled. You should have left the original 5-60v designation on one, and called the other ground or 0v. Instead, what you have said is "I will connect a supply of anywhere from 0 to 120 volts here" which does not appear to be what you mean at all. \$\endgroup\$ – Chris Stratton Mar 25 '18 at 23:55
  • \$\begingroup\$ in my opinion a simple circuit diagram would show more and does the analysis easier \$\endgroup\$ – HerrderElektronik Mar 27 '18 at 5:41

This is not an answer but if you understand impedance ratios or a switched voltage divider, this should lead you think about your results and understand why.

Instead of 100K Resistor try an 8W bulb or a small motor or 10 Ohm 1W resistor.

Using semiconductors as switches for PWM:

Average Resistance = ESR/d for duty cycle d and ESR means RdsOn or Rce for MSOFETs or BJT's the incremental resistance. But Dual transistors have the effect of 1 then 2 PN junctions add to the ESR. (more on this later .. see graph)

A Mosfet has RdsOn which requires usually >=2.5x Vgs(th) to switch on the internal resistance.

A BJT requires Ib = 10% of Ic to achieve the Vce(sat) spec. A dual BJT (Darlington) requires Ib = 0.4% of Ic for Vce(sat) up to 3A and 20mA@5A

This implies to efficiently saturate the switch you need to overdrive it implying the current gain is reduced to 10% of hFE.

Although the Ic is somewhat nonlinear, there are linear sections of collector-emitter, Rce or Effective Series Resistance , ESR that are useful to remember.

ESR = Rce = ΔVce/ΔIc between two points on the curve.
Extrapolate the tangent to read the slope.

TIP 120 , for Ic < 1A Ic = 0.7V+0.1*Ic (Rce=0.1 Ohm)

If the Motor coil DC resistance or DCR is >> 0.1 Ohm and this V+/(Rce+DCR) is less than 3A then it should work with the understanding the Vce =2V @3A is significant.

So the supply may need to be 2V higher than the motor rated voltage for max RPM. This is not the case when using a very low RdsOn part which may cost a bit more. RdsOn << 100 mOhm is very common in SMD parts which dissipate less heat and easier ('C/W) in a smaller case size. enter image description here

| improve this answer | |

Your 100K resistor is not conductive enough to meaningfully discharge the capacitor during the gaps in the PWM waveform. In effect, it merely "holds the peak" of the applied voltage. If you used something like a flashlight bulb as a load, you might start to see a time average matching your expectation.

It's also a bit unclear if you are measuring across the capacitor, or between the always-high side of the capacitor and the unswitched ground.

You also seem to have mis-labeled the lower side of the load power supply - that should probably be "ground" not "5-60v -"

Finally the TIP120 is a Darlington transistor, effectively a dual-stage Junction Transistor, not a MOSFET as claimed in your title.

| improve this answer | |
  • \$\begingroup\$ or "5-60v -" meaning Supply return (-) at source defined as 0V or Gnd... just adding clarification. \$\endgroup\$ – Tony Stewart Sunnyskyguy EE75 Mar 25 '18 at 23:26
  • \$\begingroup\$ No. As drawn the diagram implies 10-120v across the motor. This is almost certainly not what the user means, the point here was that their drawing is in error in this regard. \$\endgroup\$ – Chris Stratton Mar 25 '18 at 23:40
  • \$\begingroup\$ OK but I read it as (V+ and V-) terminals on supply set to x -xx V where V- is obviously connected to GND and not -5 to -60V \$\endgroup\$ – Tony Stewart Sunnyskyguy EE75 Mar 25 '18 at 23:43
  • \$\begingroup\$ That was probably the intent, yes, but labelling that way is an error, as such labelling would mean twice that voltage. The point was explaining to the user that they have made an error in labeling their drawing. You can have a V+ terminal and a V- terminal, but if you put numbers on both of them, the potential is either the difference of those numbers, or else your terminals are incorrectly labeled. \$\endgroup\$ – Chris Stratton Mar 25 '18 at 23:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.