- If the function block supports it, try disabling zero crossing detection for that block only.
- Try changing the model's zero crossing behavior in the configuration parameters dialog. Specifically, try adaptive vs. non-adaptive zero crossing detection. You can also globally disable zero crossing detection, but this can impact the accuracy of the simulation results.
- Try restructuring the functionality you are implementing to yield a "soft" saturation as the input approaches the saturation limit.
Simulation time in Simulink goes up because of minor changes
13 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Max E.
el 1 de Sept. de 2015
Comentada: Max E.
el 5 de Sept. de 2015
Hi guys, I don't know, if you can help with just this little amount of information, but i don't know how to make it more clear, so i thought i might just give it a try: i have a vehicle double-track model implemented in simulink. originally the speed was set by giving a motor torque input. i replaced that with a PID-regulator to be able to set a specific speed. the regulator actually works just fine except you can't make changes in the speed while at the same time having a steering input. This is because the part where the tire forces are limited is implemented like this:
function F_iy_max = KammKreis(F_ix, F_R_max)
%#codegen
F_iy_max = sqrt((F_R_max).^2 - F_ix.^2);
F_R_max is the maximum is calculated as the limit of adhesion, while F_ix and F_iy are the Tireforces in x- and y-direction. So when the regulator sets a high acceleration, the value under the sqrt will be negative and the result is complex, which i don't want it to be. So i tried fixing the issue by replacing the code with this code:
function F_iy_max = KammKreis(F_ix, F_R_max)
F_iy_max=zeros(1, 4)
for i=1:4
if (F_ix(i)^2)<=(F_R_max(i)^2)
F_iy_max(i)=sqrt(F_R_max(i)^2 - F_ix(i)^2)
else
F_iy_max(i)=0
end
end
after all this coede fixes the issue, but the time it takes the modell to simulate for example 300s is like 40s instead of 4s. Does anyone have a clue why this happens? Thanks in advance!
0 comentarios
Respuesta aceptada
John Barber
el 1 de Sept. de 2015
Might be a zero-crossing detection issue. In general, when zero crossings occur, Simulink does a solver reset, which can negate the benefits of a variable-step solver if the resets occur frequently. In your case, I suspect that the implied discontinuity due to the if...else statement is triggering frequent zero crossing events. Here are some suggestions:
5 comentarios
John Barber
el 2 de Sept. de 2015
Another approach would be to implement the calculation as follows:
- Calculate F_R_max.^2 - F_ix.^2.
- Add a Constant block with the value set to [0;0;0;0]
- Add a MinMax block. Set the Function parameter to max, the Number of inputs parameter to 2, and uncheck the Enable zero crossing detection box.
- Connect the outputs of (1) and (2) to the inputs of the MinMax block.
- Connect the output of the MinMax block to a Sqrt block to get the equivalent output to your modified code.
Más respuestas (0)
Ver también
Categorías
Más información sobre Programmatic Model Editing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!