Need help with s-function error messages
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Daniel
el 31 de Mzo. de 2014
Respondida: Daniel
el 1 de Abr. de 2014
Hello! I would like to generate a s-function from c-code. It is a state feedback controller with 5 inputs and 1 output. I am new to both, c-code and s-functions... so here are my error messages:
### Start Compiling cp_state_feedback_sfunc mex('cp_state_feedback_sfunc.c', 'E:\Master\SEM 2\ESPRO\Matlab Models\cpcntrl_final\u_feedback_control2.c', '-IE:\Master\SEM 2\ESPRO\Matlab Models\cpcntrl_final')
Writing library for cp_state_feedback_sfunc.mexw32 c:\users\espro\appdata\local\temp\mex_pkknwq\cp_state_feedback_sfunc.obj .text: undefined reference to '_u_feedback_control2'
C:\PROGRA~1\MATLAB\R2013B\BIN\MEX.PL: Error: Link of 'cp_state_feedback_sfunc.mexw32' failed.
Unable to complete successfully.
Error in legacycode.LCT/compile (line 268)
Error in legacycode.LCT.legacyCodeImpl (line 84)
Error in legacy_code (line 87)
[varargout{1:nargout}] = legacycode.LCT.legacyCodeImpl(action, varargin{1:end});
Error in legacy (line 11) legacy_code('compile', def)
-----------------------------------------------------------------------------------
my .h file
----------------------------------------------------------------------------------- #ifndef STATE_FEEDBACK2_H_
#define STATE_FEEDBACK2_H_
#define k_x 54 //0.000324
#define k_xdot 245 //0.0145
#define k_a -802 //-0.0495
#define k_adot -11976 // -0.730
#define prefilter 9
#define fixed_point_shift 14
#define fixed_point_shift_pre 12
typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned long u32;
typedef unsigned long long u64;
typedef char s8;
typedef short s16;
typedef long s32;
typedef long long s64;
s16 u_state_control(short ref, short Last_Cposit, short speed, short Pangle, short Angvel);
#endif /* STATE_FEEDBACK_H_ */
-----------------------------------------------------------------------------------
my .c file
-----------------------------------------------------------------------------------
#include "state_feedback2.h"
s16 u_state_control( short ref, short Last_Cposit, short speed, short Pangle, short Angvel)
{
s32 Ref_val = ref;
s32 u_cntr;
s32 prefiltered;
prefiltered = ((Ref_val * prefilter) >> fixed_point_shift_pre );
u_cntr = ((k_adot * Angvel)>> fixed_point_shift ) + ((k_a * Pangle)>> fixed_point_shift) +
((k_xdot * speed)>> fixed_point_shift ) + ((k_x * Last_Cposit)>> fixed_point_shift );
return (s16)u_cntr;
}
-----------------------------------------------------------------------------------
LCT
----------------------------------------------------------------------------------- def = legacy_code('initialize');
def.SourceFiles = {'u_feedback_control2.c'};
def.HeaderFiles = {'state_feedback2.h'};
def.SFunctionName = 'cp_state_feedback_sfunc';
def.OutputFcnSpec = 'int16 y1 = u_feedback_control2(int16 u1, int16 u2, int16 u3, int16 u4, int16 u5)'
legacy_code('sfcn_cmex_generate', def)
legacy_code('compile', def)
legacy_code('slblock_generate', def)
-----------------------------------------------------------------------------------
I would really appreciate if somebody could tell me what these error messages mean and how i can avoid them.
Thanks alot
Daniel
0 comentarios
Respuesta aceptada
Kaustubha Govind
el 31 de Mzo. de 2014
Not sure if it's a typo in the question, but from your def.OutputFcnSpec, it looks like you are attempting to call u_feedback_control2, when the function defined in your header is u_state_control,
0 comentarios
Más respuestas (1)
Ver también
Categorías
Más información sobre Block and Blockset Authoring en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!