purpose of state-space with pid

Hi everyone! I am having problem that when I connect state space block to PID and take its output as feedback in simulink I get a plot that converges at reference value; now I have to do the same job in mfile I have done the coding for pid but I am not getting idea that; what is the purpose of state space connected with pid so that I can write code for it.

 Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 11 Oct 2012
Modifié(e) : Azzi Abdelmalek le 11 Oct 2012

0 votes

clear,close
%your model and its input output
mot=tf(1,[1 1]),
model=ss(mot);
[F,h,c,d]=ssdata(model);
model.u='u'
model.y='y'
%your pid controller
r=pid(5,1/0.05,10)
r.u='e'
r.y='u'
%adding a reference r with som2=r-y
som1 = sumblk('e = r - y');
%global model with all conneection
modelg=connect(som1,r,model,'r','y')
%simulation
step(modelg)

27 commentaires

azan
azan le 11 Oct 2012
Sir its giving error at model y='y' and the statement of error is 'Invalid property name y'
Azzi Abdelmalek
Azzi Abdelmalek le 11 Oct 2012
the first code or the second? have you control system toolbox?
azan
azan le 11 Oct 2012
First code sir and I am having control system toolbox.
Azzi Abdelmalek
Azzi Abdelmalek le 11 Oct 2012
clear then run my code and tell me which line is making error
azan
azan le 11 Oct 2012
Modifié(e) : azan le 11 Oct 2012
ok Sir and what about 'P' in your code?
Azzi Abdelmalek
Azzi Abdelmalek le 11 Oct 2012
first, did the first code work or no?
azan
azan le 11 Oct 2012
first code didn't work,however your code is running but I am not sure of the value P
Azzi Abdelmalek
Azzi Abdelmalek le 11 Oct 2012
p is the disturbance signal added to your output, you can set it to zero
Azzi Abdelmalek
Azzi Abdelmalek le 11 Oct 2012
I've tested the two codes, they both work
azan
azan le 11 Oct 2012
And sir I have to give input from my sensor and compare it with my reference value.Sir I need to know where that input value will be in this code.
Azzi Abdelmalek
Azzi Abdelmalek le 11 Oct 2012
why are 'nt you using simulink? how are you connecting your sensor to your computer and matlab?
azan
azan le 11 Oct 2012
Modifié(e) : azan le 11 Oct 2012
actually instead of sensor my image processing code is dong the job and it is done in mfile
azan
azan le 11 Oct 2012
strange but even your code is not running for p=0
Azzi Abdelmalek
Azzi Abdelmalek le 11 Oct 2012
forget a disturbance signal look at the edited answer
azan
azan le 11 Oct 2012
It is still not working at model.y='y'
Azzi Abdelmalek
Azzi Abdelmalek le 11 Oct 2012
which version of matlab are you using?
azan
azan le 11 Oct 2012
matlab 7.8(2009)a
Azzi Abdelmalek
Azzi Abdelmalek le 11 Oct 2012
when you click on >>model
what do you get?
azan
azan le 11 Oct 2012
a = x1 x1 -1
b = u1 x1 1
c = x1 y1 1
d = u1 y1 0
Azzi Abdelmalek
Azzi Abdelmalek le 11 Oct 2012
know, when you click model.u and model.y what is the result?
azan
azan le 11 Oct 2012
Sorry sir I couldn't get this what do you mean by clicking model.u and model.y? Now the error is 'Invalid property name "y". Type "help ltiprops" for more information on valid LTI properties.'
Azzi Abdelmalek
Azzi Abdelmalek le 11 Oct 2012
azan have you copied and past my code or what? because I see in your error message , model y (it's no my code) it's model.y (you missed a dote)
azan
azan le 11 Oct 2012
No it was just a typing mistake.I have written model.y Infact I have just copied your code
Azzi Abdelmalek
Azzi Abdelmalek le 11 Oct 2012
I can't explain what is going on, because, whe I run my code it works fine
azan
azan le 11 Oct 2012
Thank you sir for your time and effort I will try to figure it out
azan
azan le 13 Oct 2012
Sir code is working now and the issue was I had to write like this model.inputname='u' model.outputname='y'
azan
azan le 13 Oct 2012
Sir can you now tell me where is that input(e.g 6 taken from image processing part) in this code which I have to compare with the reference value

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by