Forum Discussion
14 Replies
- Altera_Forum
Honored Contributor
what code are you struggling with?
- Altera_Forum
Honored Contributor
I have done sort of PI that consisted of two branches only (proportional and integral parts). I used it for phase error control in a receiver carrier tracking.
It was very simple in vhdl (but have the code misplaced). The proportional part is just a multiplier; you multiply the error(input) by a constant (I used .1 ~ 200). The integral part is just an acuumulator; you add up the error nonstop and hopefully will not overflow. You will need to add a term here to decide how much to feedback = leakage (e.g. .001 ~ 1), again needs multiplier in the accumulator loop. The two branches are just added up. Testing is more difficult and best is in-system testing - Altera_Forum
Honored Contributor
Thanks very much for your replies.
thanks Kaz i understand the proportional term but rely i didn't understand the integral term. can you explain it again and with its equation? note: for the proportional term there no value for sampling time. - Altera_Forum
Honored Contributor
i would like to tell you the equation of PI controller that i used:
u(k)=u(k-1) + err(k)*(kp +(ki*ts/2)) + err(k-1) * ( (ki*ts/2) - kp) where: u : is the output of controller. err: error signal that injected to the controller. kp: proportional constant. ki : integral constant. ts : sampling time. - Altera_Forum
Honored Contributor
I believe your equation is different from what described previously about my experience.
I had a go at it and hope it is correct. see attached diagram. - Altera_Forum
Honored Contributor
The PI controller algorithm presented by maha.eg can be found quite often in literature, it's also quoted as velocity algorithm, because the controller output u(k)-u(k1) represents the change rate of manipulated value. It's main advantage is that it allows to stop integration exactly at the limits of the manipulated value u(k).
Besides the shown variant of the algorithms, which refers to trapezoidal integration, there's also a rectangular integral variant. My digital control text book mentions, that the difference between both is neglectable for short sample periods. u(k)=u(k-1) + err(k)*kp + err(k-1) * (ki*ts - kp) - Altera_Forum
Honored Contributor
Thanks Kaz and FvM for your replies
Kaz your diagram describe my equation, does this mean that my equation is correct and can be used? but i can't get the experimental results where i'm programming the equation in FPGA by VHDL language. FVM thanks for your reply, but do you mean from your equation that i must replace my equation by your equation. please clear for me what is your idea? thanks very much for all. - Altera_Forum
Honored Contributor
I don't know about the equation, I just copied it from you.
Whether it correct or know, I think FvM confirmed it and he is really the Guy who knows about all that techno stuff. But I implemented it as diagram. You need to make sure you get your computation are correct especially issues of truncating bits at results. You need a math model and simulate first before you move to actual real time system - Altera_Forum
Honored Contributor
- Altera_Forum
Honored Contributor
Thanks james for you reply. I will study this paper.