MATLAB Designing a Controller for Quadroto with MATLAB/SIMULINK

AI Thread Summary
The discussion revolves around designing a controller for a quadrotor using MATLAB and SIMULINK, focusing on setting initial values for velocities in an embedded function. The user seeks a method to input initial values only at time t=0 and then rely on feedback for subsequent steps. Suggestions include using control system design techniques to define initial states as desired values and exporting the operating point to the model workspace. The user encounters a NaN error at time 0.3, which does not appear to stem from a denominator issue in their equations. They are advised to run the program until the error occurs and capture screenshots for better clarity. Additionally, methods for defining initial conditions in integrator blocks are discussed, including setting the initial condition source to internal or utilizing the control system toolbox for operating point definitions.
armin11
Messages
66
Reaction score
0
hi,
I'm designing a controller for quadroto with MATLAB and I'm using SIMULINK to do this.
In the embedded function I have to define the initial values so that the velocities take initial values but then in the embedded function the derivative of the velocities is calculated and then there is an integrator after the embedded function that returns to the velocities.I should define initial values so that velocity input takes these values once and after that at each step velocities are entered by the feedback and initial values should't be entered.How can I do this?Is there a way to do this?for example in embedded function to write a code that takes the initial values at t=0 and after that inputs are from feedback?please help.
 
Physics news on Phys.org
Try using control system design and defining the initial states of your operating point as your desired values. Then export the operating point to the model workspace.

A screen shot of your system and your error would also help immensely, since your description isn't 100% clear.
 
there is an error at time 0.3 of the simulink ,but if we run the program till time 0.3 it gives correct answer.Can I delete this time form the program?there is an Nan error at time 0.3,but there isn't any denominator in the equation.I don't know how to upload the program here to see your opinion.
 
armin11 said:
I don't know how to upload the program here to see your opinion.

Run the program until you reach the error then use this button on your keyboard

[PLAIN]http://www.askdrtech.com/solutions/image.axd?picture=2009%2F8%2FPrint1.jpg

Also, you can use this button to capture images of the rest of your program. See http://www.seoconsultants.com/windows/print-screen/

for details
 
Last edited by a moderator:
the first one is a picture of the whole simulink,the second is my embedded function and the third is the error,as you can see the error is at the integrator of hdot and from the embedded function we see that hdot doesn't have a denominator.
 

Attachments

  • 1.jpg
    1.jpg
    36.1 KB · Views: 545
  • 2.jpg
    2.jpg
    37.1 KB · Views: 501
  • 3.jpg
    3.jpg
    47.8 KB · Views: 524
Just to recap, you are using an embedded function to define your initial values if your states, correct?

If you do this, the initial values at your integrators are all 0. There are a few ways to go about defining initial values of your states. One is to click on your integrator block and define the initial condition source as internal and input your data there.

The second way to do this is to use the control system toolbox and define the initial states in your operating point.
 

Similar threads

Replies
7
Views
3K
Replies
11
Views
3K
Replies
2
Views
2K
Replies
5
Views
4K
Replies
5
Views
2K
Replies
0
Views
1K
Replies
5
Views
1K
Back
Top