Filtered PWM to drive a MOSFET

Hello,

A while ago, before I knew anything, I built a circuit to drive a 4 amp maximum load using Arduino's PWM, which was in turn varied by a PID controller. I used a MOSFET, and filtered the gate input with a LPF with a 3dB point of around 2 hz. I didn't know anything about transistors at this point, but it seems to work ok. I am currently studying MOSFETS, though, and it occurred to me that the filter is perhaps ruining the PID response around the target value, since the device is going to be stuck in the saturation region unless the pwm is off for a while...the low 3db point of the LPF means a high time constant, so a slow decay, so im thinking that the MOSFET is probably staying on the whole time that the PID is trying to maintain a constant value. Does this thinking make sense? I don't have the opportunity to mess with it for a while, but while i'm studying MOSFETs this weekend, I figured I'd throw this thought out there to see if anyone has any insight.

Thanks for your time.

So you’re keeping the “MOSFET” (some old high-VGS HEXFET?) biased in the linear region as a variable load?
I was reading a manufacturer’s note that the industry trend (production focus) is higher-current (ID, low-VGS designs, which don’t lend themselves to such applications.

If it was a bipolar emitter-follower (as a pass transistor), either the input or the output could be conditioned (filtered, smoothed, etc).
With a FET, I think I’d be better off PWMing the gate and conditioning the output.

The charge delay and discharge hold-up have to be taken into account in your PID application (calculations) certainly.

What load is the mosfet controlling, and what is the application? What sort of response time do you want from the controller?

Hello Mr_F,
You wrote: “the device is going to be stuck in the saturation region unless the pwm is off for a while.”

It seems you do not know what saturation is for a MOSFET, which is almost opposite what is defined for bipolar transistor saturation.

Saturation : when the Vds > (Vgs-Vt)
Linear : when Vds < (Vgs-Vt)

For Arduino PWM outputs from 0 to 5 volts and for Vt threshold of 2 volts, the MOSFET is saturated when the drain voltage is over 3 volts. When it is saturated, the current varies with the square of the gate voltage.

Ids is proportional to (Vgs-Vt)^2

Linear operation of a MOSFET occurs only for small drain voltages, like 1.0 volts. If you have 10 volts on the drain and 5 volts on the gate, it is saturated and the “square law” is used to calculate the current versus gate voltage. The drain current becomes a “constant current source” in saturation for constant gate voltage. The drain’s constant current sourcing is probably not what you want, and I assume you want the drain current to have a “linear” increase of current when the drain voltage increases. To get linear operation of a MOSFET drain IV curve, use drain voltages that are very small compared to the gate voltage.

Alternatively, you could put the MOSFET in the linear region when the drain voltage is near 10 volts if you bias the gate voltage above 12 volts .

Linear:

Vds < (Vgs-Vt)

10 volts < (15 - 2)

where
Vgs is an amplified PWM at 15 volts
Vt is 2 volts
Vds is 10 volts

Mr_F wrote: “the MOSFET is probably staying on the whole time that the PID is trying to maintain a constant value.”

Yes. It is common for a MOSFET to always be “on”. Please tell us if you want a constant voltage or a constant current, not just a constant “value”.

If the PID is fast and the gate filter is slow, that is acceptable to me, but what is you goal for acceptable performance? In this case, the slow gate voltage changes will cause a slow drain current change, but we do not know what your circuit does. With no gate filter, the PWM will slam the drain currents so fast your PID feedback will not be able to respond quickly enough, causing oscillating drain currents.

references : npn saturation : http://www.eevblog.com/forum/beginners/transistor-saturation/

Hello,

Thank you for your replies.

The application is a temperature sensor and a heater. The user sets a temperature point, and the heater heats to that point, and is controlled by the PID. I use 2 x 40W heaters in series, with a 24V power supply. I guess it would be ideal if the output current varied with Vgs.

The circuit is:

Arduino PWM --> 330k Resistor ---> 0.47 uF cap to ground --> Fet Gate, and then 24V supply --> 2 x 40W heaters in series --> FET Drain, and the source to ground.

Perhaps this question would have been better formed had I waited until I've finished studying this mosfet chapter. Please excuse my ignorance...just trying to learn.

For running a heater, there is absolutely no need to smooth the PWM. Doing so just wastes power in the mosfet, when you want it in the heater. I suggest you remove the 0.47uF cap and reduce the 330K resistor to 100 ohms. It's also wise to connect a 10K resistor between ground and the output pin that drives the gate, to ensure the mosfet stays off when the Arduino is not powered up, or is powered up but not yet running the sketch.

Ok, thank you.

The reason that I put the filter in there is that without it the power supply "screams" due to the fast switching on and off. Admittedly, though, I added this in a previous design, where I used a BJT. I've not tested it without the filter for the NFET.

Mr_Faineant: The reason that I put the filter in there is that without it the power supply "screams" due to the fast switching on and off. Admittedly, though, I added this in a previous design, where I used a BJT. I've not tested it without the filter for the NFET.

It's not likely to be any different with a mosfet compared to a BJT. You can reduce or eliminate the screaming by using a higher PWM frequency, or connecting a large capacitor across the output of the 24V supply, or a combination of both.

Ok, that makes sense.

Would you mind explaining why the filter wastes power in the mosfet? I can't quite wrap my head around that. Also, for this type of application, say where a filter was a good idea, would it make more sense to filter the output rather than the input?

Thanks for your help, I really appreciate it.

Mr_Faineant: Ok, that makes sense.

Would you mind explaining why the filter wastes power in the mosfet? I can't quite wrap my head around that.

The MOSFET gets hot.

Well, yes, that would be the effect of wasting power, by definition, but that doesn't help me understand why filtering the PWM would cause this. Also, it doesn't, the mosfet stays perfectly cool to the touch.

The best solution for you is the one dc42 suggested to you. Trust us.
Just for your information -this is how it could work with your idea: the low pass makes an analog from pwm, and an opamp senses the current flowing through the mosfet. The opamp sets the gate voltage such the voltage at the sensing resistor R2 is always equal to the voltage at R5 (analog input). So you can set the max current with the proper R2 value, and the mosfet’s Ids current will be linear to the pwm duty cycle (analog in). The heater power will be Ids^2 * Rheater.

In this schematics max voltage at R2 will be 0.71V (with pwm=99%), so you can easily calculate the Ids current flowing.
The only issue here is when you set for example pwm 20%, the power dissipated from the mosfet will be 20x bigger as the heater’s one. You may use the mosfet as the heater then :slight_smile:

Not to recommend.

fetanalog.jpg

Mr_Faineant:
Well, yes, that would be the effect of wasting power, by definition, but that doesn’t help me understand why filtering the PWM would cause this.

MOSFETs stay cool when they’re completely on or completely off (ie. extremely low resistance or extremely high resitance).

They get hot when they’re in the transition stage (“linear region”) where the resistance is low enough to dissipate heat.

If you filter the PWM output you might be keeping it in the linear region.

Mr_Faineant:
Also, it doesn’t, the mosfet stays perfectly cool to the touch.

Maybe your circuit isn’t doing what you think it does.

As noted though, high frequency PWM control of something that reacts as slowly as a heater is pointless. If the device is noisy then the best solution is to reduce the PWM frequency down to a really low value. I’d do it in software using millis(), updating at 1Hz. Maybe you can do it even slower than that.

void loop()
{
  // Update heater at 1Hz
  unsigned long now = millis()/10;

  // Do PWM as a percentage of time
  int val = desiredPwmPercentage();
  if (val < (now % 100)) {
    switchHeaterOn();
  }
  else {
    switchHeaterOff();
  }
}

Well, yes, that would be the effect of wasting power, by definition, but that doesn't help me understand why filtering the PWM would cause this. Also, it doesn't, the mosfet stays perfectly cool to the touch.

Your heating problem starts when you start to operate the mosfet in linear way (do you?). You must use a "control loop" to operate the mosfet as a linear power control element..

Have a look at my schematics above: With for example 20% PWM duty cycle, the voltage at R2 will be 0.14V. That will be Ids = 2.36A current (Ids = 0.14V/R2).

The power on the heater (heater resistance here 1 + 1ohm in parallel): P = Ids * Ids * 0.5ohm = 2.78W

Voltage on the heater:

Vh = 2.36A * 0.5ohm = 1.18V

The power on the MOSFET: P = Vds * Ids = (24 - 1.18 - 0.14) * 2.36 = 52W

pito: The best solution for you is the one dc42 suggested to you. Trust us.

I do trust you, and I certainly wasn't arguing, but I'm asking questions because I want to understand WHY it is the best option. My purpose here is to learn, not to blindly follow.

I really appreciate you all taking the time to explain things and draw diagrams and such, it's a great help. I need to sit and do some thinking/scribbling to get a good grasp on what you are saying.

fungus: Maybe your circuit isn't doing what you think it does.

I agree, it probably doesn't, which is why I'm here. I like your PWM suggestion, I will look into that, thank you.

Thanks again everybody, much appreciated.