Effacer les filtres
Effacer les filtres

Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

Multi time steps for xPC target

1 vue (au cours des 30 derniers jours)
CONG WANG
CONG WANG le 26 Mar 2011
Clôturé : MATLAB Answer Bot le 20 Août 2021
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

Réponses (1)

Gordon Weast
Gordon Weast le 28 Mar 2011
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

Cette question est clôturée.

Community Treasure Hunt

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

Start Hunting!

Translated by