- Index
- » Users
- » Allyson10
- » Profile
Posts
Posts
It worked! Thank you!
I've seen many examples on how to implement it and it seems so simple, but every time I try to run an external function written in C an error happens.
My goal is to apply it on a predictive control system, but first I'd like to do an simple example to learn how to do it. Can someone help me?
I've tried this example:
class ChirpSignal
Modelica.Blocks.Interfaces.RealOutput u;
parameter Modelica.SIunits.AngularVelocity w_start=0;
parameter Modelica.SIunits.AngularVelocity w_end=10;
parameter Real A=1;
parameter Real M=10;
equation
u=Chirp(w_start, w_end, A, M, time);
end ChirpSignal;
With the Chirp function being:
function Chirp
input Modelica.SIunits.AngularVelocity w_start;
input Modelica.SIunits.AngularVelocity w_end;
input Real A;
input Real M;
input Real t;
output Real u "output signal";
external "C" annotation(Include="#include \"Chirp.c\"");
end Chirp;
And the .c file as:
double Chirp(double w1, double w2, double A, double M, double time)
{
double res;
res=A*w1*w2*M*time;
return res;
}
The error is as shown bellow:
I'm not using a header file, but already tried to use it. What should I do?
Thank you!
- Index
- » Users
- » Allyson10
- » Profile