MATLAB: How to use custom drivers for Vicon motion capture system along with xPC target 3.4 (R2008a)

Simulink Real-Time

I am trying to use Vicon motion control system along with xPC target. I have obtained from Vicon a S-function that can control the Vicon system in Simulink. This S-function calls functions from an external 'dll' file to achive the control. When I generate code from this model so that I can deploy it to the xPC target, I receive compiler errors.

Best Answer

DLL files are windows specific and can not be used in xPC target environment. This is the reason that there is an error.
In case you can get Vicon to supply '.lib' file instead of the '.dll' file, you can use the following method to use the motion capture system:
1) Ask the third party, Vicon, to provide a library that includes all the functions in the .dll file. Normally, venders provides .lib files and .dll files because it does not require any extra effort for the venders to generate library.
2) Compile the model, which generates a file named modelname.mk under modlename_xpc_rtw directory. (Here modelname is the name of the model)
3) Open the modelname.mk, change
LIBS = $(LIBS) xpcruntime.lib
into
LIBS = $(LIBS) xpcruntime.lib thirdpartylibrary.lib
where thirdpatylibrary.lib is the library from the third party.
4) Rebuild the mode by using moldename.bat under modelname_xpc_rtw. The second time build will link the thirdpartylib.lib into the model, which can be loaded to xPC Target. The newly created model does not require the .dll file at run time.
Please note the moldename.bat file is rewritten whenever the model is built.