1
\$\begingroup\$

I developed a PID autotuning algorithm that I want to test outside of a simulation environment. For this purpose, I got temperature sensors to send data to a RaspberryPi.

Now I need something to produce heat, but it needs to be controllable with a RaspberryPi, so a Peltier element can't be used (needs to much amps). Someone told me that I could use a MOSFET for this. Does that make sense?

How difficult is it to implement something like this?

\$\endgroup\$
5
\$\begingroup\$

It's possible, with a mosfet, but there is a better way. It's typically not good to use a mosfet to burn up power with.

A more typical way is to use a hardware timer to generate a Pulse Width Modulation or PWM. A PWM is a pulse type signal where over the course of a timing cycle the power is varied by varying the size of the pulse. I use this type of control in many of my products, and it works very well. The control loop looks like this:

enter image description here
Source: https://www.semanticscholar.org/paper/Implementation-of-a-PID-control-PWM-module-on-DE0-Jain-Aware/379fc4c005eaeae199ba4ce864f99a786898228f/figure/0

For example if the timing cycle was 1 second, and the you wanted 1% power, you turn on the heater for 0.01 seconds every second, if you want 50% power, then the timer turns on for 0.5 seconds and off for 0.5 seconds during the cycle. Ect...

This link shows how to setup a raspberry pi hardware timer.

Instead of using the mosfet to do the heating, a resistor is used.

The a basic heater circuit is shown below. The mosfet is switched fully on, or fully off. The nice thing about this circuit is if you know how much your duty cycle is, you also know the average power though the resistor, this allows you to calculate how much power is being delivered. In the circuit below, if I were to turn it fully on, it would be producing P=V^2/R => 5V^2/100Ω=0.25W. A 10Ω resistor would give me 2.5W.

schematic

simulate this circuit – Schematic created using CircuitLab

You would need to size the mosfet for the current you need, and make sure you get a logic level mosfet that can handle 3.3V to turn on it's gate (unless you get a buffer or other switch with pull up for a higher gate voltage). By sizing the mosfet (or mosfets) you could design a heating control circuit for any heat needed.

\$\endgroup\$
  • 1
    \$\begingroup\$ In this case, the 100 ohm resistor is the heating element, not the MOSfet. Did the OP want the MOSfet to do the heating? Or just act as heating control? Not clear to me, but it does seem safer to use a resistor as the heating element. \$\endgroup\$ – glen_geek Oct 9 at 15:54
3
\$\begingroup\$

A MOSFET is often considered to be a variable resistor so you'd think that that indeed would make a power MOSFET suitable variable power resistor element.

However, nearly all power MOSFETs are designed to be used as a switching element making them easy to switch on/off but hard to make a certain resistance value. You would need to apply a very finely controlled Vgs to a MOSFET. Unfortunately that Vgs you need to apply depends on nearly anything, Vds, temperature, MOSFET model and individual sample (not the same between MOSFETs even from the same box).

There is however a solution and that is feedback, using feedback we can make an adjustable current source, well actually a current sink or current load because this circuit draws an adjustable (but fairly constant) current.

enter image description here

At the input J1 we need to apply a certain constant DC voltage, let's start with 1 V. The opamp will then try to force 1 V across Rs (sense resistor) as well. Suppose that Rs has a value of 1 ohm, then 1 A needs to flow. As long as we apply a high enough voltage at the drain of the N-channel MOSFET (1 V Vce for the MOSFET so in total 2 V or more will suffice) then from that 2 V (or more) 1 A will be drawn. If we apply 5 V instead of 2 V then still 1 A will be drawn.

Most of the power will then be dissipated in the MOSFET so it will get hot so use a heatsink! At 5 V, 1A there will be 4 V across the MOSFET (remember that Rs takes 1 V) at 1 A that means 4 W is dissipated.

You can play with the values of the DC voltage at J1 and the value of Rs to set the current. You can generate the voltage at J1 from a RPi by using a PWM output and filtering that signal so that you get the average value.

\$\endgroup\$

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.