Discussion forum for the BasicX family of microcontroller chips.
Temperature control - ricinecwh - Jul 1 7:31:50 2006
My project is to control the temperature of a plant.
The temperature of the plant will be monitored and as an input of the
basicX controller.
If the input temperature is larger than temperature we set,
the controller will adjust it to the correct temperature by
increasing or decreasing the current to the TEC which is inside the
plant.
The problem is how can the controller automically adjust the tempature
in the basic X
Some people tell me to use the PID controller
however, i find it is difficult to fix the three variables.
Is there anypeople familiar with the PID?
or
there are any alternative way to fix it?

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: Temperature control - Craig - Jul 3 10:15:03 2006
--- In b...@yahoogroups.com, "ricinecwh"
wrote:
>
> The problem is how can the controller automically adjust the
tempature
> in the basic X
> Some people tell me to use the PID controller
> however, i find it is difficult to fix the three variables.
> Is there anypeople familiar with the PID?
> or
> there are any alternative way to fix it?
>
Depending upon the required accuracy, you may or may not need PID
control. Will your control device be simple heat on/off, cool on/off
or do you plan on proportional control where the greater the
difference between actual temperature and desired (set point)
temperature you will increase/decrease the rate at which heat is
added or removed?
That question MUST be answered first.
If you will be using proportional control then you will want to
program a PID controller. Yes you can use PID with simple on/off
control but it is like squirrel hunting with an elephant gun.
There are many PID formulas available on the WEB and I would suggest
using the simplest expressions that maintain the desired control.
The expressions shown below are Pseudo expressions at best just to
illustrate the concepts.
PID can be thought as 3 stand alone controllers with their resulting
outputs added together to form a common control output.
The "P" in PID stands for proportional. The further your actual
temperature (or any other measurement) is from the desired (set
point) the P controller will increase/decrease output. If for example
you are only 1 degree high or low, you may not need much of a change
from your controlling device (heater, fan etc.) On the other hand if
there is a 20 degree difference you want you system to have more
output to bring the temperature back in line faster.
Error =(Set point-Actual)
P Output = (Error * P-Gain)
(you enter the P-Gain based on the system's response tea pot Vs
swimming pool)
You can run a system with just proportional gain but you will soon
find out that you will never reach the exact set point as when the
error is very small you don't have much controller output. You can
keep adding gain but eventually you will just keep overshooting then
undershooting your set point. This is usually refered to as
Proportional Droop.
INTEGRAL:
The "I" in PID is for Integral. In the most basic terms,
the integral gain is determined by the error between actual and set
point and the length of time the system has been away from the set
point. Adding Integral gain solves the problem with a Proportional
only system never reaching set point as the Integral will keep adding
to the P output positive or negative output until you reach the set
point.
For all but the most super critical temperature applications P+I will
be sufficient.
For a very, very, very simple "I" control you take the (Error * Gain)
and keep adding/subtracting that result at a given timed interval.
Care must be taken to keep the Gain as small as possible to avoid
wind up where the combined P&I values add up so fast that the system
reaches its limit way too soon and takes forever to come back under
control. Again based upon what you are trying to control (tea
pot/swimming pool) your system will require more or less time to
respond and excessive "I" gain or too short an interval will cause
overshoot/undershoot.
The "I" term will keep adding/subtracking its output every X seconds
(P-Interval)
Differential:
There are certain applications that you want to limit (or slow down)
the
response to prevent overshoot. If you have too much P or I Output it
is easy to overshoot your set point and the system will oscillate and
be unstable. The "D" in PID is Differential Gain. Again in the most
simplest of terms it looks at the "rate of change" and if that rate
is too high, the differential Output will be added/subtracted from
the P&I output sum.
Pseudo math for Differential would be: (Last Error - Current Error) *
DGain. If the difference in errors is very small the "D" output will
be very small. If the difference in Current/Last error is large then
the system is responding very fast and the DOutput will be high and
that output can be subtracted from the P+I sum.
A good cruise control in a car should have "D" gain to prevent the
car from being over, under, over, under.... speed.
I have found many people who use PIDs all the time and screw up the
concept of "I" control because there are 2 user defined values and
depending upon which one you talking about more "I" will speed up or
slow down the response. If you increase "I GAIN" the system will
respond faster. If you increase "I Interval (time) the system will
slow down because the change in "I" output is done at a slower rate.
Don't get caught in this trap. Some otherwise intelligent engineers
will argue this point like you were attacking their religion.
PID only sounds complex unless you break it down into its 3
components and realize the math for each component is rather simple
and then you just add the 3 outputs for your final control and send
it to your D/A converter.

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )Re: Temperature control - Craig - Jul 3 10:30:42 2006
--- In b...@yahoogroups.com, "Craig"
wrote:
>
> --- In b...@yahoogroups.com, "ricinecwh" wrote:
>
> >
> > The problem is how can the controller automically adjust the
> tempature
> > in the basic X
> > Some people tell me to use the PID controller
> > however, i find it is difficult to fix the three variables.
> > Is there anypeople familiar with the PID?
> > or
> > there are any alternative way to fix it?
If you understood my previous post then setting your control values
should be done in stages.
NOTE: I would use "Single" data types for the Gains as you will
quickly find integer steps will be too inaccurate.
First: Enter "0" for I-Gain and D-Gain (if you decide to use it).
Second: Using only P-Gain increase or decrease that gain value until
the system tries to reach set point but does NOT over/undershoot.
Back off the P-Gain until the over/undershoot just stops.
Third: Start adding some I-Gain until the system starts to
over/undershoot then back off a little. NOTE: the I-Interval should
be some logical value. For example if I were controlling the
temperature of a swimming pool adding I-Gain every 10ms would not
make a lot of sense. If I were controlling a tea pot a 5 second P-
Interval might be a good starting point. You need to know the inertia
of what you are controlling.
Forth: If you decided to use "D" gain, and you might if you found
the "I-Gain" was way too sensitive, start adding "D-Gain" until
system becomes stable and not too slow. If you go overboard on "D-
GAIN" the system will not be very responsive. I doubt you will need
Differential control but it is good to know what it does.
______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )Re: Temperature control - Craig - Jul 3 10:38:42 2006
--- In b...@yahoogroups.com, "Craig"
wrote:
>
> --- In b...@yahoogroups.com, "ricinecwh" wrote:
>
> >
> > The problem is how can the controller automically adjust the
> tempature
> > in the basic X
> > Some people tell me to use the PID controller
> > however, i find it is difficult to fix the three variables.
> > Is there anypeople familiar with the PID?
> > or
> > there are any alternative way to fix it?
>
I had this page on my hard drive but I do not know the URL. It is
another way of explaining PID and some ACTUAL math. While the
approach is different, both work.
Proportional Integral Derivative Control
PID, although developed in the 1940s, has had staying power as a
technique for developing closed-loop process control systems. The
reason for its longevity is that PID is easily implemented in
software and performs well for linear control problems. PID works
very well when the suitable gain values are employed and the system
responds smoothly over the range of interest. A non-linear system can
usually be controlled by dividing it into multiple ranges, and
selecting optimal gain values for each range.
PID Equations
E = Setpoint - PV
CV = Kp * E + Ki * Esum + Kd * PVdelta
PV = ProcessFunction(CV)
Where
CV is the control variable. This value might be a voltage or valve
position - something that causes the control system to change.
Increasing the control variable eventually results in a measurable
increase in the PV. Similarly, decreasing the CV causes the process
to decrease the PV. A car's throttle position is the CV in a cruise-
control application.
E is the error, the difference between the desired value (Setpoint)
and the latest measured process variable (PV) value. The value of E
is positive while PV is too low, and negative when PV is too large.
Esum is the sum of errors (E). This sum is updated at a regular
interval where Esum = Esum + E. When E is positive (PV is too low)
then Esum will grow larger at each update. When E is negative (PV is
too high) then Esum will become smaller, or even grow negatively.
When E is zero (PV is at the setpoint) then Esum remains constant.
When the system is stable, both E and PVdelta are zero, and the only
component contributing to CV is the Ki * Esum term.
Kd is the derivative gain. This factor controls how strongly the
control system will react to changes in the process variable (PV)
value. The affect of the Kd * PVdelta component is to dampen the
system by reducing acceleration. Many systems run fine with Kd set to
0, resulting in what is known as a PI control loop.
Ki is the integral gain. This factor controls how strongly the
control system will react to the continuous sum (Esum) of errors (E).
Kp is the proportional gain. This factor controls how strongly the
control loop will react to the instantaneous error (E). The Kp * E
component is positive when PV is too low, negative when PV is too
high, and zero when the PV is at the set point value.
ProcessFunction represents the process. Given a control input CV, the
process will, after some delay, update some easily measured
parameter, PV. The purpose of the PID control loop is to adjust the
value of CV to obtain the desired value for PV (and thereby make
something work a little better).
PV is the process variable value. This is some aspect of the process
that can be measured - and therefore managed. The PV is what we are
trying to control. Changing the control variable (CV) tweeks the
process and eventually results in a change to the measured PV value.
A car's speed is the PV in a cruise-control application.
PVdelta is the rate of change of the process variable (PV) value.
This can be calculated by subtracting the latest PV measurement from
the previously measured PV value. The PVdelta is negative when PV is
increasing, and positive when PV is decreasing. A car's acceleration
is the PVdelta in a cruise-control application.
Setpoint is the desired value for the process variable (PV). A car's
desired cruising speed is the Setpoint in a cruise-control
application.
Application
The most flexible way to view the PID calculation is as 3 independent
terms that sum to become the control variable value. That is, CV =
P+I+D. This arrangement of the PID calculation yields flexibility in
adjusting gain values. The following sections break down how each
term is calculated.
Proportional Term (Kp * E)
The proportional term of CV can be updated as often as new
measurements of PV can be obtained. Unlike the Integral and
Derivative terms, there is no reason to wait for the process to
respond to the latest correction. The proportional correction to CV
can be applied the instant that any Error is detected. In practice,
it is usually a good idea to avoid computing Kp * E when E is lower
than some threshold in order to avoid making constant small
corrections to CV due to noise in the measurement of PV. Such a "dead-
zone" can avoid wear and tear by preventing unnecessary "hunting"
around the setpoint.
The proportional term of CV gets progressively weaker as the PV gets
closer to the Setpoint. After some time, the Kp * E will exactly
balance drag or friction in the process and reach a stable point
where PV is just below the Setpoint.
Selecting a value for Kp can be determined by experimentation. Start
with Ki and Kd at zero. Begin with estimated values and then increase
Kp until the control system oscillates, then back off to a stable
setting. The Kp may later be increased after adjusting Kd.
Integral Term (Ki * Esum)
The integral term of CV can be updated at a frequency that is limited
by the hysteresis in the system. The PID should update the CV then
wait for sufficient time to allow the process to make a significant
and measureable affect on the PV before the next calculation. At each
calculation, Esum = Esum + E. In most applications, the integral term
should not be allowed to exceed the lower and upper limits for the CV
(Esum < CVmax/Ki). As with the proportional term, it is good practice
to not update the integral term when the Error (E) is below some
threshold of tolerance. This can avoid constant small changes to CV,
causing unnecessary wear on the components of the control system.
The integral term of CV will grow (or shrink) indefinitely until the
Error (E) becomes zero. In this way, a PI or PID loop will eventually
drag PV to the setpoint.
Selecting a value for Ki can be determined by experimentation. Start
with small values and increase Ki until oscillation is first
observed. Reduce Kp to remove the oscillation.
Derivative Term (Kd * PVdelta)
The derivative term of CV is updated at a frequency that is limited
by the hysteresis in the system. The PID should update the CV then
wait for sufficient time to allow the process to make a significant
and measureable affect on the PV before the next calculation.
Normally, the derivative and integral terms of the PID equation are
calculated at the same frequency. At each calculation, PVdelta =
PVprevious - PVnow.
The derivative term of CV will become large when PV is changing
quickly, but is not a factor in systems that change very slowly. This
component tends to dampen the system and its use may allow larger
values for Kp without oscillation.
Selection of the best values for Kd requires iterative testing. First
choose a trial value for Kd, then increase Kp until oscillation is
observed. Try to remove the oscillation by increasing Kd. If that
works, then repeat - increasing Kp to oscillation, and then
increasing Kd to remove it. Use the largest gain settings that work
well at both minimum and maximum useful Setpoint values.
Example
The following psuedocode can be used as the basis for a simple PID
implementation
// PID Example using integers
// Constants
// Arbitrary numbers - pick appropriate values for
// the system of interest.
// INTERVAL = milliseconds for PV to react to CV
#define CVmax 255 // 0 to 255
#define PVmax 100 // 0 to 100%
#define INTERVAL 500 // 500ms between "I&D" updates
#define THRESHOLD 2 // error tolerance
// Gains
// Make these run-time tunable in a real system.
// The GAIN macro divides the gain values by 100
// to allow finer granularity using integer arithmetic.
#define Kp 500 // Kp = 5.000
#define Ki 10 // Ki = 0.100
#define Kd 10000 // Kd = 100.0
#define GAIN(g,v) (((g)*(v)+50)/100)
// Variables
int esum; // sum of errors
int pvprev; // saved previous pv value
int cvi; // integral component of CV
int cvd; // derivative component of CV
// For timekeeping
// time.h is standard C, defines CLOCKS_PER_SEC
// MS() returns milliseconds elapsed since (t)
#include
clock_t stamp; // saved timestamp (from clock())
#define MS(t) (((clock()-(t))*1000)/CLOCKS_PER_SEC)
// PID function - given a PV and Setpoint, returns the CV.
// Call this function after each time the system obtains
// a fresh value for PV.
int pid (int pv, int setpoint)
{
int cv; // return value
int error;
error = setpoint - pv;
if ( abs(error) < THRESHOLD )
{
// Error is within tolerance.
error = 0;
}
// Compute proportional term
cv = GAIN(Kp, error); // Kp * E
if ( MS(stamp) >= INTERVAL )
{
// it has been long enough since last call to
// this function for the pv value to have been
// affected by the previously computed cv
stamp = clock();
// Compute integral term by summing errors.
esum = esum + error;
// Limit integral term to CV range.
if ( esum > CVmax/Ki )
esum = CVmax/Ki;
else
if ( esum < 0 )
esum = 0;
// calculate the integral term
cvi = GAIN(Ki, esum); // Ki * Esum;
// calculate the derivative term
cvd = GAIN(Kd, pvprev - pv); // Kd * PVdelta
pvprev = pv;
}
// Add terms: P+I+D
cv = cv + cvi + cvd;
// Limit cv to allowed values
if ( cv < 0 )
cv = 0;
else
if ( cv > CVmax )
cv = CVmax;
return cv;
}

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )Re: Re: PID - "nje...@ihug.co.nz" - Jul 3 17:54:17 2006
A nice treatise Craig...I enjoyed reading it. It sounds to me as though
you are a bit of a PID enthousiast, as am I. I enjoy playing with PID,
whether it be tuning an off the shelf PID controller, or writing some
code to the job. One of the more interesting tasks I had some years ago
was controlling the sewage level & flow into a treatment plant. The
incoming sewage was pumped by three very large DC motor driven pumps,
and in addition, there was a motorised gate valve about 2m x 4m in the
intake pipe. The task was to control the level in an open channel which
was the intake into the plant, by varying the speed of the duty pump,
bringing in the two standby pumps in sequence, and as last resort,
progressively closing the gate valve. All three pumps were on speed
controllers. If you got it wrong, you flooded the floor of the plant
which raised eyebrows. I remember once standing next to the channel (
which was about a meter wide and several meters deep, and I heard the
pumps suddenly start to slow...( a software bug)...Before I could move,
I was up to my ankles in %$#%$
The PID control was done in a PLC and written from scratch. It took a
while to get it right, and the main problem was the huge range of
conditions and incoming flow rates, which varied by 200-300% depending
on the weather. The non-linear pump curves did not help. In summer, one
pump would do the job at about 1/2 speed. In the winter during heavy
rain ( which caused leakage into the sewer system) all three pumps would
be flat out, and the gate valve would be modulating slowly. Its response
was quite slow obviously.
n
Craig wrote:
> --- In b...@yahoogroups.com
,
> "ricinecwh" wrote:
>
> >
> > The problem is how can the controller automically adjust the
> tempature
> > in the basic X
> > Some people tell me to use the PID controller
> > however, i find it is difficult to fix the three variables.
> > Is there anypeople familiar with the PID?
> > or
> > there are any alternative way to fix it?
> > Depending upon the required accuracy, you may or may not need PID
> control. Will your control device be simple heat on/off, cool on/off
> or do you plan on proportional control where the greater the
> difference between actual temperature and desired (set point)
> temperature you will increase/decrease the rate at which heat is
> added or removed?
>
> That question MUST be answered first.
>
> If you will be using proportional control then you will want to
> program a PID controller. Yes you can use PID with simple on/off
> control but it is like squirrel hunting with an elephant gun.
>
> There are many PID formulas available on the WEB and I would suggest
> using the simplest expressions that maintain the desired control.
>
> The expressions shown below are Pseudo expressions at best just to
> illustrate the concepts.
>
> PID can be thought as 3 stand alone controllers with their resulting
> outputs added together to form a common control output.
>
> The "P" in PID stands for proportional. The further your actual
> temperature (or any other measurement) is from the desired (set
> point) the P controller will increase/decrease output. If for example
> you are only 1 degree high or low, you may not need much of a change
> from your controlling device (heater, fan etc.) On the other hand if
> there is a 20 degree difference you want you system to have more
> output to bring the temperature back in line faster.
>
> Error =(Set point-Actual)
> P Output = (Error * P-Gain)
> (you enter the P-Gain based on the system's response tea pot Vs
> swimming pool)
>
> You can run a system with just proportional gain but you will soon
> find out that you will never reach the exact set point as when the
> error is very small you don't have much controller output. You can
> keep adding gain but eventually you will just keep overshooting then
> undershooting your set point. This is usually refered to as
> Proportional Droop.
>
> INTEGRAL:
> The "I" in PID is for Integral. In the most basic terms,
> the integral gain is determined by the error between actual and set
> point and the length of time the system has been away from the set
> point. Adding Integral gain solves the problem with a Proportional
> only system never reaching set point as the Integral will keep adding
> to the P output positive or negative output until you reach the set
> point.
>
> For all but the most super critical temperature applications P+I will
> be sufficient.
>
> For a very, very, very simple "I" control you take the (Error * Gain)
> and keep adding/subtracting that result at a given timed interval.
> Care must be taken to keep the Gain as small as possible to avoid
> wind up where the combined P&I values add up so fast that the system
> reaches its limit way too soon and takes forever to come back under
> control. Again based upon what you are trying to control (tea
> pot/swimming pool) your system will require more or less time to
> respond and excessive "I" gain or too short an interval will cause
> overshoot/undershoot.
>
> The "I" term will keep adding/subtracking its output every X seconds
> (P-Interval)
>
> Differential:
> There are certain applications that you want to limit (or slow down)
> the
> response to prevent overshoot. If you have too much P or I Output it
> is easy to overshoot your set point and the system will oscillate and
> be unstable. The "D" in PID is Differential Gain. Again in the most
> simplest of terms it looks at the "rate of change" and if that rate
> is too high, the differential Output will be added/subtracted from
> the P&I output sum.
>
> Pseudo math for Differential would be: (Last Error - Current Error) *
> DGain. If the difference in errors is very small the "D" output will
> be very small. If the difference in Current/Last error is large then
> the system is responding very fast and the DOutput will be high and
> that output can be subtracted from the P+I sum.
>
> A good cruise control in a car should have "D" gain to prevent the
> car from being over, under, over, under.... speed.
>
> I have found many people who use PIDs all the time and screw up the
> concept of "I" control because there are 2 user defined values and
> depending upon which one you talking about more "I" will speed up or
> slow down the response. If you increase "I GAIN" the system will
> respond faster. If you increase "I Interval (time) the system will
> slow down because the change in "I" output is done at a slower rate.
> Don't get caught in this trap. Some otherwise intelligent engineers
> will argue this point like you were attacking their religion.
>
> PID only sounds complex unless you break it down into its 3
> components and realize the math for each component is rather simple
> and then you just add the 3 outputs for your final control and send
> it to your D/A converter.
>
>------------------------------------------------------------------------
>
>No virus found in this incoming message.
>Checked by AVG Free Edition.
>Version: 7.1.394 / Virus Database: 268.9.8/380 - Release Date: 30/06/2006
>
>

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )Re: Temperature control - ricinecwh - Jul 4 11:58:52 2006
Thank you for your help
I am now starting the maths of the PID
--- In b...@yahoogroups.com, "Craig"
wrote:
>
> --- In b...@yahoogroups.com, "ricinecwh" wrote:
>
> >
> > The problem is how can the controller automically adjust the
> tempature
> > in the basic X
> > Some people tell me to use the PID controller
> > however, i find it is difficult to fix the three variables.
> > Is there anypeople familiar with the PID?
> > or
> > there are any alternative way to fix it?
> > Depending upon the required accuracy, you may or may not need PID
> control. Will your control device be simple heat on/off, cool
on/off
> or do you plan on proportional control where the greater the
> difference between actual temperature and desired (set point)
> temperature you will increase/decrease the rate at which heat is
> added or removed?
>
> That question MUST be answered first.
>
> If you will be using proportional control then you will want to
> program a PID controller. Yes you can use PID with simple on/off
> control but it is like squirrel hunting with an elephant gun.
>
> There are many PID formulas available on the WEB and I would
suggest
> using the simplest expressions that maintain the desired control.
>
> The expressions shown below are Pseudo expressions at best just to
> illustrate the concepts.
>
> PID can be thought as 3 stand alone controllers with their
resulting
> outputs added together to form a common control output.
>
> The "P" in PID stands for proportional. The further your actual
> temperature (or any other measurement) is from the desired (set
> point) the P controller will increase/decrease output. If for
example
> you are only 1 degree high or low, you may not need much of a
change
> from your controlling device (heater, fan etc.) On the other hand
if
> there is a 20 degree difference you want you system to have more
> output to bring the temperature back in line faster.
>
> Error =(Set point-Actual)
> P Output = (Error * P-Gain)
> (you enter the P-Gain based on the system's response tea pot Vs
> swimming pool)
>
> You can run a system with just proportional gain but you will soon
> find out that you will never reach the exact set point as when the
> error is very small you don't have much controller output. You can
> keep adding gain but eventually you will just keep overshooting
then
> undershooting your set point. This is usually refered to as
> Proportional Droop.
>
> INTEGRAL:
> The "I" in PID is for Integral. In the most basic terms,
> the integral gain is determined by the error between actual and
set
> point and the length of time the system has been away from the set
> point. Adding Integral gain solves the problem with a Proportional
> only system never reaching set point as the Integral will keep
adding
> to the P output positive or negative output until you reach the
set
> point.
>
> For all but the most super critical temperature applications P+I
will
> be sufficient.
>
> For a very, very, very simple "I" control you take the (Error *
Gain)
> and keep adding/subtracting that result at a given timed interval.
> Care must be taken to keep the Gain as small as possible to avoid
> wind up where the combined P&I values add up so fast that the
system
> reaches its limit way too soon and takes forever to come back
under
> control. Again based upon what you are trying to control (tea
> pot/swimming pool) your system will require more or less time to
> respond and excessive "I" gain or too short an interval will cause
> overshoot/undershoot.
>
> The "I" term will keep adding/subtracking its output every X
seconds
> (P-Interval)
>
> Differential:
> There are certain applications that you want to limit (or slow
down)
> the
> response to prevent overshoot. If you have too much P or I Output
it
> is easy to overshoot your set point and the system will oscillate
and
> be unstable. The "D" in PID is Differential Gain. Again in the
most
> simplest of terms it looks at the "rate of change" and if that
rate
> is too high, the differential Output will be added/subtracted from
> the P&I output sum.
>
> Pseudo math for Differential would be: (Last Error - Current
Error) *
> DGain. If the difference in errors is very small the "D" output
will
> be very small. If the difference in Current/Last error is large
then
> the system is responding very fast and the DOutput will be high
and
> that output can be subtracted from the P+I sum.
>
> A good cruise control in a car should have "D" gain to prevent the
> car from being over, under, over, under.... speed.
>
> I have found many people who use PIDs all the time and screw up
the
> concept of "I" control because there are 2 user defined values and
> depending upon which one you talking about more "I" will speed up
or
> slow down the response. If you increase "I GAIN" the system will
> respond faster. If you increase "I Interval (time) the system will
> slow down because the change in "I" output is done at a slower
rate.
> Don't get caught in this trap. Some otherwise intelligent
engineers
> will argue this point like you were attacking their religion.
>
> PID only sounds complex unless you break it down into its 3
> components and realize the math for each component is rather
simple
> and then you just add the 3 outputs for your final control and
send
> it to your D/A converter.
>

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )Re: Temperature control - Alex Chaihorsky - Jul 4 12:28:36 2006
I had posted PID code for BX24 on this forum about two years ago. It
was in "Files" area but now the whole area looks different. But it
must be there somewhere.
This code worked very well for a very fast-responce job (fast heating
of a 5 grams copper plate with a 30 watt heater and temp control up to
0.1 deg C).
The output was PWM.
Alex.
--- In b...@yahoogroups.com, "ricinecwh"
wrote:
>
> Thank you for your help
> I am now starting the maths of the PID
>
> --- In b...@yahoogroups.com, "Craig" wrote:
> >
> > --- In b...@yahoogroups.com, "ricinecwh" wrote:
> >
> > >
> > > The problem is how can the controller automically adjust the
> > tempature
> > > in the basic X
> > > Some people tell me to use the PID controller
> > > however, i find it is difficult to fix the three variables.
> > > Is there anypeople familiar with the PID?
> > > or
> > > there are any alternative way to fix it?
> > >
> >
> > Depending upon the required accuracy, you may or may not need PID
> > control. Will your control device be simple heat on/off, cool
> on/off
> > or do you plan on proportional control where the greater the
> > difference between actual temperature and desired (set point)
> > temperature you will increase/decrease the rate at which heat is
> > added or removed?
> >
> > That question MUST be answered first.
> >
> > If you will be using proportional control then you will want to
> > program a PID controller. Yes you can use PID with simple on/off
> > control but it is like squirrel hunting with an elephant gun.
> >
> > There are many PID formulas available on the WEB and I would
> suggest
> > using the simplest expressions that maintain the desired control.
> >
> > The expressions shown below are Pseudo expressions at best just to
> > illustrate the concepts.
> >
> > PID can be thought as 3 stand alone controllers with their
> resulting
> > outputs added together to form a common control output.
> >
> > The "P" in PID stands for proportional. The further your actual
> > temperature (or any other measurement) is from the desired (set
> > point) the P controller will increase/decrease output. If for
> example
> > you are only 1 degree high or low, you may not need much of a
> change
> > from your controlling device (heater, fan etc.) On the other hand
> if
> > there is a 20 degree difference you want you system to have more
> > output to bring the temperature back in line faster.
> >
> > Error =(Set point-Actual)
> > P Output = (Error * P-Gain)
> > (you enter the P-Gain based on the system's response tea pot Vs
> > swimming pool)
> >
> > You can run a system with just proportional gain but you will soon
> > find out that you will never reach the exact set point as when the
> > error is very small you don't have much controller output. You can
> > keep adding gain but eventually you will just keep overshooting
> then
> > undershooting your set point. This is usually refered to as
> > Proportional Droop.
> >
> > INTEGRAL:
> > The "I" in PID is for Integral. In the most basic terms,
> > the integral gain is determined by the error between actual and
> set
> > point and the length of time the system has been away from the set
> > point. Adding Integral gain solves the problem with a Proportional
> > only system never reaching set point as the Integral will keep
> adding
> > to the P output positive or negative output until you reach the
> set
> > point.
> >
> > For all but the most super critical temperature applications P+I
> will
> > be sufficient.
> >
> > For a very, very, very simple "I" control you take the (Error *
> Gain)
> > and keep adding/subtracting that result at a given timed interval.
> > Care must be taken to keep the Gain as small as possible to avoid
> > wind up where the combined P&I values add up so fast that the
> system
> > reaches its limit way too soon and takes forever to come back
> under
> > control. Again based upon what you are trying to control (tea
> > pot/swimming pool) your system will require more or less time to
> > respond and excessive "I" gain or too short an interval will cause
> > overshoot/undershoot.
> >
> > The "I" term will keep adding/subtracking its output every X
> seconds
> > (P-Interval)
> >
> > Differential:
> > There are certain applications that you want to limit (or slow
> down)
> > the
> > response to prevent overshoot. If you have too much P or I Output
> it
> > is easy to overshoot your set point and the system will oscillate
> and
> > be unstable. The "D" in PID is Differential Gain. Again in the
> most
> > simplest of terms it looks at the "rate of change" and if that
> rate
> > is too high, the differential Output will be added/subtracted from
> > the P&I output sum.
> >
> > Pseudo math for Differential would be: (Last Error - Current
> Error) *
> > DGain. If the difference in errors is very small the "D" output
> will
> > be very small. If the difference in Current/Last error is large
> then
> > the system is responding very fast and the DOutput will be high
> and
> > that output can be subtracted from the P+I sum.
> >
> > A good cruise control in a car should have "D" gain to prevent the
> > car from being over, under, over, under.... speed.
> >
> > I have found many people who use PIDs all the time and screw up
> the
> > concept of "I" control because there are 2 user defined values and
> > depending upon which one you talking about more "I" will speed up
> or
> > slow down the response. If you increase "I GAIN" the system will
> > respond faster. If you increase "I Interval (time) the system will
> > slow down because the change in "I" output is done at a slower
> rate.
> > Don't get caught in this trap. Some otherwise intelligent
> engineers
> > will argue this point like you were attacking their religion.
> >
> > PID only sounds complex unless you break it down into its 3
> > components and realize the math for each component is rather
> simple
> > and then you just add the 3 outputs for your final control and
> send
> > it to your D/A converter.
>

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )Re: Re: Temperature control - Tom Becker - Jul 4 13:32:44 2006
> It was in "Files" area but now the whole area looks different.
Two clicks finds that it's still there; look in
Files/Datasheets-Appnotes-Examples-Drawings/Code Techniques. You
uploaded it as "biovirus1".
Tom

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: PID - Craig - Jul 4 20:40:27 2006
--- In b...@yahoogroups.com, "njepsen@..."
wrote:
>
> A nice treatise Craig...I enjoyed reading it. It sounds to me as
though
> you are a bit of a PID enthousiast, as am I.
Thanks, I know what you mean about the $#@% ankle deep if the pumps
don't work right.
I do like working with PIDs as once you get past 3 things happening at
once they work slick. Once properly tuned they are neat to watch
operate (only engineers would get a kick out of this).

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )