PID Controller Calulu for HERMS home-brewng ytem Introuton h oument erbe the ervaton of a PID ontroller that an be mplemente n the brew applaton he PID ontroller houl be apable of ontrollng the temperature of the Hot Lqu un HL, 90 L to wthn 05 C he HL ontan a heatng element of 3 W, whh rven by the PID ontroller output gnal Gamma [00 %] he HL temperature enor a LM9 bt gn bt, ± 033 C aurate temperature enor h oument ontan the followng nformaton Chapter : Dervaton of a tme-rete algorthm for a PID ontroller Chapter 3: Dervaton of an mprove algorthm a o-alle type C PID ontroller Chapter 4: Derpton of algorthm for fnng the optmum et of,, an value of the PID ontroller Chapter 5: Expermental reult An appenx ontanng the C oure ltng Dervaton of a tme-rete algorthm for a PID ontroller wt et PID Controller ut Hot-Lqu un HL yt yt he gener equaton for a PID ontroller n the tme-ontnuou oman : e t u t e t e τ τ eq 0 t Wth: p Proportonal Gan for our temperature ontroller, unty [% / C] / me-ontant Integral gan [e] / me-ontant Dervatve gan [e] Sample pero efault value 5 eon wt Set pont SP value for temperature I alo alle et_ n th oument et error gnal et-pont wt proe varable yt et_ ut PID output gnal, alo alle Gamma, range from [000 %] yt proe varable PV meaure temperature alo alle n th oument he orreponng equaton n the -oman then: U eq 0 E h tranfer funton ha no real pratal ue, ne the gan nreae a the frequeny nreae Pratal PID ontroller lmt th hgh frequeny gan, ung a frt orer low-pa flter h reult n the followng tranfer funton: h the eal, textboo veron of a ontnuou-tme PID ontroller See [], page 54 PID Controller Calulu, V30 Page /6 r r EHW van e Logt
PID Controller Calulu for HERMS home-brewng ytem PID Controller Calulu, V30 Page /6 r r EHW van e Logt E U eq 03 where a mall tme-ontant an may be et a 0% of the value of the ervatve term Equaton eq 03 nee to tranferre to the Z oman to mae t utable for mplementaton on a omputer h one ung the blnear tranformaton gven n eq 04: he blnear tranformaton formula gven wth: eq 04 Now ue the blnear tranformaton, gven n equaton eq 04, to tranform equaton eq 03 onto an equvalent form n the Z oman: E U eq05- h tranform nto: E U eq05- E U eq05-3 Now, let all eparate part hare the ame enomnator: E U eq05-4 Rewrte equaton eq05-4 an ombne all part of - an - wth eah other: E U eq05-5 Smplfyng the varou term reult n:
PID Controller Calulu for HERMS home-brewng ytem PID Controller Calulu, V30 Page 3/6 r r EHW van e Logt 4 4 4 E U eq05-6 Now efne the followng parameter: ; 4 ; 4 4 ; 0 p p eq06 Subttutng thee parameter ba nto equaton 05-6 reult n: 0 E p p U eq 07 ranformng equaton eq 07 ba to the tme-rete form reult n: ] [ ] [ ] [ ] [ ] [ ] [ 0 e e e u p u p u eq 08 Equaton eq08 mplemente wth p_reg an eq07 mplemente wth nt_p ee appenx for full C oure ltng
PID Controller Calulu for HERMS home-brewng ytem 3 Dervaton of a ype C PID ontroller here are three type of PID equaton ee http://betune50megom/typeabhtm, wth type C beng the preferre one Equaton eq 0 an ultmately eq 08 are type A equaton, ne the P- an the D-term both ontan the et-pont Any hange n the et-pont may aue an unwante hange n the PID output ut Removng the et-pont from the D-term reult n a type B ontroller he type C ontroller ha alo remove the et-pont from the P-term, reultng n an even better PID ontroller mplementaton Startng wth equaton 0 an fferentatng both e gve equaton eq 09 e t e t u t e t t eq 09 ranformng equaton eq 09 to the tme-rete oman, ung bawar fferentaton, reult n equaton eq 0: e u u e e e e e eq 0 he D-term nee to be fltere wth a Low-Pa Flter LPF to mae t more pratal he tranfer funton of a mple LPF gven wth: H, wth typally et to about 0% of the value eqa he equvalent Z tranfer funton : H eqb he equvalent funton the tme-rete oman then: lpf e e lpf eq Equaton eq0 an now alo be wrtten a: e u u e e lpf lpf lpf eq Equaton tll a type A equaton textboo PID, beaue the term epen on e an the nput of the LPF alo ha e a nput Equaton eq an eq are mplemente wth p_reg3 an wth nt_p3 ee appenx for full C oure ltng PID Controller Calulu, V30 Page 4/6 r r EHW van e Logt
PID Controller Calulu for HERMS home-brewng ytem Beaue t not eay to tranform th equaton nto a full type C ontroller beaue of the aton n eq, we wll revert to equaton eq0 an tranform th equaton nto a type C equaton eq 3: e u u e e e e e eq 0 e u u SP PV SP PV SP PV SP PV SP PV eq 3 Here, PV the proe varable, whh the atual temperature of the HL Furthermore SP the et-pont or the referene temperature If we aume that the et-pont not hange, we an tate the PV PV - PV - Wth th, the equaton tranform nto: e u u PV PV PV PV PV eq 4 Equaton 4 a type C PID ontroller an normally referre to a a aaha PID ontroller h equaton mplemente wth p_reg4 an wth nt_p4 ee appenx for full C oure ltng PID Controller Calulu, V30 Page 5/6 r r EHW van e Logt
PID Controller Calulu for HERMS home-brewng ytem 4 Fnng the optmum et of PID parameter Fnng the optmum parameter for a PID ontroller an be ffult Optmum mean that the et-pont temperature reahe a quly a poble wth overhoot mnme hree well-nown algorthm for etermnng the PID parameter are erbe here: Zegler-Nhol open-loop: et PID ontroller to a ertan output an etermne lope an ea-tme of HL ytem Zegler-Nhol loe-loop: meaure tep-repone Cohen-Coon: alo a loe-loop metho Meaure tep-repone Integral of the tme weghte abolute error IAE: reult n the bet performane he error gnal mnme over tme Some term are frequently ue n th oument: Dea-tme Θ: th the tme-elay between the ntal tep an a 0% nreae n the proe varable the HL temperature n our ae : the gan of the HL-ytem he HL-ytem reeve the Gamma value PID output a nput an ha the HL temperature a output Unty of [ C / %] τ : the tme-ontant of the HL-ytem he HL-ytem an be erbe wth a frt-orer proe moel wth tme-elay FOPD he tranfer funton for th moel : θ e HL τ a*: the normale lope of the tep repone Equal to / t p wth: o : hange n temperature [ C] o t : hange n tme [eon] o p: hange n PID ontroller output [%] Wth thee three parameter, the optmum PID parameter are etermne ung table on the next page value are gven both for PID operaton an for PI-only operaton: PID Controller Calulu, V30 Page 6/6 r r EHW van e Logt
PID Controller Calulu for HERMS home-brewng ytem Metho: / [% / C] [eon] [eon] Parameter: Zegler-Nhol,,0θ 0,5 θ Open-loop θ a * Zegler-Nhol 0,9 3,33θ - - Open-loop θ a* Zegler-Nhol, τ,0θ 0,5 θ Cloe-loop θ Zegler-Nhol 0,9 τ 3,33θ - - Cloe-loop θ Cohen-Coon τ θ 4 3 τ 6 θ θ θ 4 τ 3 3 τ 8 θ Cohen-Coon τ θ 9 30 τ 3 θ - - θ θ τ 0 9 τ 0 θ 0, 947 0,738 IAE-Loa,357 θ τ τ 0,84 θ τ 0, 977 0,680 IAE-Loa 0,859 θ τ τ 0,674 θ - - τ able : optmum PID parameter for the varou metho 4 τ θ θ τ 0 θ,38 τ τ o be able to fn thee three parameter aurately, two experment nee to be onute hee two experment are erbe n the next two paragraph he lat paragraph 43 how the alulate PID parameter for all thee metho 0,995 PID Controller Calulu, V30 Page 7/6 r r EHW van e Logt
PID Controller Calulu for HERMS home-brewng ytem 4 Experment : Determne ea-tme Θ of HL-ytem Manually et the PID-ontroller output gamma to a ertan value eg 0 % In ae of a heavy loa, 00 % reommene more aurate, but f you on t now the performane of the ytem, a lower value to tart wth better he temperature tart to nreae an follow the urve n fgure Fgure : Open-loop repone of the ytem Calulate the average lope of the re a / t by ung regreon analy f poble Calulate the normale lope a*, whh efne a: a* a / p he ea-tme Θ efne a the tme between t 0 an t by ung regreon analy, th an be one qute aurately Expermental ata: HL flle wth 85 L water, l off 9:08:0 t 0, the PID ontroller output gamma wa et to 00 %, 47,4 C Step-repone up to 5500 C, 7,59 C 9 : :5 48,8 C 0% 48,7 C 9 :7 : 54,5 C 90% 54,4 C Regreon analy of the ata between 9 : :5 an 9:7 : reulte n the followng: y ax b 0,0334x 48,78 R 0,9995 Here, every ata-pont for x repreent 5 eon herefore, the average lope a equal to: a 0,0334 C / 5 e 6,68E-03 C/eon whh 0,4 C/mnute Now olve where th urve ht the env lne: Meaurement are reore n HL_open_loop_repone_60404xl PID Controller Calulu, V30 Page 8/6 r r EHW van e Logt
PID Controller Calulu for HERMS home-brewng ytem x 474 4878 / 668E-03-30 eon or mnute an 0 eon he ea-tme moment then 9::5 :0 9:0:5 herefore, the ea-tme Θ 9:0:5 9:08:0 :55 5 eon he normale lope a* equal to : a* a / p 6,68E-05 C/%eon 4 Experment : Determne gan an tme-ontant τ of HL-ytem Manually et the PID-ontroller output gamma to a ertan value eg 0 % he temperature tart to nreae an follow the urve n fgure Fgure : Step repone of the ytem Beaue of the large tme-ontant preumably preent n the HL ytem, the tep repone not very aurate n etermnng the ea-tme Θ h the mean reaon to onut two experment theoretally, the tep-repone woul gve you all the requre nformaton to etermne the three parameter Expermental ata: 3 HL flle wth 85 L water, l off 09:49:04 t 0, the PID ontroller output gamma wa et to 0 %, 9,0 C 0:4:03 Experment toppe, 5,98 C Regreon analy n orer polynomal ue to fn maxmum Maxmum foun at :0:44 8300 t of 5 eon 5,989 C 5,989 9,0 33,789 C t /3τ 0,83 * 8,76 C > /3τ 6599 eon t τ 0,63 * 40,555 C > τ 6573 eon Solve for τ : τ /3 τ 6573 6599 > τ 496 eon Solve for Gan : / p 33,789 C / 0 %,689 C / % 3 Meaurement are reore n HL_tep_repone_90404xl PID Controller Calulu, V30 Page 9/6 r r EHW van e Logt
PID Controller Calulu for HERMS home-brewng ytem 43 Calulaton of PID parameter for the varou metho In the prevou paragraph, the followng parameter were foun: ea-tme Θ 5 eon Gan,689 C / % me-ontant τ 496 eon Normale lope a* a / p 6,68E-05 C/%eon [%/ C] [e] [e] Zegler-Nhol Open Loop 56, 30,0 57,5 PID 7, 383,0 - - PI Zegler-Nhol Cloe Loop 9,4 30,0 57,5 PID 69,3 383,0 - - PI Cohen-Coon 0,8 8, 4,8 PID 69,4 377, - - PI IAE-Loa 80,8 489,0 44,9 PID 59, 80, - - PI able : Calulaton of parameter for the varou metho PID Controller Calulu, V30 Page 0/6 r r EHW van e Logt
PID Controller Calulu for HERMS home-brewng ytem Referene Doument Referene oument Veron Date tle: Author ag 005 Dgtal Self-unng Controller, ISBN -8533-980-, Sprnger V Bobál, J Böhm, J Fel, J Maháe [0] Veron Htory Date Veron Derpton 0-0-003 V0 Frt veron for play on web-te 08-03-004 V0 - Remove mplementaton an 3 - Ae erpton of type A, B an C - Ae type C PID algorthm - Ae auto-tunng algorthm example 0-03-004 V Inorret ea-tme alulaton 09-05-004 V - Ae Cohen-Coon IAE metho - Ae two experment erpton - Calulaton are upate 0-05-004 V30 - Dervaton wth aylor ere replae by exat ervaton Current mplementaton wore well, but mulaton howe problem 3-05-004 V30 - Upate of oument, orrete a few mtae - A low-pa flter to the D-term of the PID-ontroller 3-05-004 V30 Some textual hange 09-05-006 V303 Error orrete n equaton eq09 6-0-007 V30 - Referene oument ae - ypo orrete n eq08 - Blo agram ae - Soure oe hortene, non-relevant oe remove - More ontent namng of varable - More elaborate ervaton n hapter 06-05-0 V30 - Better ervaton for p_reg3 an p_reg4 P_reg3 now a type A PID ontroller wth flterng of the D-aton P_reg4 now a pure aahah type C PID ontroller PID Controller Calulu, V30 Page /6 r r EHW van e Logt
PID Controller Calulu for HERMS home-brewng ytem Appenx I: C-program p_regh, p_reg /* Fle name : $I: p_regh,v 7 004/05/3 0:5:00 emle Exp $ Author : E v Logt ------------------------------------------------------------------ Purpoe : h fle ontan the efne for the PID ontroller ------------------------------------------------------------------ $Log: p_regh,v $ Revon 7 004/05/3 0:5:00 emle V0 06030 Frt veron */ #fnef PID_REG_H #efne PID_REG_H #fef pluplu extern "C" #enf // hee efne are neee for loop tmng an PID ontroller tmng #efne WENY_SECONDS 400 #efne EN_SECONDS 00 #efne FIVE_SECONDS 00 #efne ONE_SECOND 0 #efne _50MSEC 50 // Pero tme of mer n me #efne GMA_HLIM 000 // PID ontroller upper lmt [%] #efne GMA_LLIM 00 // PID ontroller lower lmt [%] typeef trut _p_param ouble ; // Controller gan from Dalog Box ouble t; // me-ontant for I aton from Dalog Box ouble t; // me-ontant for D aton from Dalog Box ouble t; // Sample tme [e] from Dalog Box ouble _lpf; // me ontant [e] for LPF flter ouble 0; // 0 value for PID ontroller ouble ; // value for PID ontroller ouble ; // value for PID ontroller ouble 3; // 3 value for PID ontroller ouble lpf; // value for LPF flter ouble lpf; // value for LPF flter nt t_t; // t for tmer nt p_moel; // PID Controller type [03] ouble pp; // ebug ouble p; // ebug ouble p; // ebug p_param; // trut p_param //-------------------- // Funton Prototype //-------------------- vo nt_pp_param *p; vo p_regouble x, ouble *y, ouble tet, p_param *p, nt vrg; vo nt_p3p_param *p; vo p_reg3ouble x, ouble *y, ouble tet, p_param *p, nt vrg; vo nt_p4p_param *p; vo p_reg4ouble x, ouble *y, ouble tet, p_param *p, nt vrg; #fef pluplu ; #enf #enf PID Controller Calulu, V30 Page /6 r r EHW van e Logt
PID Controller Calulu for HERMS home-brewng ytem /* Funton name: nt_p, p_reg nt_p3, p_reg3, nt_p4, p_reg4 Author : E v Logt Fle name : $I: p_reg,v 6 004/05/3 0:5:00 emle Exp $ ------------------------------------------------------------------ Purpoe : h fle ontan the man boy of the PID ontroller For egn etal, pleae rea the Wor oument "PID Controller Calulu" In the GUI, the followng parameter an be hange: : he ontroller gan : me-ontant for the Integral Gan : me-ontant for the Dervatve Gan : he ample pero [eon] ------------------------------------------------------------------ $Log: p_reg,v $ Revon 6 004/05/3 0:5:00 emle */ #nlue "p_regh" tat ouble e_; // e[-] SP[-] - PV[-] et_[-] - [-] tat ouble e_; // e[-] SP[-] - PV[-] et_[-] - [-] tat ouble x_; // PV[-] [-] tat ouble x_; // PV[-] [-] tat ouble y_; // y[-] Gamma[-] tat ouble y_; // y[-] Gamma[-] tat ouble lpf_; // lpf[-] LPF output[-] tat ouble lpf_; // lpf[-] LPF output[-] vo nt_pp_param *p /*------------------------------------------------------------------ Purpoe : h funton ntale the PID ontroller, bae on the new ype A PID ontroller Varable: p: ponter to trut ontanng all PID parameter 0 ---- ------------ _lpf / 4_lpf - 4 ------------------------- _lpf _lpf / _lpf/ ------------------------------------------------ _lpf Return : No value are returne ------------------------------------------------------------------*/ ouble alfa p->t 0 * p->_lpf; // help varable p->t_t ntp->t * 0000 / _50MSEC; f p->t_t > WENY_SECONDS p->t_t WENY_SECONDS; f p->t > 000 p->0 p-> * 0 p->t / 0 * p->t 0 * p->t / alfa; p-> p-> * p->t * p->t / p->t - 40 * p->_lpf 40 * p->t; p-> / alfa; p-> 0 * p->_lpf p->t p->t * p->t / 0 * p->t; p-> 0 * p->t p->_lpf * p->t / p->t; p-> * p-> / alfa; // f //-------------------------------------------------- // u[] lpf*u[-] lpf*u[-] //-------------------------------------------------- p->lpf 40 * p->_lpf / alfa; p->lpf p->t 0 * p->_lpf / alfa; // nt_p vo p_regouble x, ouble *y, ouble tet, p_param *p, nt vrg /*------------------------------------------------------------------ Purpoe : h funton mplement the upate PID ontroller It an upate of p_reg, erve wth Blnear ranformaton It a ype A ontroller h funton houl be alle one every S eon Varable: x : he nput varable x[] meaure temperature *y : he output varable y[] gamma value for power eletron PID Controller Calulu, V30 Page 3/6 r r EHW van e Logt
PID Controller Calulu for HERMS home-brewng ytem tet : he etpont value for the temperature *p : Ponter to trut ontanng PID parameter vrg: Releae gnal: Start ontrol, 0 able PID ontroller Return : No value are returne ------------------------------------------------------------------*/ ouble e; // e[] e tet - x; // alulate e[] f vrg *y p->lpf * y_ p->lpf * y_; // y[] p*y[-] p*y[-] *y p->0 * e; // 0 * e[] *y p-> * e_; // * e[-] *y p-> * e_; ele *y 00; e_ e_; // e[-] e[-] e_ e; // e[-] e[] // lmt y[] to GMA_HLIM an GMA_LLIM f *y > GMA_HLIM *y GMA_HLIM; ele f *y < GMA_LLIM *y GMA_LLIM; // ele y_ y_; // y[-] y[-] y_ *y; // y[-] y[] // p_reg // * e[-] vo nt_p3p_param *p /*------------------------------------------------------------------ Purpoe : h funton ntale the Allen Braley ype A PID ontroller Varable: p: ponter to trut ontanng all PID parameter 0 ----- for I-term -- for D-term he LPF parameter are alo ntale here: lpf[] lpf * lpf[-] lpf * lpf[-] Return : No value are returne ------------------------------------------------------------------*/ p->t_t ntp->t * 0000 / _50MSEC; f p->t_t > WENY_SECONDS p->t_t WENY_SECONDS; f p->t 00 p->0 00; ele p->0 p-> * p->t / p->t; // ele p-> p-> * p->t / p->t; p->lpf 0 * p->_lpf - p->t / 0 * p->_lpf p->t; p->lpf p->t / 0 * p->_lpf p->t; // nt_p3 vo p_reg3ouble x, ouble *y, ouble tet, p_param *p, nt vrg /*------------------------------------------------------------------ Purpoe : h funton mplement the type Allen Braley ype A PID ontroller All term are epenent on the error gnal e[] he D term alo low-pa fltere h funton houl be alle one every S eon Varable: x : he nput varable x[] meaure temperature *y : he output varable y[] gamma value for power eletron tet : he etpont value for the temperature *p : Ponter to trut ontanng PID parameter vrg: Releae gnal: Start ontrol, 0 able PID ontroller Return : No value are returne ------------------------------------------------------------------*/ PID Controller Calulu, V30 Page 4/6 r r EHW van e Logt
PID Controller Calulu for HERMS home-brewng ytem ouble e; // e[] ouble lpf; //LPF output e tet - x; // alulate e[] SP[] - PV[] //-------------------------------------- // Calulate Lowpa Flter for D-term //-------------------------------------- lpf p->lpf * lpf_ p->lpf * e e_; f vrg //----------------------------------------------------------- // Calulate PID ontroller: // y[] y[-] *e[] - e[-] // *e[]/ // /*lpf[] - *lpf[-]lpf[-] //----------------------------------------------------------- p->pp p-> * e - e_; // y[] y[-] *e[] - e[-] p->p p->0 * e; // */ * e[] p->p p-> * lpf - 0 * lpf_ lpf_; *y p->pp p->p p->p; ele *y 00; e_ e; // e[-] e[] lpf_ lpf_; // upate tore for LPF lpf_ lpf; // lmt y[] to GMA_HLIM an GMA_LLIM f *y > GMA_HLIM *y GMA_HLIM; ele f *y < GMA_LLIM *y GMA_LLIM; // ele // p_reg3 vo nt_p4p_param *p /*------------------------------------------------------------------ Purpoe : h funton ntale the Allen Braley ype C PID ontroller Varable: p: ponter to trut ontanng all PID parameter Return : No value are returne ------------------------------------------------------------------*/ nt_p3p; // ental to nt_p3 // nt_p4 vo p_reg4ouble x, ouble *y, ouble tet, p_param *p, nt vrg /*------------------------------------------------------------------ Purpoe : h funton mplement the aahah PID ontroller, whh a type C ontroller: the P an D term are no longer epenent on the et-pont, only on PV whh he D term NO low-pa fltere h funton houl be alle one every S eon Varable: x : he nput varable x[] meaure temperature *y : he output varable y[] gamma value for power eletron tet : he etpont value for the temperature *p : Ponter to trut ontanng PID parameter vrg: Releae gnal: Start ontrol, 0 able PID ontroller Return : No value are returne ------------------------------------------------------------------*/ ouble e; // e[] ouble lpf; //LPF output e tet - x; // alulate e[] SP[] - PV[] f vrg //----------------------------------------------------------- // Calulate PID ontroller: // y[] y[-] *PV[-] - PV[] // *e[]/ // /**PV[-] - PV[] - PV[-] //----------------------------------------------------------- p->pp p-> * x_ - x; // y[] y[-] *PV[-] - PV[] p->p p->0 * e; // */ * e[] p->p p-> * 0 * x_ - x - x_; *y p->pp p->p p->p; ele *y p->pp p->p p->p 00; x_ x_; // PV[-] PV[-] PID Controller Calulu, V30 Page 5/6 r r EHW van e Logt
PID Controller Calulu for HERMS home-brewng ytem x_ x; // PV[-] PV[] // lmt y[] to GMA_HLIM an GMA_LLIM f *y > GMA_HLIM *y GMA_HLIM; ele f *y < GMA_LLIM *y GMA_LLIM; // ele // p_reg4 PID Controller Calulu, V30 Page 6/6 r r EHW van e Logt