Simulink model execution doesn't follow the flowgraph.
1 view (last 30 days)
Show older comments
Hi,
I'm trying to model a quadrotor drone using this model:

To summarize, it's two nested control loops, the outer one controlling the position of the drone, and the inner one its attitude.
The model runs without producing any error, however it doesn't produce the expected results. In order to investiguate, I tried to run it step by step in debug mode.
What happened is that the simulation goes through one block after another, except when entering the inner-loop subsystem. Instead of going through Control Law first, it directly executes Rodriguez Fromula, using Constant1 as value of the input q. It then goes back to the Control Law function and runs through the subsystem in the right order, except it directly jumps from the last integrator to the exit port. The simulation does that on every turn of the loop, not only the first time.
The input of Rodriguez Formula being always the same, the output of the subsytem is independent of the input Rc, and the whole simulation doesn't work as intended.
I really have no clue about what's causing this, since it is the first time I hear about a simulink model not following the order shown on the flowgraph.
I hope someone here knows what could be causing this.
Thanks in advance :) !
0 Comments
Answers (1)
Sebastian Castro
on 1 Mar 2016
This makes sense because your block has an integrator before it. Since the integrator, at each time step, will use the last value it computed, it doesn't need knowledge about the previous blocks.
In other words, the output of the "qdot" block isn't used until the end of the time step, in which "qdot" is used to update the value of the internal state in the integrator.
On top of that, the model actually needs the Rodriguez Formula block to execute first because its output is used by the left-most Control Law block.
If you want to break this dependency, you can try adding a Unit Delay on that feedback "R" signal. This ensures that the block on the left uses the previous time step's output values, which wouldn't impact your sorted order. Note that this works only if your algorithm runs in discrete time; else a Unit Delay may not be the best way to break those loops.
You can verify this by viewing the sorted order of the blocks: Display > Blocks > Sorted Execution Order.
- Sebastian
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!