In the previous post An Introduction to compensator Design with matlab we saw an introduction to compensators. In this post we will deal with lag compensator design with frequency domain specifications.

The steps to design the lag Compensator are

- Determine K from the error constatns given
- Sketch the bode plot
- Determine phase margin if it is not satisfactory design lag compensator
- take as the required phase margin to that add a tolerance of 5 so that new phase margin is

- Find new gain cross over frequency which is the frequency corresponding to of previous step for that find

from the bode plot determine corresponding to - Determine gain corresponding to from bode plotlet it be A db
- a lag compensator has the form

since

- form the complete transfer function with the lag compensator added in series to th original system
- plot the new Bode plot and determine phase margin and observe that it is the required phase margin

Now to do this In Matlab let us take a question. I will be solving the question number 6.2 in Control Systems By Nagoor Kani. In th text book the question has been solved without using matlab you can go through it to understand the steps better.

**The question is **

### Open loop transfer function and the phase margin should be atleast 33 and velocity error constant is 30.

**Solution:**

The velocity error constant is

On solving we get K =9600

**The code below shows the matlab commands to obtain the design.**

K=9600 d1=conv([1 4 0],[1 80]) % used to formulate the polynomial G=tf(K,d1) % generate the transfer function. margin(G) pmreq=input('Enter Required Phase Margin') % enter 33 as given in question pmreq=pmreq+5 phgcm=pmreq-180 wgcm=input('Enter new gain cross over frequency') % from the first bode plot use the mouse pointer and locate wgcm corresponding to phgcm. [Beta,p]=bode(G,wgcm) T=10/wgcm Zc=1/T Pc=1/(Beta*T) Gc=tf([1 Zc],[1 Pc]) sys=Gc*G/Beta margin(sys)

If you have any doubts please do contact me.

Hello, Vineethkartha!

How can I compensate model by putting in the PID into the feedback? PID tuning, and automated matlab response optimisation bring no help///

Thanks.

PS your blog’s nice!

How to download matlab for linux

MathWorks has a Linux version of Matlab available, you can get it there

https://www.mathworks.com/downloads/

Nice explanation sir