CNTL-2P2Z
U[n]=A1*U[n-1]+A2*U[n-2]+B0*e[n]+B1*e[n-1]+B0*e[n-2]
PID
U[n]=U[n-1]+(Kp+Ki+Kd)*e[n]+(-Kp-2*Kd)*e[n-1]+Kd*e[n-2]
B0=Kp+Ki+Kd
B1=-Kp-2*Kd
B2=Kd
A2=0
A1=1
但是在Ti给的开发套件程序里,设定
B1=Ki-Kp-2*Kd 这是怎么回事?
另外:在Ti的开发套件程序里,设定:
CNTL-2P2Z的系数按照下列Q值格式,即Q26的格式
b2= _IQ26(0.35);
b1 = _IQ26(-1.45);
b0 _IQ26(1.33);
a2= _IQ26(-0.23);
a1 = _IQ26(1.23);
但是在PID转换成CNTL-2P2Z的系数后,出现了b2,b1,b0的格式是Q16,但是a1和a2的格式却是Q26的格式
b2 = _IQ16(Dgain);
b1 = _IQ16(Igain – Pgain – Dgain – Dgain);
b0 = _IQ16(Pgain + Igain + Dgain);
a2 = _IQ26(0.0);
a1 = _IQ26(1.0);
CNTL-2P2Z的汇编程序如下:
CNTL_2P2Z_INIT .macro n
;=============================
; allocate memory space for data & terminal pointers
_CNTL_2P2Z_Ref:n: .usect "CNTL_2P2Z_Section",2,1,1 ; reference input terminal
_CNTL_2P2Z_Fdbk:n: .usect "CNTL_2P2Z_Section",2,1,1 ; feedback input terminal
_CNTL_2P2Z_Out:n: .usect "CNTL_2P2Z_Section",2,1,1 ; output terminal
_CNTL_2P2Z_Coef:n: .usect "CNTL_2P2Z_Section",2,1,1 ; coefficients & saturation limits (14 words)
_CNTL_2P2Z_DBUFF:n: .usect "CNTL_2P2Z_Section",10,1,1 ; internal Data BUFF
; publish terminal pointers for access from the C environment
.def _CNTL_2P2Z_Ref:n:
.def _CNTL_2P2Z_Fdbk:n:
.def _CNTL_2P2Z_Out:n:
.def _CNTL_2P2Z_Coef:n:
.def _CNTL_2P2Z_DBUFF:n:
; set terminal pointers to ZeroNet
MOVL XAR2, #ZeroNet
MOVW DP, #_CNTL_2P2Z_Ref:n:
MOVL @_CNTL_2P2Z_Ref:n:, XAR2
MOVW DP, #_CNTL_2P2Z_Fdbk:n:
MOVL @_CNTL_2P2Z_Fdbk:n:, XAR2
MOVW DP, #_CNTL_2P2Z_Out:n:
MOVL @_CNTL_2P2Z_Out:n:, XAR2
; zero data buffer
MOVW DP, #_CNTL_2P2Z_DBUFF:n:
MOVL XAR2,#_CNTL_2P2Z_DBUFF:n:
RPT #9 ; 10 times
|| MOV *XAR2++, #0
.endm
;———————————————————————————-
;=============================
CNTL_2P2Z .macro n
;=============================
; set up address pointers
MOVW DP, #_CNTL_2P2Z_Ref:n:
MOVL XAR0, @_CNTL_2P2Z_Ref:n: ; net pointer to Ref (XAR0)
MOVW DP,#_CNTL_2P2Z_Fdbk:n:
MOVL XAR1, @_CNTL_2P2Z_Fdbk:n: ; net pointer to Fdbk (XAR1)
MOVW DP,#_CNTL_2P2Z_DBUFF:n:
MOVL XAR4, #_CNTL_2P2Z_DBUFF:n: ; pointer to the DBUFF array (used internally by the module)
; calculate error (Ref – Fdbk)
MOVL ACC, *XAR0 ; ACC = Ref (Q24) = Q(24)
SUBL ACC, *XAR1 ; ACC = Ref(Q24) – Fdbk(Q24)= error(Q24)
LSL ACC, #6 ; Logical left shift by 6, Q{24}<<6 -> Q{30}
;store error in DBUFF MOVL *+XAR4[4], ACC ; e(n) = ACC = error Q{30}
MOVW DP,#_CNTL_2P2Z_Out:n:
MOVL XAR2, @_CNTL_2P2Z_Out:n: ; net pointer to Out (XAR2)
MOVW DP,#_CNTL_2P2Z_Coef:n:
MOVL XAR3, @_CNTL_2P2Z_Coef:n: ; net pointer to Coef (XAR3)
ZAPA
; compute 2P2Z filter
MOV AR0,#8
MOVL XT, *+XAR4[AR0] ; XT = e(n-2)
QMPYL P, XT, *XAR3++ ; P = e(n-2)Q30*B2{Q26} = I8Q24
MOVDL XT, *+XAR4[6] ; XT = e(n-1), e(n-2) = e(n-1)
QMPYAL P, XT, *XAR3++ ; P = e(n-1)Q30*B1{Q26} = Q24, ACC=e(n-2)*B2
MOVDL XT, *+XAR4[4] ; XT = e(n), e(n-1) = e(n) QMPYAL P, XT, *XAR3++ ; P = e(n)Q30*B0{Q26}= Q24, ACC = e(n-2)*B2 + e(n-1)*B1 MOVL XT,*+XAR4[2] ; XT = u(n-2)
QMPYAL P, XT, *XAR3++ ; P = u(n-2)*A2, ACC = e(n-2)*B2 + e(n-1)*B1 + e(n)*B0
MOVDL XT,*+XAR4[0] ; XT = u(n-1), u(n-2) = u(n-1)
QMPYAL P, XT, *XAR3++ ; P = u(n-1)*A1, ACC = e(n-2)*B2 + e(n-1)*B1 + e(n)*B0 + u(n-2)*A2
ADDL ACC, @P ; ACC = e(n-2)*B2 + e(n-1)*B1 + e(n)*B0 + u(n-2)*A2 + u(n-1)*A1
; scale u(n):Q24, saturate (max>u(n)>min0), and save history
MINL ACC, *XAR3++ ; saturate to < max (Q24)
MAXL ACC, *XAR3 ; saturate to > min (Q24)
; write controller result to output terminal (Q24)
MOVL *XAR2, ACC ; output control effort to terminal net
; Convert the u(n) to Q30 format and store in the data buffer
LSL ACC, #6 ; Logical left shift by 6, Q{24}<<6 -> Q{30}
MOVL *XAR4, ACC ; u(n-1) = u(n) = ACC
.endm
问题:
b2 = _IQ16(Dgain);
b1 = _IQ16(Igain – Pgain – Dgain – Dgain);
b0 = _IQ16(Pgain + Igain + Dgain);
a2 = _IQ26(0.0);
a1 = _IQ26(1.0);
系数 a1和a2的格式不是Q16的话,不是相当于
b2 = _IQ16(Dgain>>10);
b1 = _IQ16((Igain – Pgain – Dgain – Dgain)>>10);
b0 = _IQ16((Pgain + Igain + Dgain)>>10);
a2 = _IQ26(0.0);
a1 = _IQ26(1.0);
这样相当于PID的公式变为:
U[n]=1024*U[n-1]+(Kp+Ki+Kd)*e[n]+(-Kp-2*Kd)*e[n-1]+Kd*e[n-2] ???
希望给予解答,谢谢!
Troublemaker:
帖子中,有处写错了, 现修改如下:
问题:
b2 = _IQ16(Dgain);
b1 = _IQ16(Igain – Pgain – Dgain – Dgain);
b0 = _IQ16(Pgain + Igain + Dgain);
a2 = _IQ26(0.0);
a1 = _IQ26(1.0);
系数 a1和a2的格式不是Q16的话,不是相当于
b2 = _IQ26(Dgain>>10);
b1 = _IQ26((Igain – Pgain – Dgain – Dgain)>>10);
b0 = _IQ26((Pgain + Igain + Dgain)>>10);
a2 = _IQ26(0.0);
a1 = _IQ26(1.0);
这样相当于PID的公式变为:
U[n]=1024*U[n-1]+(Kp+Ki+Kd)*e[n]+(-Kp-2*Kd)*e[n-1]+Kd*e[n-2] ???
希望给予解答,谢谢!
CNTL-2P2Z
U[n]=A1*U[n-1]+A2*U[n-2]+B0*e[n]+B1*e[n-1]+B0*e[n-2]
PID
U[n]=U[n-1]+(Kp+Ki+Kd)*e[n]+(-Kp-2*Kd)*e[n-1]+Kd*e[n-2]
B0=Kp+Ki+Kd
B1=-Kp-2*Kd
B2=Kd
A2=0
A1=1
但是在Ti给的开发套件程序里,设定
B1=Ki-Kp-2*Kd 这是怎么回事?
另外:在Ti的开发套件程序里,设定:
CNTL-2P2Z的系数按照下列Q值格式,即Q26的格式
b2= _IQ26(0.35);
b1 = _IQ26(-1.45);
b0 _IQ26(1.33);
a2= _IQ26(-0.23);
a1 = _IQ26(1.23);
但是在PID转换成CNTL-2P2Z的系数后,出现了b2,b1,b0的格式是Q16,但是a1和a2的格式却是Q26的格式
b2 = _IQ16(Dgain);
b1 = _IQ16(Igain – Pgain – Dgain – Dgain);
b0 = _IQ16(Pgain + Igain + Dgain);
a2 = _IQ26(0.0);
a1 = _IQ26(1.0);
CNTL-2P2Z的汇编程序如下:
CNTL_2P2Z_INIT .macro n
;=============================
; allocate memory space for data & terminal pointers
_CNTL_2P2Z_Ref:n: .usect "CNTL_2P2Z_Section",2,1,1 ; reference input terminal
_CNTL_2P2Z_Fdbk:n: .usect "CNTL_2P2Z_Section",2,1,1 ; feedback input terminal
_CNTL_2P2Z_Out:n: .usect "CNTL_2P2Z_Section",2,1,1 ; output terminal
_CNTL_2P2Z_Coef:n: .usect "CNTL_2P2Z_Section",2,1,1 ; coefficients & saturation limits (14 words)
_CNTL_2P2Z_DBUFF:n: .usect "CNTL_2P2Z_Section",10,1,1 ; internal Data BUFF
; publish terminal pointers for access from the C environment
.def _CNTL_2P2Z_Ref:n:
.def _CNTL_2P2Z_Fdbk:n:
.def _CNTL_2P2Z_Out:n:
.def _CNTL_2P2Z_Coef:n:
.def _CNTL_2P2Z_DBUFF:n:
; set terminal pointers to ZeroNet
MOVL XAR2, #ZeroNet
MOVW DP, #_CNTL_2P2Z_Ref:n:
MOVL @_CNTL_2P2Z_Ref:n:, XAR2
MOVW DP, #_CNTL_2P2Z_Fdbk:n:
MOVL @_CNTL_2P2Z_Fdbk:n:, XAR2
MOVW DP, #_CNTL_2P2Z_Out:n:
MOVL @_CNTL_2P2Z_Out:n:, XAR2
; zero data buffer
MOVW DP, #_CNTL_2P2Z_DBUFF:n:
MOVL XAR2,#_CNTL_2P2Z_DBUFF:n:
RPT #9 ; 10 times
|| MOV *XAR2++, #0
.endm
;———————————————————————————-
;=============================
CNTL_2P2Z .macro n
;=============================
; set up address pointers
MOVW DP, #_CNTL_2P2Z_Ref:n:
MOVL XAR0, @_CNTL_2P2Z_Ref:n: ; net pointer to Ref (XAR0)
MOVW DP,#_CNTL_2P2Z_Fdbk:n:
MOVL XAR1, @_CNTL_2P2Z_Fdbk:n: ; net pointer to Fdbk (XAR1)
MOVW DP,#_CNTL_2P2Z_DBUFF:n:
MOVL XAR4, #_CNTL_2P2Z_DBUFF:n: ; pointer to the DBUFF array (used internally by the module)
; calculate error (Ref – Fdbk)
MOVL ACC, *XAR0 ; ACC = Ref (Q24) = Q(24)
SUBL ACC, *XAR1 ; ACC = Ref(Q24) – Fdbk(Q24)= error(Q24)
LSL ACC, #6 ; Logical left shift by 6, Q{24}<<6 -> Q{30}
;store error in DBUFF MOVL *+XAR4[4], ACC ; e(n) = ACC = error Q{30}
MOVW DP,#_CNTL_2P2Z_Out:n:
MOVL XAR2, @_CNTL_2P2Z_Out:n: ; net pointer to Out (XAR2)
MOVW DP,#_CNTL_2P2Z_Coef:n:
MOVL XAR3, @_CNTL_2P2Z_Coef:n: ; net pointer to Coef (XAR3)
ZAPA
; compute 2P2Z filter
MOV AR0,#8
MOVL XT, *+XAR4[AR0] ; XT = e(n-2)
QMPYL P, XT, *XAR3++ ; P = e(n-2)Q30*B2{Q26} = I8Q24
MOVDL XT, *+XAR4[6] ; XT = e(n-1), e(n-2) = e(n-1)
QMPYAL P, XT, *XAR3++ ; P = e(n-1)Q30*B1{Q26} = Q24, ACC=e(n-2)*B2
MOVDL XT, *+XAR4[4] ; XT = e(n), e(n-1) = e(n) QMPYAL P, XT, *XAR3++ ; P = e(n)Q30*B0{Q26}= Q24, ACC = e(n-2)*B2 + e(n-1)*B1 MOVL XT,*+XAR4[2] ; XT = u(n-2)
QMPYAL P, XT, *XAR3++ ; P = u(n-2)*A2, ACC = e(n-2)*B2 + e(n-1)*B1 + e(n)*B0
MOVDL XT,*+XAR4[0] ; XT = u(n-1), u(n-2) = u(n-1)
QMPYAL P, XT, *XAR3++ ; P = u(n-1)*A1, ACC = e(n-2)*B2 + e(n-1)*B1 + e(n)*B0 + u(n-2)*A2
ADDL ACC, @P ; ACC = e(n-2)*B2 + e(n-1)*B1 + e(n)*B0 + u(n-2)*A2 + u(n-1)*A1
; scale u(n):Q24, saturate (max>u(n)>min0), and save history
MINL ACC, *XAR3++ ; saturate to < max (Q24)
MAXL ACC, *XAR3 ; saturate to > min (Q24)
; write controller result to output terminal (Q24)
MOVL *XAR2, ACC ; output control effort to terminal net
; Convert the u(n) to Q30 format and store in the data buffer
LSL ACC, #6 ; Logical left shift by 6, Q{24}<<6 -> Q{30}
MOVL *XAR4, ACC ; u(n-1) = u(n) = ACC
.endm
问题:
b2 = _IQ16(Dgain);
b1 = _IQ16(Igain – Pgain – Dgain – Dgain);
b0 = _IQ16(Pgain + Igain + Dgain);
a2 = _IQ26(0.0);
a1 = _IQ26(1.0);
系数 a1和a2的格式不是Q16的话,不是相当于
b2 = _IQ16(Dgain>>10);
b1 = _IQ16((Igain – Pgain – Dgain – Dgain)>>10);
b0 = _IQ16((Pgain + Igain + Dgain)>>10);
a2 = _IQ26(0.0);
a1 = _IQ26(1.0);
这样相当于PID的公式变为:
U[n]=1024*U[n-1]+(Kp+Ki+Kd)*e[n]+(-Kp-2*Kd)*e[n-1]+Kd*e[n-2] ???
希望给予解答,谢谢!
Troublemaker:
有人能帮忙解决下吗?
CNTL-2P2Z
U[n]=A1*U[n-1]+A2*U[n-2]+B0*e[n]+B1*e[n-1]+B0*e[n-2]
PID
U[n]=U[n-1]+(Kp+Ki+Kd)*e[n]+(-Kp-2*Kd)*e[n-1]+Kd*e[n-2]
B0=Kp+Ki+Kd
B1=-Kp-2*Kd
B2=Kd
A2=0
A1=1
但是在Ti给的开发套件程序里,设定
B1=Ki-Kp-2*Kd 这是怎么回事?
另外:在Ti的开发套件程序里,设定:
CNTL-2P2Z的系数按照下列Q值格式,即Q26的格式
b2= _IQ26(0.35);
b1 = _IQ26(-1.45);
b0 _IQ26(1.33);
a2= _IQ26(-0.23);
a1 = _IQ26(1.23);
但是在PID转换成CNTL-2P2Z的系数后,出现了b2,b1,b0的格式是Q16,但是a1和a2的格式却是Q26的格式
b2 = _IQ16(Dgain);
b1 = _IQ16(Igain – Pgain – Dgain – Dgain);
b0 = _IQ16(Pgain + Igain + Dgain);
a2 = _IQ26(0.0);
a1 = _IQ26(1.0);
CNTL-2P2Z的汇编程序如下:
CNTL_2P2Z_INIT .macro n
;=============================
; allocate memory space for data & terminal pointers
_CNTL_2P2Z_Ref:n: .usect "CNTL_2P2Z_Section",2,1,1 ; reference input terminal
_CNTL_2P2Z_Fdbk:n: .usect "CNTL_2P2Z_Section",2,1,1 ; feedback input terminal
_CNTL_2P2Z_Out:n: .usect "CNTL_2P2Z_Section",2,1,1 ; output terminal
_CNTL_2P2Z_Coef:n: .usect "CNTL_2P2Z_Section",2,1,1 ; coefficients & saturation limits (14 words)
_CNTL_2P2Z_DBUFF:n: .usect "CNTL_2P2Z_Section",10,1,1 ; internal Data BUFF
; publish terminal pointers for access from the C environment
.def _CNTL_2P2Z_Ref:n:
.def _CNTL_2P2Z_Fdbk:n:
.def _CNTL_2P2Z_Out:n:
.def _CNTL_2P2Z_Coef:n:
.def _CNTL_2P2Z_DBUFF:n:
; set terminal pointers to ZeroNet
MOVL XAR2, #ZeroNet
MOVW DP, #_CNTL_2P2Z_Ref:n:
MOVL @_CNTL_2P2Z_Ref:n:, XAR2
MOVW DP, #_CNTL_2P2Z_Fdbk:n:
MOVL @_CNTL_2P2Z_Fdbk:n:, XAR2
MOVW DP, #_CNTL_2P2Z_Out:n:
MOVL @_CNTL_2P2Z_Out:n:, XAR2
; zero data buffer
MOVW DP, #_CNTL_2P2Z_DBUFF:n:
MOVL XAR2,#_CNTL_2P2Z_DBUFF:n:
RPT #9 ; 10 times
|| MOV *XAR2++, #0
.endm
;———————————————————————————-
;=============================
CNTL_2P2Z .macro n
;=============================
; set up address pointers
MOVW DP, #_CNTL_2P2Z_Ref:n:
MOVL XAR0, @_CNTL_2P2Z_Ref:n: ; net pointer to Ref (XAR0)
MOVW DP,#_CNTL_2P2Z_Fdbk:n:
MOVL XAR1, @_CNTL_2P2Z_Fdbk:n: ; net pointer to Fdbk (XAR1)
MOVW DP,#_CNTL_2P2Z_DBUFF:n:
MOVL XAR4, #_CNTL_2P2Z_DBUFF:n: ; pointer to the DBUFF array (used internally by the module)
; calculate error (Ref – Fdbk)
MOVL ACC, *XAR0 ; ACC = Ref (Q24) = Q(24)
SUBL ACC, *XAR1 ; ACC = Ref(Q24) – Fdbk(Q24)= error(Q24)
LSL ACC, #6 ; Logical left shift by 6, Q{24}<<6 -> Q{30}
;store error in DBUFF MOVL *+XAR4[4], ACC ; e(n) = ACC = error Q{30}
MOVW DP,#_CNTL_2P2Z_Out:n:
MOVL XAR2, @_CNTL_2P2Z_Out:n: ; net pointer to Out (XAR2)
MOVW DP,#_CNTL_2P2Z_Coef:n:
MOVL XAR3, @_CNTL_2P2Z_Coef:n: ; net pointer to Coef (XAR3)
ZAPA
; compute 2P2Z filter
MOV AR0,#8
MOVL XT, *+XAR4[AR0] ; XT = e(n-2)
QMPYL P, XT, *XAR3++ ; P = e(n-2)Q30*B2{Q26} = I8Q24
MOVDL XT, *+XAR4[6] ; XT = e(n-1), e(n-2) = e(n-1)
QMPYAL P, XT, *XAR3++ ; P = e(n-1)Q30*B1{Q26} = Q24, ACC=e(n-2)*B2
MOVDL XT, *+XAR4[4] ; XT = e(n), e(n-1) = e(n) QMPYAL P, XT, *XAR3++ ; P = e(n)Q30*B0{Q26}= Q24, ACC = e(n-2)*B2 + e(n-1)*B1 MOVL XT,*+XAR4[2] ; XT = u(n-2)
QMPYAL P, XT, *XAR3++ ; P = u(n-2)*A2, ACC = e(n-2)*B2 + e(n-1)*B1 + e(n)*B0
MOVDL XT,*+XAR4[0] ; XT = u(n-1), u(n-2) = u(n-1)
QMPYAL P, XT, *XAR3++ ; P = u(n-1)*A1, ACC = e(n-2)*B2 + e(n-1)*B1 + e(n)*B0 + u(n-2)*A2
ADDL ACC, @P ; ACC = e(n-2)*B2 + e(n-1)*B1 + e(n)*B0 + u(n-2)*A2 + u(n-1)*A1
; scale u(n):Q24, saturate (max>u(n)>min0), and save history
MINL ACC, *XAR3++ ; saturate to < max (Q24)
MAXL ACC, *XAR3 ; saturate to > min (Q24)
; write controller result to output terminal (Q24)
MOVL *XAR2, ACC ; output control effort to terminal net
; Convert the u(n) to Q30 format and store in the data buffer
LSL ACC, #6 ; Logical left shift by 6, Q{24}<<6 -> Q{30}
MOVL *XAR4, ACC ; u(n-1) = u(n) = ACC
.endm
问题:
b2 = _IQ16(Dgain);
b1 = _IQ16(Igain – Pgain – Dgain – Dgain);
b0 = _IQ16(Pgain + Igain + Dgain);
a2 = _IQ26(0.0);
a1 = _IQ26(1.0);
系数 a1和a2的格式不是Q16的话,不是相当于
b2 = _IQ16(Dgain>>10);
b1 = _IQ16((Igain – Pgain – Dgain – Dgain)>>10);
b0 = _IQ16((Pgain + Igain + Dgain)>>10);
a2 = _IQ26(0.0);
a1 = _IQ26(1.0);
这样相当于PID的公式变为:
U[n]=1024*U[n-1]+(Kp+Ki+Kd)*e[n]+(-Kp-2*Kd)*e[n-1]+Kd*e[n-2] ???
希望给予解答,谢谢!
ge xijie:
求教,
TI 的PFC+ACI套件,实测发现在交流220输入,直流390V输出时,PF值只有80%,有没有好的解决办法?
如果调整PID系数的话,是只调整电流环还是要电流环电压环一起调整?有没有参考的把参数?
谢谢