Hi Bruce,
I think I see a source of confusion. These are the comments from devEpidSoft.c
/* A discrete form of the PID algorithm is as follows
* M(n) = KP*(E(n) + KI*SUMi(E(i)*dT(i))
* + KD*(E(n) -E(n-1))/dT(n)
* where
* M(n) Value of manipulated variable at nth sampling instant
* KP,KI,KD Proportional, Integral, and Differential Gains
* NOTE: KI is inverse of normal definition of KI
* E(n) Error at nth sampling instant
* SUMi Sum from i=0 to i=n
* dT(n) Time difference between n-1 and n
*/
Note that there is an unmatched open parenthesis in the equation! It is this one: KP*(
The correct version of that comment, which reflects how the calculation is actually done is:
* M(n) = KP*(E(n) + KI*SUMi(E(i)*dT(i))
* + KD*(E(n) -E(n-1)))/dT(n)
I added a close parenthesis here: "E(n-1)))/"
So KP is multiplying the entire numerator of that expression, i.e. it multiplies KI and KD.
Both equations in your original message also have that unmatched open parenthesis.
I have fixed the incorrect comment in devEpicsSoft.c and committed to SVN.
Mark
From: Bruce Hill [mailto:[email protected]]
Sent: Wednesday, February 27, 2013 12:37 AM
To: Mark Rivers
Cc: [email protected]
Subject: Question about epid record
Hi Mark,
I'm in the process of replacing a genSub based PID controller with
the epid record that you and Bob developed, and I'm puzzled by a difference
in how the two compute the I and D terms.
In the classical PID algorithm, the value of M(n), the manipulated variable is
M(n) = KP*(E(n) + KI*SUMi(E(i)*dT(i)) + KD*(E(n) -E(n-1))/dT(n)
In fact, the above is from line 33 of devEpidSoft.c, and agrees with
other descriptions I've found of the PID calculation.
However, in the do_pid() function, and in epidRecord.html, the
calculation includes the KP gain in the integral and derivative terms.
M(n) = KP*(E(n) + KP*KI*SUMi(E(i)*dT(i)) + KP*KD*(E(n) -E(n-1))/dT(n)
I can scale my KI and KD gain factors by KP to get the equivalent result,
but I don't see why the effective integral gain should be affected when
the proportional gain is tweaked. Ditto for KD.
Any comments or clarification would be appreciated.
Thanks,
- Bruce
--
Bruce Hill
Member Technical Staff
SLAC National Accelerator Laboratory
- References:
- Question about epid record Bruce Hill
- Navigate by Date:
- Prev:
AW: Question about epid record Pal Trivan
- Next:
Re: Installing EPICS&MEDM on UBUNTU John Hammonds
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
<2013>
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
Re: Question about epid record Bruce Hill
- Next:
'APS event receiver' type event record can not be processed Zhang Yuliang
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
<2013>
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
|