How to decrease sample rate to run a model in real time?

조회 수: 1 (최근 30일)
Marta
Marta 2014년 10월 15일
이동: Steve Miller 2022년 11월 20일
Hi,
I have a steering model (attached, as an .mdl but only runs as .slx) which I want to modify so that it can run in real time on a target computer. The problem is that when I switch to a fixed step solver, I need a step of max 10^-5 to avoid singularity and it has to be 10^-3.
Can someone please help with an advice on how to modify the model so that I can decrease the sample rate?
  댓글 수: 3
Marta
Marta 2014년 10월 16일
Thanks Tony, are you able to see/download the files now?
Marta
Marta 2014년 11월 3일
Thanks for your input Jon. Yes, the requirement was based on the capabilities of the target

댓글을 달려면 로그인하십시오.

답변 (1개)

Jon Boerner
Jon Boerner 2014년 10월 16일
이동: Steve Miller 2022년 11월 20일
After a quick look, there are a few things I noticed:
  • There are a number of memory blocks in your controller. When using a fixed-step solver with memory blocks, you are effectively discretizing your controller to the rate of the solver. It looks like your controller is meant to be a continuous controller, so the discretization may not be what you want. If you take out the memory blocks the model still runs and you can up the sample time to 1e-4.
  • If you look at the scope you have, with a step-size of 1e-3, before the simulation terminates itself, you can see that the dynamics of the system are faster than the solver step-size. You can tell by the choppiness of the signal. I assume the controller being discretized is the issue, since it should have faster dynamics than the plant, and 1e-3 seems close to working. It could also be that the plant is too fast to be solved at 1e-3, however.
My suggestion would be to:
  1. Run a simulation of just your plant with the solver at a timestep of 1e-3 and make sure the results are accurate for different inputs (without the controller)
  2. Take the controller subsystem and turn it into a variant subsystem (one variant with a continuous controller, and one with a discretized controller), and quickly convert your controller to a discrete controller with a rate of 1e-3 for the second variant. Confirm that the discrete controller is stable and then try the model with it.
Lastly, why do you need a step size of 1e-3? Is that the maximum rate of the target machine you are going to be using? Usually target machines can go faster if the model is simpler (less calculations/time step -> time steps can be shorter), so I am curious how you came up with the 1e-3 requirement.

카테고리

Help CenterFile Exchange에서 Converters (High Power)에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by