Effacer les filtres
Effacer les filtres

coder.excentric not working when compiling with TwinCat Target

2 vues (au cours des 30 derniers jours)
Dries billiet
Dries billiet le 11 Mar 2014
Commenté : Dries billiet le 20 Mar 2014
Hello,
I am working on a case where I put simulink generated code into an embedded PC. My model works fine in simulink, but when I try to generate the code for my embedded controller, it fails. The fault message is the following.
_Failed to eliminate a call to the MATLAB function 'butter'. For non-simulation builds, calls to unsupported MATLAB functions are eliminated if they do not affect function out puts. Function 'filter1/MATLAB Function' (#34.92.133), line 6, column 1: "[a,b] = butter(w,[x y]/(z/2), 'bandpass')"
I found out that the actual problem is that coder.extrinsic('butter') is not allowed by external compilers. But I really need a way to create a butterworth filter in a matlab function block.Because my system needs a filter with adaptable bandwith. Is there somebody who knows a possible workaround?
function [a,b] = fcn(w,x,y,z)
a=zeros(1,(11));
b=zeros(1,(11));
coder.extrinsic('butter');
[a,b] = butter(w,[x y]/(z/2), 'bandpass');

Réponse acceptée

Tom Bryan
Tom Bryan le 17 Mar 2014
If you leave out the coder.extrinsic('butter') command, then it will generate code for the embedded processor. But, in that case, the butter() command requires constant inputs.
It is possible to create a table of constant coefficient values that you can index into as a function of discrete w, x, y, z values. Would that be a workable option for you?
  2 commentaires
Dries billiet
Dries billiet le 17 Mar 2014
Nice idea! I'll try to work this one out!
Dries billiet
Dries billiet le 20 Mar 2014
This does non't work. Because the coeficients are non constants. But it brougt me on the idea of adding a 'database' (read: big array) with the calculated transfert functions already in the array.

Connectez-vous pour commenter.

Plus de réponses (1)

Kaustubha Govind
Kaustubha Govind le 13 Mar 2014
You can either implement the functionality yourself in C, or find a third-party library that does so, and call it in your MATLAB code using coder.ceval.
  1 commentaire
Ketan
Ketan le 15 Mar 2014
Here are few other options:
- Implement the desired filter coefficient calculation yourself in MATLAB and call this code in your function block
- Try to leverage some of the more advanced filter functionality in DSP system toolbox:

Connectez-vous pour commenter.

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by