Effacer les filtres
Effacer les filtres

Simulink: Generated C code for a PID controller is delayed compared to its model

6 vues (au cours des 30 derniers jours)
Moritz Timmer
Moritz Timmer le 6 Déc 2023
Réponse apportée : Sarthak le 21 Déc 2023
Hi,
For an embedded project we created a PID controller with Simulink. Then, we generated C code from this model and integrated it into our embedded project. However, when we tested the controller on our hardware (AVR microcontroller), we noticed a rather large overshoot. Since the model has no such problem, we plotted our measured controller output and compared it with the model. We noticed that our measured data is delayed by ~120 seconds compared to the modelled data. This is even the case when we only locally test the generated C code with the measured input values (thus, the error does not lie in our hardware/controller, but in the generated C code).
Does someone has an idea, what could be configured wrong in Simulink, such that this happens?
Thanks in advance, Moritz

Réponses (1)

Sarthak
Sarthak le 21 Déc 2023
Hi Moritz,
I faced a similar issue. The variable I was using for indexes was of type double. I was able to resolve the issue after changing it to int32 type. If this doesn't resolve your issue, you can create a technical support service request at the following link:
I hope this helps!

Catégories

En savoir plus sur Simulink dans Help Center et File Exchange

Produits


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by