Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PI controller in VHDL

Status
Not open for further replies.

maha.eg

Newbie level 6
Joined
Aug 8, 2011
Messages
13
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,371
please, I try to implement a PI digital controller in VHDL but my circuit does not work where PI code isn't correct. can anyone help me with a PI code by VHDL? Note, the equation that i use it in vhdl is : u(k)=u(k-1)+e(k)*(kp + ki*Ts/2) + e(k-1)* (ki*Ts/2 - kp) where: u : output signal o controller e : error signal and it is equal to (Iref-Igrid). kp, ki : constant of the controller. Ts : sampling time. please again, i need to your helps. thanks
 

Here's what I used for a PID controller: u(k)=u(k-1) + Kp*[e(k)-e(k-1)] + Ki*e(k)+Kd*[e(k)-2*e(k-1)+e(k-2)]. Note that I just pushed the "Ts/2" into the Ki parameter. If you set Kd to zero in my equation, mine looks ALMOST like yours except that mine only uses e(k) (not e(k)+e(k-1)) for the Ki term. This might be due to the transform used to get your algorithm. (And mine COULD be wrong, but it still seems to be working in several systems)

I would first question how you're implementing the "Ts/2". Are you doing floating point math? Signed integers? And I would also check your Ki and Kp values. If those are too far from where they should be, the controller won't "work" (it may saturate or oscillate). Make sure your intermediate calculations aren't overflowing, and also that you have enough resolution. Just to make you feel better, I had a hard time getting mine to work also.

Good luck,
Barry
 

thanks berry for your reply because Ts/2 is very small so i canceled the term that contain this value. beacause i can't implement float value on FPGA. i tried to chang the values of kp and ki but it may should be less than 1 so, i don't know how can i implement it on FPGA also. if you have any idea for these proplems please help me. thanks
 

Without knowing the actual arithmetic implementation, we can only guess about the problem. Some kind of fixed point arithmetic will be needed anyway.

I don't however understand this statement
because Ts/2 is very small so i canceled the term that contain this value.
ki*Ts/2 can be in fact implement as a single constant. But without apllying it correctly, the integrator part won't work.
 
When you say you "cancelled" the term that contains Ts/2, do you mean you set Ts/2= 1 or do you mean that you set ki*Ts/2=0? I hope you mean the first.

Hopefully you can simulate your design, rather than trying to debug it in hardware. Here's what I would try: First, set your Ki value to zero. This means your output will reduce to u(k)=u(k-1)+Kp*(e(k)-e(k-1)). If you then simulate a static value for e(k), your output will be static, since e(k)-e(k-1)=0. If you then simulate a change in e, you should see a corresponding change in u; you should be able to mathematically verify that the output from your simulation is what you expect. Similarly, you should be able to set Ki to a non-zero value and verify that the output agrees with your calculated value.

Barry
 
I tried to implement the PI controller code but i failed and i need it. so, if any one have a source code for this controller with vhdl please give me the code.
and i will be very thankful for him.

thanks very much for all
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top