This document attempts to give a hands-on description on how to make a DLL from a controller built in Simulink. This makes it possible to develop advanced controllers in Simulink, and then use them from an arbitrary application. Persons with knowledge in the C programming language should have no problems converting the steps in this tutorial to build Linux/Unix libraries, thus expanding the scope of this document to be applicable not only on Windows.
When I have generated the code and update the grt_shell.c file for inputs and outputs I tried to build the DLL as mentioned in the section 4.6. when I execute the command gmake –f ($NAMEOFMODEL).mk I am getting an error “:128: *** missing separator. Stop.”.
I understand that this is caused due to the use of space in place of tabs. But as you might know the .mk file is generated by the RTW. I checked the line 128 in the .mk file and it has no space at all.
We are getting the error ' NMAKE : fatal error U1073: don't know how to make 'cn_main.ofile'
The make command returned an error of 2
'An_error_occurred_during_the_call_to_make' is not recognized as an internal or external command,
operable program or batch file.
This is appeared when we try to build the CANoe supported model. We are trying to interface Matlab into CANoe using the dll generated by the Matlab. But dll is not generated. Can anybody have a answer, please let us know.
i can follow till 5th step of 4.6
than gmake gives me this out put
C:\123\add1_grt_rtw>gmake -f add1.mk
C:/PROGRA~1/MATLAB/R2008b\sys\lcc\bin\lcclnk -s -LC:/PROGRA~1/MATLAB/R2008b\sys\
lcc\lib -o ../add1.exe add1.obj add1_data.obj rtGetInf.obj rtGetNaN.obj rt_log
ging.obj rt_nonfinite.obj grt_main.obj rt_sim.obj @add1_ref.rsp
*** Created executable: add1.exe
this donot match with step 4.6 - 6 so what am i doing wrong?
please help i need it real bad and real fast
i am using make 3.81 compiler
I have a problem. when I attemp to use gmake -f ($NAMEMODEL).mk I receive this error:
??? Undefined function or method 'gmake' for input arguments of type 'char'.
if I use the command :
!gmake -f ($NAMEMODEL).mk
it works but I can not see what gmake is dooing, the only output is :
>> !gmake -f controller.mk
gmake: `../controller.exe' is up to date.
can someone explain me hot to solve this problem? or please send me the code that I need to continue?
Good stuff here. Thanks! I'd just like to add a little bit. For those who don't know pascal, please see the python script pasted below. This can be used to test your dll. This specific example is for 3xinput and 2xoutput:
from ctypes import *
# first make some hooks into the impported functions
initiateController = cdll.controller._initiateController
getControllerOutput = cdll.controller._getControllerOutput
performCleanup = cdll.controller._performCleanup
# This makes python realise that the function outputs are pointers to c_chars
initiateController.restype = c_char_p
getControllerOutput.restype = c_char_p
performCleanup.restype = c_char_p
#The following line shows two different methods for passing the pointers in
errMsg = getControllerOutput(c_int(3), p_inputData, c_int(2), byref(outputData) )
print "getControllerOutput reports : ", errMsg
print "output = ", outputData, "\noutput = ", outputData
I had a similar error to Dennis from a project I was compiling and linking into a project here at work. Turns out I hadn't set up the Configuration Parameters correctly (Tools -> Real Time Workshop -> Options). After I had set these up appropriately the error went away.
23 Aug 2008
Hello Roland Pfeiffer,
Thanks the document "from simulink model to dll",It is very helpful to me.
but there is some error.
when I construct a project in vc2005, the simulink model dll is call in a simple main function.
when I build it , the error is happen; the error is
I am new to matlab and RTWEC, I am not able to find the custom target example. can you please guide / share the information.
24 Apr 2007
This document really kick-started my work. Thanks.
I ended up developing a more general approach that requires only a little more programming.
* Derive a custom TLC from the grt.tlc file using the "Custom Target" example in the RTW Embedded Coder documentation, which does NOT require RTWEC, only RTW. (This is easy.)
* Derive a custom TMF from the grt_lcc.tmf file. Make the changes proposed in the RTWEC example as well as the changes that Roland proposes to make to the 'lcc' and 'lcclnk' command line options. (Not too hard, you only need to change 2 or 3 lines.)
* Finally derive a C file as described by Roland. (This is the most work, but is outlined very well in the article.)
This will give you the opportunity to configure the model to build directly to a DLL without any manual intervention!
19 Mar 2007
10 Oct 2006
I want to use matlab program in VB
20 Jul 2006
Very good tutorial. I would recommend adding RTW to the keywords for this tutorial.
17 Mar 2006
Excellent step-by-step tutorial. It helped me to save a lot of time.