PID to control heater using microcontroller


Thread Starter


Hi all, I'm new in here. I have been assigned a project title related to PID controller for which I need some advice and guidance. I wish to apply PID algorithm to control a heater to ramp up and maintain at certain temperature using micro-controller. Any help is highly appreciated. =)

The hardware includes a Thermocouple and a Heater block. I wish to use micro-controller (C programming) to control the heater block to fire up to 200 degree and maintain at that temperature.

I have included some parameters to be considered: Kp, Ki, Kd, setpoint, actual output and error. Is there any other parameter I should include? How should I manupulate these parameters to control my heater block in order to ramp and maintain the temperature using PID algorithm?

Thank you for your attention, please give me some advice on these. =)

Best regards,

Gerrit M van der Molen

Hello Wayne,

Additional parameters you should consider are output limits (min/max heater power?) for anti-windup if you use integral control, and scaling factors between the inputs and outputs of your micro-controller (is the temperature measurement input signal in mA, deg C, deg F, another unit?) and internal scaled or engineering units. Another factor to consider is whether you will need to switch between automatic and manual control (requiring bumpless transfer/changeover), or will always be under automatic control.

For ideas and examples of PID algorithms and code, search on the site for "pid implementation" and "pid using c".

Good luck,

Thong Phat Co., Ltd.

Dear Wayne,

There is a full resource for your to build a PID controller for a heater: using thermocouple or RTD sensor, on/off or phase control for the heater, Orcad schematic, C code for both microcontroller and PC interface via serial communication, PID code with Kp, Ki, Kd.

The link is:

However, it is based on Cypress PSoC microcontrollers. They are very powerful 8 bit microcontrollers: ADC, DAC, PWM, analog multiplexers, timers/ counters, I2C, UART, amplifiers etc. Its big disadvantage is quite complicated to start, learn and understand. It is very difficult in comparison to 8051 microcontrollers.

Hope you like it!

Hung Lam