Fixed-step solvers, model referencing and Normal and Accelerator mode

36 views (last 30 days)
Dear all,
I'm designing a Simulink model to simulate the dynamics of a vehicle. My model is composed by a system "VehicleDynamics" which contains two referenced models "WheelDynamics" (4 instances) and "LocalController" (4 instances). The model "WheelDynamics" include a continuous-time state, while the model "LocalController" just include some gains and switches, but it takes the wheel speed as an input signal and it generates a continuous-time output. My model "VehicleDynamics" runs in normal mode, the model "WheelDynmaicsFL" (FL stands for front-left) runs also in Normal mode, while the other three instances "WheelDynmaicsXX" (where XX is FR,RL,RR) run in Accelerator mode. The same is for the four instances of "LocalControllerXX": "LocalControllerFL" runs in Normal Mode, while the other three instances of the same model runs in Accelerator mode. Until here, everything works fine as long as I use a variable-step solver. If I use a fixed-step solver (like for example ode3 (Bogacki-Shampine)), I get this error:
"The Model block cannot inherit a continuous sample time. Output port 1 of Model block 'SingleWheelTEST/LocalCtrlFL' cannot accept 'continuous' sample time."
To get a better understanding of the system, I made a model with just one instance of "WheelDynamics" and "LocalController" that run in Normal mode. With the fixed step solver I still experience the same error, while with the variable-step solver everything goes smooth, and I cannot understand why!
I already tried to configure all the models in question "SingleWheelTEST", "WheelDynamics" and "LocalController" to use a Fixed-Step solver, but it didn't worked out.
Fianlly, having 4 instances of "WheelDynamics" and "LocalController", it seems that I'm constrainted to use Accelerator mode on 3 of the instances. However, I don't want to use them because Simulink generates code in the working folder that put additional files that I will never open (it creates like a "slprj" foldes and several .mexw32 files that I don't want). Is it possible to use all in Normal mode instead?
The Matlab version I'm using is the 2009a.
Thanks,
Ubaldo

Accepted Answer

Ubaldo Tiberi
Ubaldo Tiberi on 25 Apr 2012
Hi!
I think we are close to the solution! In what follows I performed all the simulations by using the fixed-step solver Ode3(Bogacki-Shampine) to all the models. Moreover, let me say that the model 'SingleWheelTEST/LocalCtrlFL' is composed by 4 input ports, 1 output port, 2 gains, one switch, one product block and one scope(so the model is very simple, I would even upload an image but I do not know if it is possible here in the forum).
Anyway, I tried to put a sample time "0" to a randomly chosen block in the 'SingleWheelTEST/LocalCtrlFL' model (for instance, I set sample time "0" to an Inport). I tried to run the simulation and I got this error
"Root Inport 'LocalController/Is Braking' has a sample time of [0 0] which does not match the sample time [0.4 0] of its destination: input port 1 of block 'LocalController/Scope'. Root inports must have the same sample time as their destinations for model reference. Please correct this situation by changing one of the two sample times or inserting a Rate Transition block. This error message is related to a hidden Inport block."
So I argued that the problem is in the Scope block. In addition, I don't want to add additional blocks in the model (otherwise is not the same model as in the case with variable-step solver, where everything works fine without additional blocks.) Then, with the same setting as above (i.e. sample time "0" to an Inport), I removed the Scope block and this time everything worked out perfectly, but with these warnings:
"Warning: Unable to determine a fixed step size based on the sample times in the model 'SingleWheelTEST', because the model does not have any discrete sample times. Picking a fixed step size of (0.4) based on simulation start and stop times. You can disable this diagnostic by explicitly specifying a fixed step size in the Solver pane of the Configuration Parameters dialog box, or setting the 'Automatic solver parameter selection' diagnostic to 'none' in the Solver group on the Diagnostics pane of the Configuration Parameters dialog box.
Warning: The model 'SingleWheelTEST' has continuous states and is referencing (via the Model block 'SingleWheelTEST/LocalCtrlFL') the fixed-step model 'LocalController' which has blocks with continuous sample time. The solver 'ode3' used to simulate model 'SingleWheelTEST', will execute the referenced model 'LocalController' in minor time steps, where as during standalone simulation the model 'LocalController' uses a discrete solver which does not have minor time steps. This can cause results from the Model block and results obtained from standalone simulation of the referenced model to be different. You can disable this diagnostic by setting 'Automatic solver parameter selection' diagnostic to 'none' in the Diagnostics page of the configuration parameters dialog."
Honestly, I was surprised that the problem could be the Scope block. Could you please explain me what happened with that block? And could you also tell me more about the warnings I get?
Finally, just for the sake of completeness, I also tried to run a simulation by setting sample time "-1" to all the blocks in 'SingleWheelTEST/LocalCtrlFL'and by deleting the Scope block. The result is that the sample time of this referenced model became again Discrete1 0.4.
I wonder what trick the variable-step solvers use to adapt all the sample times of all the blocks...
  5 Comments
Ubaldo Tiberi
Ubaldo Tiberi on 27 Apr 2012
Ok great! I will do that. In the meanwhile I accepted this answer so you can gain more reputation :-)
Kaustubha Govind
Kaustubha Govind on 27 Apr 2012
Ubaldo: Actually, you accepted your own answer, so I don't get any points. :) But no worries at all!

Sign in to comment.

More Answers (4)

K E
K E on 19 Apr 2012
I likely misunderstand your question, but I think you need SimScape if you want both continuous and discrete time sampling schemes within the same model. There is a specific block to interface between continuous and discrete sampling but I can't remember the name (just remembering from training, but haven't done it myself).

Kaustubha Govind
Kaustubha Govind on 19 Apr 2012
Ubaldo: I already answered the second part of your question here. You need to use R2010b or later to have multiple instances of a referenced model in Normal mode. There is no workaround for older versions, unfortunately.
For the first part, I still can't imagine why the error occurs on changing just the Solver Type. If the first output port of the model being referenced at "SingleWheelTEST/LocalCtrlFL" really returning a continuous sample-time with a fixed-step solver? What is its sample time with a variable-step solver when there is no error?

Ubaldo Tiberi
Ubaldo Tiberi on 20 Apr 2012
Hi Kaustubha,
In the previous thread I get that perhaps to use referenced models in normal mode I need the Matlab 2010b version, but, on the other hand, I didn't get that there are no workaround for older version and that the utlization of the 2010b Version (or later) is the only possible solution. Now everything is clear :)
Regarding the first part, unfortunately I have to say that this is exactly what happens. If I set Variable Step Solver for the top-model ("SingleWheelTEST") and for the referenced models ("SingleWheelTEST/LocalCtrlFL" and "SingleWheelTEST/FLWheel") I don't experience any problem. If I change the solver to Fixed Step Solvers (this is the only change I perform with respect to the working model)I get the mentioned error. I set Fixed Step Solver in all the three models. Moreover, I tried to derive the sampling times of the blocks by issuing the command "Simulink.Block.getSampleTimes(SingleWheelTEST/BlockName)" by I still get the error: "??? The Model block cannot inherit a continuous sample time. Output port 1 of Model block 'SingleWheelTEST/LocalCtrlFL' cannot accept 'continuous' sample time".
However, I performed another test using the Fixed Step Solver but without connecting the two blocks. Surprisingly the simulation worked out! But I got this message on the command line that may be useful:
"Warning: Unable to determine a fixed step size based on the sample times in the model 'SingleWheelTEST', because the model does not have any discrete sample times. Picking a fixed step size of (0.4) based on simulation start and stop times. You can disable this diagnostic by explicitly specifying a fixed step size in the Solver pane of the Configuration Parameters dialog box, or setting the 'Automatic solver parameter selection' diagnostic to 'none' in the Solver group on the Diagnostics pane of the Configuration Parameters dialog box. "
I'm really not understanding what is going on... Of course I perform simulations by using Variable Step Solvers, but I really wish why is not working. I hope you can help me :)
Thanks,
Ubaldo
  3 Comments
Ubaldo Tiberi
Ubaldo Tiberi on 23 Apr 2012
Yes, I expected that Simulink.Block.getSampleTimes wouldn't work.
I'm also already using the time annotation with colors. I love this feature :-)
Going back to my problem, I left the sample-time fields on "auto" when I selected the fixed-step solver.
Kaustubha Govind
Kaustubha Govind on 24 Apr 2012
Ubaldo: Even if you left it as auto, the sample time annotations will show you the actual (compiled) sample time being used for the model. My question was about the compiled sample times.

Sign in to comment.


Ubaldo Tiberi
Ubaldo Tiberi on 25 Apr 2012
Hello Kaustubha!
I didn't understand the question before, sorry! I performed different simulations with different setting and I annotate the sampling times.
Variable-step solver (for all the three models):
If there exist a connection between the two blocks "SingleWheelTEST/LocalCtrlFL" and "SingleWheelTEST/FLWheel" I get these sampling times
-Continuous 0
-Fixed in minor steps [0,1]
but the block and the connections are all black colored. Moreover, I get this warning:"Warning: Using a default value of 0.4 for maximum step size. The simulation step size will be equal to or less than this value. You can disable this diagnostic by setting 'Automatic solver parameter selection' diagnostic to 'none' in the Diagnostics page of the configuration parameters dialog. "
If I do not connect the two blocks I obtain the same sampling times and the same warning as above.
Fixed-step solver (for all the three models. I also set "Periodic sample constraint" to Unconstrained in the Solver pane):
If there exist a connection between the two blocks "SingleWheelTEST/LocalCtrlFL" and "SingleWheelTEST/FLWheel" I get the error
"The Model block cannot inherit a continuous sample time. Output port 1 of Model block 'SingleWheelTEST/LocalCtrlFL' cannot accept 'continuous' sample time."
If I do not connect the two blocks I obtain the same sampling times.
- SingleWheelTEST/LocalCtrlFL Discrete1 0.4
- SingleWheelTEST/FLWheel Continuous 0
with this warning "Warning: Unable to determine a fixed step size based on the sample times in the model 'SingleWheelTEST', because the model does not have any discrete sample times. Picking a fixed step size of (0.4) based on simulation start and stop times. You can disable this diagnostic by explicitly specifying a fixed step size in the Solver pane of the Configuration Parameters dialog box, or setting the 'Automatic solver parameter selection' diagnostic to 'none' in the Solver group on the Diagnostics pane of the Configuration Parameters dialog box."
I hope this information may be useful in order to solve my problem.
  1 Comment
Kaustubha Govind
Kaustubha Govind on 25 Apr 2012
It looks like 'SingleWheelTEST/LocalCtrlFL' is getting a discrete sample-time - what kind of source blocks do you have in this model? Do any of them have "-1" as their sample time? If yes, try setting them to "0" and see if 'SingleWheelTEST/LocalCtrlFL' gets a Continuous sample-time with the Fixed-step solver as well.

Sign in to comment.

Categories

Find more on Configure Simulation Conditions in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!