Continue to Site

Welcome to

Welcome to our site! is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PID Cotrol implementation in microcontroller system

Not open for further replies.


Member level 3
May 28, 2001
Reaction score
Trophy points
Activity points
velocity pid

Hello to all of electronics fans out there.

I have a question about PID control for you. Did any of you implement a PID control in his/hers microcontroller system ?
Does any of you have a good PID documentation (preferd in PDF)?

I'd like to implement a linear temperature control wit electric valve and tmperature sensor feedback.

Thank you for your answers!

winavr pid controller

I've done preliminary design work for a AVR based PID controller for DC motor position control. I no longer have the links, but you should be able to perform a google search on PID control system to find information. You should find several university class notes and examples for the design equations.

We used the AVR PWM outputs to control current drivers which, in turn, drive the motors. The built-in A/D converter was used to read the position potentiometer for feedback.

does kp ki and kd depend on path

Hi mikasi,

Look at my post here:
**broken link removed**

It may be useful.


heater control an937

The best article I know for PID control for microcontroller with code examples was in microcontrol journall ( some time ago.


Read Target Input

Read Actual output

Calculate err, err= Target - Output
calculate Proportional effect. PE = err * Kp
calculate Integral effect. IE = err * Ki*dt1 + old_IE, old_IE=IE
calculate Derivative effect, DE = Kd * (err - old_err)/dt2, old_err=err

calculate command signal = PE + IE + DE

p i d and pendulum

Does anyone have e-book/documents or experience about calculating Kp, Ki, Kd.

avr pid control err

That is all that you need
**broken link removed**

pid source code for room temperature control php

Download file PID.ZIP (0.95 KB) from

**broken link removed**

It may be useful.

windup automatic generation control

Some code and explanations regarding PID design

PID and Kp Kd Ki Parameters

Usualy more difficult the determine of good values of PID parameters using analitic method.

Zigler-Nichols is experimental method.


I used frequency analysis to determine PID coefficients, but it is complex procedure.

I'm looking for some wind-up methods, please help.

Wind up

" I'm looking for some wind-up methods, please help. "

Saturate the integral output your desired level.

integtral_e = integral + new_err*Ki*dt

if integral > my_Plimit then integral=my_Plimit;
if integral< my_Nlimit then integral=my_Nlimit;

Re: PID Cotrol

simulink program for a PDI A/D-D/A converter and a PDI for a CPU

Re: PID Cotrol

u can use velocity PID type algorithm. since in velocity the problem of anti windup is not present so you can use this methosd.

velocity PID is nothing but difference of positional PID which is normal PID with base value

o/p = base value + kp + ki + kd

velocity = op(t) + op(t-1)

if u work on it u will find that integral term is missing and hence the problem of antiwindup is taken care


PID Cotrol

I wonder what PID really is?software or hardware can perform it?or both?

Re: PID Cotrol

yangxh said:
I wonder what PID really is?software or hardware can perform it?or both?

It's a control technique or part of the control system. It's called regulator or compensator also. It's purpose is to match the actual value and desired value as wanted. A small example: You want to make a room's temperature 30°C. You measure it 20°C. Now you must increase the heater's setting. But how much will you increase it? Generally you want to reach 30°C as fast as possible. If you increase much it can exceed 30°C. If you increase less, it may take a lot of time to reach 30°C. PID determines how much you'll increase it. As you can easily see, for optimum increase value to reach 30°C, without exceeding 30°C and reaching it as fast as possible, you must determine optimum paramater values for PID. This depends on the heater's heating properties and response of the environment to the heater's heating action. So for each system you need to develop a way to obtain optimum PID values. There are practical and theoretical ways. But there is not one solution. Trial & error is more or less a part of the design.

It can be implemented by software and/or hardware.

Re: PID Cotrol

PID is part of a feedback control system.

A feedback control system measures the output of the system and corrects it's performance against an input.
A PID contains/is a feedback path that contains a Preportional Intergral and Derivitave component of the output.


Re: PID Cotrol

Thank you !
I know something about step respond.And some books usually take it as examples for the PID instruction.It seems the PID functioned just at the beginning.BUT in many cases the inputs are not step only .
They are changed in many ways .ANd if the input changes quickly,while the PID can't follow the changing in time.the result may be that the output is trembling or not stable.
Does anyone can explain it.Thank you!

PID Cotrol

Dammm :-(

Most of the links above are dead...

I am doing a Temp controlled watertank heater (just 2 liters), and would like to use PID

Am going to use AVR + DS1820 + Heater + WinAVR

Any hints , especially some sourcecode in C would be appreciated.


Not open for further replies.

Part and Inventory Search

Welcome to