Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com 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.

Code in C for PID temperature controller

Status
Not open for further replies.

ritula.thakur

Newbie level 2
Joined
Jun 9, 2007
Messages
2
Helped
3
Reputation
6
Reaction score
1
Trophy points
1,283
Activity points
1,302
pid c code

I want to develop a 8051 based PID temeperature controller.i will be using IC temperture sensor LM35DZ .
Please send me the code in C for the same on my mail id ritula.thakur@gmail.com.
Writing code in C is not my cup of tea.Im gud in developing hardware but when softwware comes i get panicky.so please please help me. I any one has the full code please mail it to me as soon as possible. i shall e highly obliged
Thanks in advance
 
pid control c code

To be moore precise abt my project. The temp sensor LM35DZ will be sensing the actual temperature of process and this temp will be converted into digital form by ADC 0809 and sent to microcontroller.The user can set the desired temp through keyboard.There is also LCD interfacing which will display the actual tempertaure and set temp.Th eprogram in C will containg PID algorithm to operate a relay which is connected to heater and thus accordingly turn it ON and OFF.
 

    V

    Points: 2
    Helpful Answer Positive Rating
    V

    Points: 2
    Helpful Answer Positive Rating
pid control code

Simple PID

PID = GainP * actual error + GainI * SUM(previous errors) + GainD * (actual error - last error)

error = sp(set point) - pv(process value)


float pid (float sp, float pv)
{

err_old = err;
err = sp - pv;

// note
P_err = err;
I_err += err_old;
D_err = err - err_old;

return 0.1*P_err + 0.3*I_err + 0.02*D_err;

}


//note. Dead zone example: if (err<2 && err>-2){err=0;}
 
pid controller c code

Good explanation oscar_pdx.
 

c code pid

/*u=kp*(e+Td*diff(e)+Td*int(e))
y0=analog input 1;
r0=ref=set point or reference;
T=sample time;
qd=diff constant=Kp*Td/T; //Td:diff time
qi=integral cosntant=Kp*T/Ti; //Ti:Integration time
Kp=prop gain;*/

float pid (float r0, float y0)
{
e0=r0-y0;
D=qd*(e0-e1);
if (((u>umin)|(e>0))&((u<umax)|(e<0))) //antiwindup integral
I=I+qi*(r0-y0);

u=Kp*e0+D+I;//pid control signal
if (u>umax) u=umax; //antiwindup PID
if (u<umin) u=umin;

e1=e0; //save old values
y1=y0;
}
 
simple pid c code

Fernando Vasquez said:
if (((u>umin)|(e>0))&((u<umax)|(e<0))) //antiwindup integral

Your code should use the || and && operators. I put in bold the problem areas.

& and | are binary bitwise operators and not logical operators.
 

This all code ref is not working properly....
I want to inplement full controlled pid...
How can i do that please help me out in this...

Thanks...

kapilddit...
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top