PID simple code ??

Thread Starter

eric_s88

Joined Apr 20, 2011
158
Hi everyone..

May someone help me in PID simple code ?

I know this : I have to calculate the error = desirevalue - actualvalue , and then do some other calculation on this " error "..

any help ? :(
 

tshuck

Joined Oct 18, 2012
3,534
You seem to have some uncertainty in your understanding.

PID uses the error to determine what value should be applied to the controlled device(plant) to make the input minus the feedback quantity equal to zero (indicating the controlled parameter is at the commanded input).

A PID controller uses the error (current error, rate of change of the error[derivative], and accumulated error[integral]) multiplied by some constant values(\(k_p\), \(k_i\), & \(k_d\)) to determine the output parameter. In tuning a PID, one selects the \(k_p\), \(k_i\), & \(k_d\) & to accomplish the controller requirements (e.g. rise time, overshoot, response type, etc.)

In digital systems, the derivative is no more than the difference between the current error and the previous error, where the integral is the current error added to previous errors.
 
Last edited:

crutschow

Joined Mar 14, 2008
34,452
You might consider a type of control loop that doesn't require calculation of the integral or differential of the signal as PID does which is Fuzzy Logic. It basically consists of a series of If-Then-Else loops to control the system. This can be more intuitive to write in computer code than a PID loop and can be more tolerant of system non-linearities.
 
Last edited:

Thread Starter

eric_s88

Joined Apr 20, 2011
158
You seem to have some uncertainty in your understanding.

PID uses the error to determine what value should be applied to the controlled device(plant) to make the input minus the feedback quantity equal to zero (indicating the controlled parameter is at the commanded input).

A PID controller uses the error (current error, rate of change of the error[derivative], and accumulated error[integral]) multiplied by some constant values(\(k_p\), \(k_i\), & \(k_d\)) to determine the output parameter. In tuning a PID, one selects the \(k_p\), \(k_i\), & \(k_d\) & to accomplish the controller requirements (e.g. rise time, overshoot, response type, etc.)

In digital systems, the derivative is no more than the difference between the current error and the previous error, where the integral is the current error added to previous errors.
thank you "tshuck"..
I understand from your answer that at first we have to calculate the error!
and what about calculation of (\(k_p\), \(k_i\), & \(k_d\)) ? I read somewhere that for tuning this items we need zigler nicols method ?
 

Thread Starter

eric_s88

Joined Apr 20, 2011
158
You might consider a type of control loop that doesn't require calculation of the integral or differential of the signal as PID does which is Fuzzy Logic. It basically consists of a series of If-Then-Else loops to control the system. This can be more intuitive to write in computer code than a PID loop and can be more tolerant of system non-linearities.
thank you " crutschow " . this is my project definition that I have to use PID control method , by the way I'm interested in FUZZY control too.. do you have any inrtoduction file ?
 

crutschow

Joined Mar 14, 2008
34,452
thank you " crutschow " . this is my project definition that I have to use PID control method , by the way I'm interested in FUZZY control too.. do you have any inrtoduction file ?
Click on Fuzzy Logic in my original post. Also Google Fuzzy Logic.
 
Last edited:

THE_RB

Joined Feb 11, 2008
5,438
thank you " THE_RB " ..

I have to control the Temp. of a furnace which is warm up by TEC plates!
Do you have the time constant of the furnace? ie; how many seconds it takes, for the temperature to rise 1 degree C?

Most furnaces are so slow you can use setpooint control and regulate temperature to better than 1'C. The most important thing is the thermal design, ie where the heaters are and where the sensor is, and how well the heat propagates within the space.
 
Top