Daniel
unread,Jun 5, 2013, 5:31:09 AM6/5/13You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
Halle everyone,
i'm using Simulink for the first time and try to import C-Code into Simulink via S-function builder.
At the moment i think i've done everything right rgarding implementing C-Code and declaring neccessary information within S-function block but nevertheless i have the feeling that the build block isn't working anyway. Both output values "pfCosPhiSet" and "pfQSet" show me permanent the value "0" while all the necessaray input values got some sensible value in order to test the block.
I did the implementation and declaration of the S-function block as followed:
1) New *-mdl opened
2) S-Function Builder Block from library into model taken
3) Within "Data Properties" following input- and output-value defined:
In_1: ucPowerCurrentPercent / Data type: uint8
In_2: ucPowerTargetPercent / Data type: uint8
In_3: fCosPhiTarget / Data type: single
In_4: fCosPhiCurrent / Data type: single
In_5: bCosPhiCurrentValid / Data type: boolean
In_6: fQTarget / Data type: single
In_7: fQCurrent / Data type: single
In_8: bQCurrentValid / Data type: boolean
Out_1: pfCosPhiSet / Data type: single
Out_2: pfQSet / Data type: single
4) Within "Libraries" Source- and Header-Files as followed integrated:
Library/Object/Source files (one per line)
nap_control.c
nap_control_alg.c
Include files and external function declarations
Includes:
#include <math.h>
#include "nap_control.h"
#include "nap_control_alg.h"
#include "types.h"
5) Within "Outputs" two functions (as they are declared in "nap_control.c") as followed integrated:
extern bool_t napControl_GetCosPhi(f32_t *pfCosPhiSet, u8_t ucPowerCurrentPercent, u8_t ucPowerTargetPercent, f32_t fCosPhiTarget, f32_t fCosPhiCurrent, bool_t bCosPhiCurrentValid, f32_t fQCurrent, bool_t bQCurrentValid);
extern bool_t napControl_GetQ(f32_t *pfQSet, u8_t ucPowerCurrentPercent, u8_t ucPowerTargetPercent, f32_t fQTarget, f32_t fQCurrent, bool_t bQCurrentValid);
6) Build S-Function gives following response:
### 'wrap_nap_control.c' created successfully
### 'wrap_nap_control_wrapper.c' created successfully
### 'wrap_nap_control.tlc' created successfully
### S-function wrap_nap_control.mexw32 created successfully
Could it be that the fact, that both output variables ("pfCosPhiSet" and "pfQSet") are pointers (see 5. *pfCosPhiSet / *pfQSet), result in problems within the s-function block. Is it possible to test the ready built block somehow?
MATLAB-Version: R2009b
Compiler: Microsoft Visual C++ 2008 Express
System: Windows 7 (64-bit)
I would be glad to get some answers and maybe some support in order to cope with the described issue.
Thanks in advance,
Daniel