You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
purpose of state-space with pid
1 view (last 30 days)
Show older comments
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.
Accepted Answer
Azzi Abdelmalek
on 11 Oct 2012
Edited: Azzi Abdelmalek
on 11 Oct 2012
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 Comments
Azzi Abdelmalek
on 11 Oct 2012
the first code or the second? have you control system toolbox?
Azzi Abdelmalek
on 11 Oct 2012
clear then run my code and tell me which line is making error
Azzi Abdelmalek
on 11 Oct 2012
first, did the first code work or no?
Azzi Abdelmalek
on 11 Oct 2012
p is the disturbance signal added to your output, you can set it to zero
Azzi Abdelmalek
on 11 Oct 2012
I've tested the two codes, they both work
Azzi Abdelmalek
on 11 Oct 2012
why are 'nt you using simulink? how are you connecting your sensor to your computer and matlab?
Azzi Abdelmalek
on 11 Oct 2012
forget a disturbance signal look at the edited answer
Azzi Abdelmalek
on 11 Oct 2012
which version of matlab are you using?
Azzi Abdelmalek
on 11 Oct 2012
when you click on >>model
what do you get?
Azzi Abdelmalek
on 11 Oct 2012
know, when you click model.u and model.y what is the result?
Azzi Abdelmalek
on 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)
Azzi Abdelmalek
on 11 Oct 2012
I can't explain what is going on, because, whe I run my code it works fine
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)