Re: [CAD_CAM_EDM_DRO] PID in a PIC
Posted by
Spehro Pefhany
on 2000-08-10 16:24:18 UTC
At 02:37 PM 8/10/00 -0700, you wrote:
PID algorithm.
Error should be (SP - PV), so you get negative feedback.
A more usual algorithm you will see more frequently is
Output = K (1 + (dt/Ti) * sum + Td*(Error-OldError)/dt)
Where K is dimensionless (gain) and Ti, Td have units of time.
These algorithms are seldom used in practice as-is because they
don't work very well without modifications.
Normally the derivative equation has to be modified because of noise
considerations. You also have to think about the resolution of the
input and the effect that will have on the "D" operation. In fact, you
may only need a PI controller. I usually program a single pole
digital filter for this purpose. You also should make the sample
time reasonably large in comparision with the response time of the
system if you want to get a sensible derivative signal.
Imagine a situation where the sample rate was very high, the system
response rate slow and the resolution poor. You would get zero derivative
signal until the bit transitions when you would get a huge signal that
could saturate the output, then the signal would disappear with the next
sample.
You also need to initialize Sum to zero (!) or some other number in some
cases, and you should inhibit further integration when the output is
saturated, otherwise you will get what is called "reset windup" happening.
This can cause the controller to oscillate.
Best regards,
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Spehro Pefhany --"it's the network..." "The Journey is the reward"
speff@... Info for manufacturers: http://www.trexon.com
Embedded software/hardware/analog Info for designers: http://www.speff.com
Contributions invited->The AVR-gcc FAQ is at: http://www.bluecollarlinux.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>I came up with this 'C' code from an "Embedded Systems Programming"This is an ok start. This is called the "ideal" or non-interactive
>magazine pseudo code example, am I on the right track?
>
>dt = .001; // 1000 loops/sec?
>
>while(1)
> {
> Sum = OldSum + Error;
> Output = (Kp * Error) + (Ki * Sum * dt) + (Kd * (Error -
>OldError)/dt);
> OldError = Error;
> OldSum = Sum;
> }
PID algorithm.
Error should be (SP - PV), so you get negative feedback.
A more usual algorithm you will see more frequently is
Output = K (1 + (dt/Ti) * sum + Td*(Error-OldError)/dt)
Where K is dimensionless (gain) and Ti, Td have units of time.
These algorithms are seldom used in practice as-is because they
don't work very well without modifications.
Normally the derivative equation has to be modified because of noise
considerations. You also have to think about the resolution of the
input and the effect that will have on the "D" operation. In fact, you
may only need a PI controller. I usually program a single pole
digital filter for this purpose. You also should make the sample
time reasonably large in comparision with the response time of the
system if you want to get a sensible derivative signal.
Imagine a situation where the sample rate was very high, the system
response rate slow and the resolution poor. You would get zero derivative
signal until the bit transitions when you would get a huge signal that
could saturate the output, then the signal would disappear with the next
sample.
You also need to initialize Sum to zero (!) or some other number in some
cases, and you should inhibit further integration when the output is
saturated, otherwise you will get what is called "reset windup" happening.
This can cause the controller to oscillate.
Best regards,
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Spehro Pefhany --"it's the network..." "The Journey is the reward"
speff@... Info for manufacturers: http://www.trexon.com
Embedded software/hardware/analog Info for designers: http://www.speff.com
Contributions invited->The AVR-gcc FAQ is at: http://www.bluecollarlinux.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Discussion Thread
Alan Marconett KM6VV
2000-08-10 14:38:32 UTC
PID in a PIC
Spehro Pefhany
2000-08-10 16:24:18 UTC
Re: [CAD_CAM_EDM_DRO] PID in a PIC
Tony Jeffree
2000-08-13 13:34:53 UTC
Re: [CAD_CAM_EDM_DRO] PID in a PIC
Dave Kowalczyk
2000-08-14 06:21:52 UTC
Re: PID in a PIC
Alan Marconett KM6VV
2000-08-14 11:28:23 UTC
Re: PID in a PIC
Dave Kowalczyk
2000-08-29 20:06:40 UTC
Re: PID in a PIC