Hello Lubin
I have several "init" C- function blocks that I need to execute at a specified order upon booting the dsPIC, if I use the Block ordering option only the last block in the sequence order gets included. Right now I guess I can work around this by doing just one C-block that calls all in the specified order, so this is not a show stopper, just something for you to consider for the next version.
Here are a couple of screenshots of the model and the generated code:
Thanks!
Mariano
Block Orderring fails for Blocks with infinite sample time
Block Orderring fails for Blocks with infinite sample time
- Attachments
-
- Generated Code
- Code.png (40.86 KiB) Viewed 22028 times
-
- Simulink Model
- Model-1.png (19.17 KiB) Viewed 22027 times
-
- Site Admin - Expert
- Posts: 616
- Joined: Wed Mar 07, 2007 11:23 pm
- Location: Bayonne- France
- Contact:
Re: Block Orderring fails for Blocks with infinite sample time
Hello Mariano,
Thanks for your clear explanation. You find an interesting problem I would never find such a bug by myself
My explanation is the following:
You checked the Inline parameters (Simulation==>Configuration Parameters==>Optimization) to reduced the RAM memory of the dsPIC.
When a block with infinite sample time (thus, for initialization here) has an input, Simulink try to optimize the code (Inlines parameters). Thus, it computes the scalar (or vector) result for this entry at time 0 because that block will be executed only once at time 0, and directly inject the result to last block with infinite sample time… This is why the blocks attached to a block with infinite time are not executed and thus implemented in the C code!
Therefore, The method I usually use to force the block ordering will cause trouble in such a case. I am not sure there is a solution to make it works differently.
However, there is another way to constrain the ordering of the blocks: using the simulink built in mechanism.
Each block has Priority parameters (right click on the block ==> Block Properties. The lower the priority value, the sooner the block executes. If blocks are not inside a loop, this will work 100%. Otherwise, be aware that this added constraint may not be satisfied by simulink…
You can see the execution ordering on the model: Format==>Block Displays ==> Sorted Order
The number value at the top-right corner is the ordering of the blocks. I hope the explanation is correct ! I do not have full knowlege about simulink omtimization process yet...
Lubin
Thanks for your clear explanation. You find an interesting problem I would never find such a bug by myself

My explanation is the following:
You checked the Inline parameters (Simulation==>Configuration Parameters==>Optimization) to reduced the RAM memory of the dsPIC.
When a block with infinite sample time (thus, for initialization here) has an input, Simulink try to optimize the code (Inlines parameters). Thus, it computes the scalar (or vector) result for this entry at time 0 because that block will be executed only once at time 0, and directly inject the result to last block with infinite sample time… This is why the blocks attached to a block with infinite time are not executed and thus implemented in the C code!
Therefore, The method I usually use to force the block ordering will cause trouble in such a case. I am not sure there is a solution to make it works differently.
However, there is another way to constrain the ordering of the blocks: using the simulink built in mechanism.
Each block has Priority parameters (right click on the block ==> Block Properties. The lower the priority value, the sooner the block executes. If blocks are not inside a loop, this will work 100%. Otherwise, be aware that this added constraint may not be satisfied by simulink…
You can see the execution ordering on the model: Format==>Block Displays ==> Sorted Order
The number value at the top-right corner is the ordering of the blocks. I hope the explanation is correct ! I do not have full knowlege about simulink omtimization process yet...
Lubin
Re: Block Orderring fails for Blocks with infinite sample time
Hello Lubin,
Thanks for such a quick response. This solution works like a charm.
Thanks!
Thanks for such a quick response. This solution works like a charm.
Thanks!
Who is online
Users browsing this forum: No registered users and 24 guests