Control Standa Hardware with Simulink and Realtime Windows Target

조회 수: 4 (최근 30일)
Alexander
Alexander 2014년 3월 27일
답변: Jan Houska 2014년 4월 1일
Hi Guys
The Hardware is 8SMC1-USBhF-B1-1MC Stepper Motor Controller together with a 8MVT100-25-1 Stepper Motor. The Controller is connected via USB to my Win7 PC (Dell Precision T7500), with Matlab2014a installed. I have installed the drivers MicroSMC. Together with the drivers I got a dll file (USMCDLL.dll), a header (USMCDLL.h) and a lib file (USMCDLL.lib). I wrote an S-function, that just outputs the number of currently connected controllers. I can compile it via mex with Visual Studio 2010:
mex standatest.cpp -lUSMCDLL
In Normal mode, simulink runs fine.
Now when I set the target to rtwin.tlc and build it I get the following error:
### Generating code into build folder: C:\Users\Dev\Documents\StandaSoftware\Matlab\simulink\test_rtwin_win64
### Invoking Target Language Compiler on test.rtw
### Using System Target File: C:\Program Files\MATLAB_ETH\R2014a\toolbox\rtw\targets\rtwin\rtwin\rtwin.tlc
### Loading TLC function libraries
### Initial pass through model to cache user defined code
### Caching model source code
### Writing header file test.h
### Writing header file test_types.h
### Writing source file test.cpp
### Writing header file rtwtypes.h
### Writing header file multiword_types.h
### Writing header file test_private.h
### Writing header file rtmodel.h
### Writing source file test_data.cpp
### Writing header file rt_nonfinite.h
### Writing source file rt_nonfinite.cpp
### Writing header file rt_defines.h
### Writing header file rtGetInf.h
### Writing source file rtGetInf.cpp
### Writing header file rtGetNaN.h
### Writing source file rtGetNaN.cpp
### TLC code generation complete.
### Generating TLC interface API.
### Creating data type transition file test_dt.h
### Processing Template Makefile: C:\Program Files\MATLAB_ETH\R2014a\toolbox\rtw\targets\rtwin\rtwin\rtwin.tmf
### Creating test.mk from C:\Program Files\MATLAB_ETH\R2014a\toolbox\rtw\targets\rtwin\rtwin\rtwin.tmf
### Building test: .\test.bat
C:\Users\Dev\Documents\StandaSoftware\Matlab\simulink\test_rtwin_win64>set MATLAB=C:\Program Files\MATLAB_ETH\R2014a
C:\Users\Dev\Documents\StandaSoftware\Matlab\simulink\test_rtwin_win64>"C:\PROGRA~1\MATLAB~1\R2014a\bin\win64\gmake" -f test.mk EXTMODE_STATIC_ALLOC=0 EXTMODE_STATIC_ALLOC_SIZE=1000000 TMW_EXTMODE_TESTING=0 OPTS="-DON_TARGET_WAIT_FOR_START=1"
### Compiling test.cpp
C:/PROGRA~1/MATLAB~1/R2014a/sys/extern/win64/clang/bin/clang -emit-llvm -c -m64 -O4 -fno-ms-compatibility -U_MSC_VER -Wno-switch-enum -IC:/PROGRA~1/MATLAB~1/R2014a/toolbox/rtw/targets/rtwin/lib/include -x c++ -IC:/PROGRA~1/MATLAB~1/R2014a/toolbox/rtw/targets/rtwin/lib/include/cpp -I. -I.. -IC:/PROGRA~1/MATLAB~1/R2014a/simulink/include -IC:/PROGRA~1/MATLAB~1/R2014a/extern/include -IC:/PROGRA~1/MATLAB~1/R2014a/rtw/c/src -IC:/PROGRA~1/MATLAB~1/R2014a/rtw/c/src/ext_mode/common -IC:/PROGRA~1/MATLAB~1/R2014a/toolbox/shared/can/src/scanutil -IC:/PROGRA~1/MATLAB~1/R2014a/toolbox/rtw/targets/rtwin/src -IC:/Users/Dev/Documents/StandaSoftware/Matlab/simulink/test_rtwin_win64 -IC:/Users/Dev/Documents/StandaSoftware/Matlab/simulink -IC:/PROGRA~1/MATLAB~1/R2014a/rtw/c/src/ext_mode/common -DON_TARGET_WAIT_FOR_START=1 -DEXT_MODE -DUSE_RTMODEL -DMODEL=test -DRT -DNUMST=3 -DTID01EQ=1 -DNCSTATES=0 -DMT=1 -o "test.obj" "test.cpp"
### Compiling rtGetInf.cpp
C:/PROGRA~1/MATLAB~1/R2014a/sys/extern/win64/clang/bin/clang -emit-llvm -c -m64 -O4 -fno-ms-compatibility -U_MSC_VER -Wno-switch-enum -IC:/PROGRA~1/MATLAB~1/R2014a/toolbox/rtw/targets/rtwin/lib/include -x c++ -IC:/PROGRA~1/MATLAB~1/R2014a/toolbox/rtw/targets/rtwin/lib/include/cpp -I. -I.. -IC:/PROGRA~1/MATLAB~1/R2014a/simulink/include -IC:/PROGRA~1/MATLAB~1/R2014a/extern/include -IC:/PROGRA~1/MATLAB~1/R2014a/rtw/c/src -IC:/PROGRA~1/MATLAB~1/R2014a/rtw/c/src/ext_mode/common -IC:/PROGRA~1/MATLAB~1/R2014a/toolbox/shared/can/src/scanutil -IC:/PROGRA~1/MATLAB~1/R2014a/toolbox/rtw/targets/rtwin/src -IC:/Users/Dev/Documents/StandaSoftware/Matlab/simulink/test_rtwin_win64 -IC:/Users/Dev/Documents/StandaSoftware/Matlab/simulink -IC:/PROGRA~1/MATLAB~1/R2014a/rtw/c/src/ext_mode/common -DON_TARGET_WAIT_FOR_START=1 -DEXT_MODE -DUSE_RTMODEL -DMODEL=test -DRT -DNUMST=3 -DTID01EQ=1 -DNCSTATES=0 -DMT=1 -o "rtGetInf.obj" "rtGetInf.cpp"
### Compiling rtGetNaN.cpp
C:/PROGRA~1/MATLAB~1/R2014a/sys/extern/win64/clang/bin/clang -emit-llvm -c -m64 -O4 -fno-ms-compatibility -U_MSC_VER -Wno-switch-enum -IC:/PROGRA~1/MATLAB~1/R2014a/toolbox/rtw/targets/rtwin/lib/include -x c++ -IC:/PROGRA~1/MATLAB~1/R2014a/toolbox/rtw/targets/rtwin/lib/include/cpp -I. -I.. -IC:/PROGRA~1/MATLAB~1/R2014a/simulink/include -IC:/PROGRA~1/MATLAB~1/R2014a/extern/include -IC:/PROGRA~1/MATLAB~1/R2014a/rtw/c/src -IC:/PROGRA~1/MATLAB~1/R2014a/rtw/c/src/ext_mode/common -IC:/PROGRA~1/MATLAB~1/R2014a/toolbox/shared/can/src/scanutil -IC:/PROGRA~1/MATLAB~1/R2014a/toolbox/rtw/targets/rtwin/src -IC:/Users/Dev/Documents/StandaSoftware/Matlab/simulink/test_rtwin_win64 -IC:/Users/Dev/Documents/StandaSoftware/Matlab/simulink -IC:/PROGRA~1/MATLAB~1/R2014a/rtw/c/src/ext_mode/common -DON_TARGET_WAIT_FOR_START=1 -DEXT_MODE -DUSE_RTMODEL -DMODEL=test -DRT -DNUMST=3 -DTID01EQ=1 -DNCSTATES=0 -DMT=1 -o "rtGetNaN.obj" "rtGetNaN.cpp"
### Compiling C:/PROGRA~1/MATLAB~1/R2014a/rtw/c/src/rt_matrx.c
C:/PROGRA~1/MATLAB~1/R2014a/sys/extern/win64/clang/bin/clang -emit-llvm -c -m64 -O4 -fno-ms-compatibility -U_MSC_VER -Wno-switch-enum -IC:/PROGRA~1/MATLAB~1/R2014a/toolbox/rtw/targets/rtwin/lib/include -I. -I.. -IC:/PROGRA~1/MATLAB~1/R2014a/simulink/include -IC:/PROGRA~1/MATLAB~1/R2014a/extern/include -IC:/PROGRA~1/MATLAB~1/R2014a/rtw/c/src -IC:/PROGRA~1/MATLAB~1/R2014a/rtw/c/src/ext_mode/common -IC:/PROGRA~1/MATLAB~1/R2014a/toolbox/shared/can/src/scanutil -IC:/PROGRA~1/MATLAB~1/R2014a/toolbox/rtw/targets/rtwin/src -IC:/Users/Dev/Documents/StandaSoftware/Matlab/simulink/test_rtwin_win64 -IC:/Users/Dev/Documents/StandaSoftware/Matlab/simulink -IC:/PROGRA~1/MATLAB~1/R2014a/rtw/c/src/ext_mode/common -DON_TARGET_WAIT_FOR_START=1 -DEXT_MODE -DUSE_RTMODEL -DMODEL=test -DRT -DNUMST=3 -DTID01EQ=1 -DNCSTATES=0 -DMT=1 -o "rt_matrx.obj" "C:/PROGRA~1/MATLAB~1/R2014a/rtw/c/src/rt_matrx.c"
### Compiling rt_nonfinite.cpp
C:/PROGRA~1/MATLAB~1/R2014a/sys/extern/win64/clang/bin/clang -emit-llvm -c -m64 -O4 -fno-ms-compatibility -U_MSC_VER -Wno-switch-enum -IC:/PROGRA~1/MATLAB~1/R2014a/toolbox/rtw/targets/rtwin/lib/include -x c++ -IC:/PROGRA~1/MATLAB~1/R2014a/toolbox/rtw/targets/rtwin/lib/include/cpp -I. -I.. -IC:/PROGRA~1/MATLAB~1/R2014a/simulink/include -IC:/PROGRA~1/MATLAB~1/R2014a/extern/include -IC:/PROGRA~1/MATLAB~1/R2014a/rtw/c/src -IC:/PROGRA~1/MATLAB~1/R2014a/rtw/c/src/ext_mode/common -IC:/PROGRA~1/MATLAB~1/R2014a/toolbox/shared/can/src/scanutil -IC:/PROGRA~1/MATLAB~1/R2014a/toolbox/rtw/targets/rtwin/src -IC:/Users/Dev/Documents/StandaSoftware/Matlab/simulink/test_rtwin_win64 -IC:/Users/Dev/Documents/StandaSoftware/Matlab/simulink -IC:/PROGRA~1/MATLAB~1/R2014a/rtw/c/src/ext_mode/common -DON_TARGET_WAIT_FOR_START=1 -DEXT_MODE -DUSE_RTMODEL -DMODEL=test -DRT -DNUMST=3 -DTID01EQ=1 -DNCSTATES=0 -DMT=1 -o "rt_nonfinite.obj" "rt_nonfinite.cpp"
### Compiling C:/PROGRA~1/MATLAB~1/R2014a/rtw/c/src/rt_printf.c
C:/PROGRA~1/MATLAB~1/R2014a/sys/extern/win64/clang/bin/clang -emit-llvm -c -m64 -O4 -fno-ms-compatibility -U_MSC_VER -Wno-switch-enum -IC:/PROGRA~1/MATLAB~1/R2014a/toolbox/rtw/targets/rtwin/lib/include -I. -I.. -IC:/PROGRA~1/MATLAB~1/R2014a/simulink/include -IC:/PROGRA~1/MATLAB~1/R2014a/extern/include -IC:/PROGRA~1/MATLAB~1/R2014a/rtw/c/src -IC:/PROGRA~1/MATLAB~1/R2014a/rtw/c/src/ext_mode/common -IC:/PROGRA~1/MATLAB~1/R2014a/toolbox/shared/can/src/scanutil -IC:/PROGRA~1/MATLAB~1/R2014a/toolbox/rtw/targets/rtwin/src -IC:/Users/Dev/Documents/StandaSoftware/Matlab/simulink/test_rtwin_win64 -IC:/Users/Dev/Documents/StandaSoftware/Matlab/simulink -IC:/PROGRA~1/MATLAB~1/R2014a/rtw/c/src/ext_mode/common -DON_TARGET_WAIT_FOR_START=1 -DEXT_MODE -DUSE_RTMODEL -DMODEL=test -DRT -DNUMST=3 -DTID01EQ=1 -DNCSTATES=0 -DMT=1 -o "rt_printf.obj" "C:/PROGRA~1/MATLAB~1/R2014a/rtw/c/src/rt_printf.c"
### Compiling test_data.cpp
C:/PROGRA~1/MATLAB~1/R2014a/sys/extern/win64/clang/bin/clang -emit-llvm -c -m64 -O4 -fno-ms-compatibility -U_MSC_VER -Wno-switch-enum -IC:/PROGRA~1/MATLAB~1/R2014a/toolbox/rtw/targets/rtwin/lib/include -x c++ -IC:/PROGRA~1/MATLAB~1/R2014a/toolbox/rtw/targets/rtwin/lib/include/cpp -I. -I.. -IC:/PROGRA~1/MATLAB~1/R2014a/simulink/include -IC:/PROGRA~1/MATLAB~1/R2014a/extern/include -IC:/PROGRA~1/MATLAB~1/R2014a/rtw/c/src -IC:/PROGRA~1/MATLAB~1/R2014a/rtw/c/src/ext_mode/common -IC:/PROGRA~1/MATLAB~1/R2014a/toolbox/shared/can/src/scanutil -IC:/PROGRA~1/MATLAB~1/R2014a/toolbox/rtw/targets/rtwin/src -IC:/Users/Dev/Documents/StandaSoftware/Matlab/simulink/test_rtwin_win64 -IC:/Users/Dev/Documents/StandaSoftware/Matlab/simulink -IC:/PROGRA~1/MATLAB~1/R2014a/rtw/c/src/ext_mode/common -DON_TARGET_WAIT_FOR_START=1 -DEXT_MODE -DUSE_RTMODEL -DMODEL=test -DRT -DNUMST=3 -DTID01EQ=1 -DNCSTATES=0 -DMT=1 -o "test_data.obj" "test_data.cpp"
### Compiling C:/PROGRA~1/MATLAB~1/R2014a/toolbox/rtw/targets/rtwin/src/rtwin_main.c
C:/PROGRA~1/MATLAB~1/R2014a/sys/extern/win64/clang/bin/clang -emit-llvm -c -m64 -O4 -fno-ms-compatibility -U_MSC_VER -Wno-switch-enum -IC:/PROGRA~1/MATLAB~1/R2014a/toolbox/rtw/targets/rtwin/lib/include -x c++ -IC:/PROGRA~1/MATLAB~1/R2014a/toolbox/rtw/targets/rtwin/lib/include/cpp -I. -I.. -IC:/PROGRA~1/MATLAB~1/R2014a/simulink/include -IC:/PROGRA~1/MATLAB~1/R2014a/extern/include -IC:/PROGRA~1/MATLAB~1/R2014a/rtw/c/src -IC:/PROGRA~1/MATLAB~1/R2014a/rtw/c/src/ext_mode/common -IC:/PROGRA~1/MATLAB~1/R2014a/toolbox/shared/can/src/scanutil -IC:/PROGRA~1/MATLAB~1/R2014a/toolbox/rtw/targets/rtwin/src -IC:/Users/Dev/Documents/StandaSoftware/Matlab/simulink/test_rtwin_win64 -IC:/Users/Dev/Documents/StandaSoftware/Matlab/simulink -IC:/PROGRA~1/MATLAB~1/R2014a/rtw/c/src/ext_mode/common -DON_TARGET_WAIT_FOR_START=1 -DEXT_MODE -DUSE_RTMODEL -DMODEL=test -DRT -DNUMST=3 -DTID01EQ=1 -DNCSTATES=0 -DMT=1 -o "rtwin_main.obj" "C:/PROGRA~1/MATLAB~1/R2014a/toolbox/rtw/targets/rtwin/src/rtwin_main.c"
### Compiling C:/PROGRA~1/MATLAB~1/R2014a/rtw/c/src/rt_sim.c
C:/PROGRA~1/MATLAB~1/R2014a/sys/extern/win64/clang/bin/clang -emit-llvm -c -m64 -O4 -fno-ms-compatibility -U_MSC_VER -Wno-switch-enum -IC:/PROGRA~1/MATLAB~1/R2014a/toolbox/rtw/targets/rtwin/lib/include -I. -I.. -IC:/PROGRA~1/MATLAB~1/R2014a/simulink/include -IC:/PROGRA~1/MATLAB~1/R2014a/extern/include -IC:/PROGRA~1/MATLAB~1/R2014a/rtw/c/src -IC:/PROGRA~1/MATLAB~1/R2014a/rtw/c/src/ext_mode/common -IC:/PROGRA~1/MATLAB~1/R2014a/toolbox/shared/can/src/scanutil -IC:/PROGRA~1/MATLAB~1/R2014a/toolbox/rtw/targets/rtwin/src -IC:/Users/Dev/Documents/StandaSoftware/Matlab/simulink/test_rtwin_win64 -IC:/Users/Dev/Documents/StandaSoftware/Matlab/simulink -IC:/PROGRA~1/MATLAB~1/R2014a/rtw/c/src/ext_mode/common -DON_TARGET_WAIT_FOR_START=1 -DEXT_MODE -DUSE_RTMODEL -DMODEL=test -DRT -DNUMST=3 -DTID01EQ=1 -DNCSTATES=0 -DMT=1 -o "rt_sim.obj" "C:/PROGRA~1/MATLAB~1/R2014a/rtw/c/src/rt_sim.c"
### Compiling ../standatest.cpp
C:/PROGRA~1/MATLAB~1/R2014a/sys/extern/win64/clang/bin/clang -emit-llvm -c -m64 -O4 -fno-ms-compatibility -U_MSC_VER -Wno-switch-enum -IC:/PROGRA~1/MATLAB~1/R2014a/toolbox/rtw/targets/rtwin/lib/include -x c++ -IC:/PROGRA~1/MATLAB~1/R2014a/toolbox/rtw/targets/rtwin/lib/include/cpp -I. -I.. -IC:/PROGRA~1/MATLAB~1/R2014a/simulink/include -IC:/PROGRA~1/MATLAB~1/R2014a/extern/include -IC:/PROGRA~1/MATLAB~1/R2014a/rtw/c/src -IC:/PROGRA~1/MATLAB~1/R2014a/rtw/c/src/ext_mode/common -IC:/PROGRA~1/MATLAB~1/R2014a/toolbox/shared/can/src/scanutil -IC:/PROGRA~1/MATLAB~1/R2014a/toolbox/rtw/targets/rtwin/src -IC:/Users/Dev/Documents/StandaSoftware/Matlab/simulink/test_rtwin_win64 -IC:/Users/Dev/Documents/StandaSoftware/Matlab/simulink -IC:/PROGRA~1/MATLAB~1/R2014a/rtw/c/src/ext_mode/common -DON_TARGET_WAIT_FOR_START=1 -DEXT_MODE -DUSE_RTMODEL -DMODEL=test -DRT -DNUMST=3 -DTID01EQ=1 -DNCSTATES=0 -DMT=1 -o "standatest.obj" "../standatest.cpp"
In file included from ../standatest.cpp:23:
In file included from ../USMCDLL.h:11:
In file included from C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\\include\windows.h:208:
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\\include\stralign.h:473:16: error: use of undeclared identifier '_wcsicmp'; did you mean 'ua_wcsicmp'?
return _wcsicmp( (LPCWSTR)String1, (LPCWSTR)String2 );
^
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\\include\stralign.h:467:1: note: 'ua_wcsicmp' declared here
ua_wcsicmp(
^
1 error generated.
gmake: *** [standatest.obj] Error 1
It seems some undeclared function is used somewhere:
_wcsicmp
I do not really how to go about this.
Thanks

답변 (1개)

Jan Houska
Jan Houska 2014년 4월 1일
You cannot use any function of the Windows operating system in a code that you want to run in real time. This means that you cannot include the Windows headers into your code, either directly or indirectly, or link Windows libraries to your code. But, your code appears to contain #include "windows.h" somewhere.
If you must use Windows operating system calls in your code, there is no way to compile it and run in External Mode. However, you may try to use Normal Mode which runs the model uncompiled and where are no restrictions on using Windows functions.

카테고리

Help CenterFile Exchange에서 Target Computer Setup에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by