Can I use well-trained ANN model and "place" function for Hardware in the loop (HIL) testing?

I have a trained ANN in MATLAB that estimates the plant’s parameters. These estimates go to an adaptive-control block that recomputes the controller gain K with the place function.
The snag: place is not supported for code generation.
Can I keep the ANN and adaptive-control logic (including the place call) running in MATLAB/Python on a host PC, while
  • the plant runs in real-time on a simulator such as Typhoon HIL or OPAL-RT, and
  • the main controller code executes on a TI C2000 DSP?
Hope someone can help me for this question!

Risposte (1)

Hi,
I understand that you want to generate code for the 'place' function.
This can be achieved with the help of 'coder.extrinsic'
Here is a sample code snippet:
function K = computeK(A, B, p)
coder.extrinsic('place');
K = zeros(size(B, 2), size(A, 1));
K(:,:) = place(A, B, p);
end
Refer to the documentation link below for a better understanding:
Hope it helps!

1 Commento

I tried to use "coder.extrinsic" before however the simulation time is much more slower.
Now, I am considering the way to calculate controller gain K in Maltab environment so I don't need to generate code for "place" function. General idea is for example A value is sent from simulink model (while running) to MATLAB environment, then ANN using A to estimate B, then B is used to calculate adaptive controller gain K, then K is fed back to the Simulink model.
I think it's quite complicated.

Accedi per commentare.

Categorie

Scopri di più su Simulink Coder in Centro assistenza e File Exchange

Prodotti

Release

R2024b

Richiesto:

il 14 Mag 2025

Commentato:

il 16 Mag 2025

Community Treasure Hunt

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

Start Hunting!

Translated by