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 MCU

Status
Not open for further replies.

garimella

Full Member level 5
Joined
Aug 25, 2011
Messages
260
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,296
Activity points
3,276
Hi

I have some clarification regarding implementing PI Controller in MCU. I have seen two approaches
First one is direct translation of PI controller equations in software and second one is converting continuous domain to discrete domain and then getting corresponding difference equation, which can be put back to action. I was interested to know which one is better?
 

Software controller is time discrete by nature. In so far z domain implementation is the straightforward approach and more exact than "simulated" continuous PI.

In can still make sense to use popular PI parameters for controller setup and calculate parameters of time discrete transfer function internally. Most commercial digital PID controllers do.
 

Hi FvM
I was referring to this link in implementing PI controller in C for MCU's https://batchloaf.wordpress.com/2013/06/11/simple-pi-control-using-the-dspic30f4011/
I do not understand how the final output works. For example if we consider only proportional controller, the output=kp*error. Well this is just an open loop. closed loop TF should be kp/kp+1. I have seen similar such formulas all over the place. I do not see feedback parameter getting into the equation.
 

I don't understand what's the problem with this simple PI code. It's a "simulated" continuous PI, implemented as difference equation. To get the exact transfer function, you should analyze it in z domain.

What do you mean by feedback parameter? The loop is closed in hardware outside the code. The overall closed loop transfer function also depends on the controlled "plant" and the RC lowpass used to average the PWM output.
 

Ok I got it. Model gets closed from outside.
 

I was trying to implement closed loop PI controller within MCU. No inputs from field. The TF laplace domain is skp+ki/s(kp+1)+ki. I translated this to z domain using Tustin method and converted to difference equation. Assuming Kp=100 and Ki=1000 and T=0.001, i get y(n)=.0099y(n-1)+0.9901x(n)-0.0098x(n-1). The input is simply a constant 1.0 and I expect output to rise and stay at 1.0. I get same answer in simulink. But looking at difference equation, i really do not understand the meaning of x(n-1) because there are no previous values of x. Since input is constant x(n-1) will always be 1.0. So what Am i doing wrong?
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top