Info

此问题已关闭。 请重新打开它进行编辑或回答。

Multi time steps for xPC target

1 次查看(过去 30 天)
CONG WANG
CONG WANG 2011-3-26
关闭: MATLAB Answer Bot 2021-8-20
Hi,
I am using a controller built with xPC target and Simulink. And I want to have different time steps for the control signal and the sensor sampling. But every time I am trying to compile and download it to the target PC, simulink tells me that for real time control only one single time step is allowed...
Is it possible to have multiple time steps for xPC target realtime control?
Begging for answers~
Cong @ MSC Lab, UC Berkeley

回答(1 个)

Gordon Weast
Gordon Weast 2011-3-28
You can have multiple different time steps in xPC Target if you set it up correctly.
I assume you are already using the fixed-step solver.
Next, the slower sample time must be an integer multiple of the faster sample time. The slower blocks will run every Nth time the faster blocks run, where N is the multiple. You can even have several different sample times, not just 2 as long as they're all some integer multiple of the fastest time.
Next, you can use single tasking or multi tasking. The difference is how overloads are handled in the slow task.
In single tasking, the slower task runs after the faster task in the same thread. That means the total TET for both must be shorter than the faster sample time.
In multi tasking, the slower task is in a different thread. The TET for the slower task just has to be shorter than the slow sample time. The faster thread will preempt the slow thread if the slow one is still running when the fast sample time hits.
You select the tasking mode on the solver page of the configuration parameters for the model.
This is discussed in our documentation.
Gordon Weast, xPC Target Development

此问题已关闭。

Community Treasure Hunt

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

Start Hunting!

Translated by