Forum Discussion
PI controller in VHDL
I'm trying to implement a PI controller in VHDL. where i tried a lot but i failed
Please, can any one help me to achieve this task where i'm new in this field.14 Replies
- Altera_Forum
Honored Contributor
Hello James,
I have to design a pid servo for power stabilization of the lasers . I have thought of the closed loop design involving the experiment and the feedback. I read your paper on the pid controller and was wondering about what should be the sampling interval for the integral component and how to implement it in vhdl. My ADC's and DAC's work at maximum frequency of 10 MHz and 25 MHz respectively. Does that mean for the PID , I can have a maximum frequency of 12.5 MHz (half the frequency of DAC). Secondly, how to use the inverse of this frequency (sampling interval) in the difference equation that you have given in your paper. Thanks. - Altera_Forum
Honored Contributor
The ADC and DAC scaling isn't part of the digital controller, but it obviously affects the feedback loop gain. I think the plant model should take account of it.
- Altera_Forum
Honored Contributor
Hi,
what about the relationship between Kp, Ki, Kd and the width of the input signals? For example if i have input data coming from a 12bit ADC with 5V analog range and a 12bit ADC with 2.5V analog range (so the same input voltage is rapresented with different words) are the PI parameters affected by this? - Altera_Forum
Honored Contributor
One of the key issues in implementing this type of controller is how to handle the clamping function. Think about how to wrap a finite state machine controller around the main PI; to enable the integrator after the clamp has cleared in an appropriate manner. This topic is in addition to how to handle the bit growth of the accumulator; which is an issue in any FIR or IIR filter design. -James
- Altera_Forum
Honored Contributor
Thanks james for you reply. I will study this paper.
- Altera_Forum
Honored Contributor
- 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
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
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
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.