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.

Looking for a code to control heater through PID

Status
Not open for further replies.

lats

Full Member level 4
Joined
Oct 27, 2005
Messages
217
Helped
13
Reputation
26
Reaction score
6
Trophy points
1,298
Activity points
2,958
hi all
m designing a pic 16f876 based pid temperature controller in which i m using lm35 as a temperature sensor. i have to control heater thru pid control. m done with the tempearture part ,i.e displaying temp on lcd . but m new to pid.i dont know the basic use of it. can u please explain me how to control heater thru pid. wht is the basic idea behing this.

can anyone provide me the code for this. it would be of grate help too me.

thnks all

byeeee
 

creative_35

Full Member level 1
Joined
Apr 10, 2006
Messages
95
Helped
9
Reputation
18
Reaction score
3
Trophy points
1,288
Location
Under Mango Tree
Activity points
2,031
pid routine c

According to my knowledge PID is nothing but stabilize the temperature in a
set point. while we control the temperature of a closed area, the heater
element will stop functioning as soon as the temp.
sensor reaches the set point. but even after disconnecting the power to heater
coils you can see the temperature may increase some more degrees.and when the temp. decreases the heater coil may start in the set point. but it will take
some time to heat up the coil and flow the hot air everywhere.
That time is critical in some applications where PID is used. And the theory of
PID is to control the power to the heater element with respect to the values of
sensor. for example if your set point is 150 degree and your heater is fully
functional. it's increasing the temperature to achive 150. Assume that if you
reach 125, you can give 3/4 power to heater coil, so that it will reduce the
heating speed.(increase time) and while your temp reaches to 135 again reduce
the power to the heating element as half. so it will take more time to achive
150 but once it reaches to 150 it will be stable there. calculating the proportion
of heating speed and the values of sensor and set the minimum and maximum values of sensor to stabilise the set point through software is called as PID control.
heating element power can be controlled through Semiconductor Switches like TRIAC,IGBT etc. and it can be easly managed by PICMICRO.
 

lats

Full Member level 4
Joined
Oct 27, 2005
Messages
217
Helped
13
Reputation
26
Reaction score
6
Trophy points
1,298
Activity points
2,958
pid con 16f877

hi all
thnkyou so much for replying .now i understood the basic of pid.but wht abt the equation used. there is this big equation involved in it. how to implement that and solve it. does anybody have code for pid equation solving.it would be of grt help to me.

When the program starts it should show following message on screen.
When you scroll down using decrement or down button it should show the following message.
proportional value=
intergral value=
derevative value=

When you scroll down further it should show message displayed below.


Same sequence when you move cursor up. The switches RA0 and RA1 are used to move the cursor up/down to highlight one of the choices. RA2 is used to select the highlighted choice. In the above sequence value means numbers. So, the switches RA0 is used to move cursor up and for increment of selected term means for PID values. RA1 is for scrolling down as well as for decrement of values. RA2 is used for selection. When the particular line or term is highlighted means selected it’s values can be incremented or decremented using scrolling up and down button. It can be set when value is selected or done. Then if we want to change another value move up or down it can be done by up, down buttons and term can be selected by selection button. Then, set the values of that term using up, down and when done press select button. So, by this way we can use three switches and LCD screen to make selection of PID values and for display of output. The screen can also be used to display the output value as well
 

veioloko

Member level 1
Joined
Aug 18, 2006
Messages
36
Helped
4
Reputation
8
Reaction score
1
Trophy points
1,288
Location
Brazil
Activity points
1,493
heater with pic16f877a

does anyone has a c pid routine?
 

bbgil

Full Member level 2
Joined
Mar 11, 2006
Messages
135
Helped
13
Reputation
26
Reaction score
9
Trophy points
1,298
Activity points
2,321
+lasterror +preverror

i have a pid routine in c here. i got it from the net as well. hope this helps.

/***************************************************************************\
PID Function

Author : Greg Young, Z-World.

The PID (Proportional Integral Derivative) function is used in mainly
control applications. PIDCalc performs one iteration of the PID
algorithm.

While the PID function works, main is just a dummy program showing
a typical usage.
\***************************************************************************/

typedef struct PID {
double SetPoint; // Desired Value

double Proportion; // Proportional Const
double Integral; // Integral Const
double Derivative; // Derivative Const

double LastError; // Error[-1]
double PrevError; // Error[-2]
double SumError; // Sums of Errors
} PID;

/*=========================================================================*\
Perform One PID Iteration
\*=========================================================================*/

double
PIDCalc ( PID *pp,
double NextPoint
)

{ double dError,
Error;

pp->SumError += (Error = pp->SetPoint - NextPoint);
dError = pp->LastError - pp->PrevError;
pp->PrevError = pp->LastError;
pp->LastError = Error;
return ( pp->Proportion * Error
+ pp->Integral * pp->SumError
+ pp->Derivative * dError
);
}

/*=========================================================================*\
Initialize PID Structure
\*=========================================================================*/

void
PIDInit ( PID *pp
)

{ memset ( pp,0,sizeof(PID) );
}

/***************************************************************************\
Main Program
\***************************************************************************/

double
sensor ( void // Dummy Sensor Function
)

{ return 100.0;
}

void
actuator ( double rDelta // Dummy Actuator Function
)

{}

void
main ( void
)

{ PID sPID; // PID Control Structure
double rOut; // PID Response (Output)
double rIn; // PID Feedback (Input)

PIDInit ( &sPID ); // Initialize Structure
sPID.Proportion = 0.5; // Set PID Coefficients
sPID.Integral = 0.5;
sPID.Derivative = 0.0;
sPID.SetPoint = 100.0; // Set PID Setpoint

for (;;) { // Mock Up of PID Processing
rIn = sensor (); // Read Input
rOut = PIDCalc ( &sPID,rIn ); // Perform PID Interation
actuator ( rOut ); // Effect Needed Changes
}
}
 

garg29

Advanced Member level 1
Joined
Nov 17, 2004
Messages
451
Helped
25
Reputation
50
Reaction score
9
Trophy points
1,298
Activity points
3,605
button ra0 pic16f877a

how do you get these constant values & from where?

sPID.Proportion = 0.5; // Set PID Coefficients
sPID.Integral = 0.5;
sPID.Derivative = 0.0;
sPID.SetPoint = 100.0;
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top