MATLAB Answers

sujan
0

how to write PID function in .m file

Asked by sujan
on 14 May 2012
Latest activity Commented on by PUJARI MURAGA on 1 Dec 2016
i need a pid function in my m file. could anyone please write the function.

  2 Comments

I do have same question
You are having state space model. Suppose I have differential equations then is it possible to do without converting them in state space/laplace ?

Sign in to comment.

3 Answers

Answer by Arkadiy Turevskiy on 14 May 2012
Edited by Arkadiy Turevskiy on 27 Oct 2014
 Accepted Answer

This demo might help.
Arkadiy

  2 Comments

thank you,
but my model is a space state model, and it has many tf. and i dont know how to connect space state form and PID controller. so could you please tell me how to use PID in m file which is not in tranfer function. thank you Arkadiy
well, how many inputs and outputs does you system have? If is a single-input-single output system, then everything shown in the demo is still applicable.If you more comfortable dealing with transfer functions, convert your state space system to a transfer function using tf:
ss_sys=ss(a,b,c,d);
tf_sys=tf(ss_sys);

Sign in to comment.


Answer by Krishnendu Mukherjee on 14 May 2012

a way is there : suppose ur tf is (1/a+s) which is to be fed to a pid controler. then the overall tf will be: (Kp+Ki/S+Kd.S).(i/S+a)/(1+(Kp+Ki/S+Kd.S).(i/S+a)). now if you want to give step input then : num=[............] den=[............] tf=num/den ster(tf) so you have to transfer the PID and the tf to a overall transfer function.

  1 Comment

thank you,
but my model is a space state model and its has 9 state parameters. and i dont know how to use PID in my system. and it is a MIMO system. 4 inputs and 9 outputs. so could you please help me to write a PID function for space state form not in tf. thank you

Sign in to comment.


Answer by Daniel
on 24 Oct 2014

Please where's the demo? I'm also trying to write a matlab function for pid using the user-defined function block

  1 Comment

Sign in to comment.