...
Simulink blocks for the Softing CanAc2 board now support simulation on Win32targetWin32 target. In this mode, the sfunctions s-functions do not actually access a CanAc2board. This mode is rather used to emulate CanAc2 transmission. In order to achieve this, the sfunctions s-functions can be customized to execute user-specific code during initialization, execution and reset.
These features are been made available by calling specific functions within the MdlInitializeConditions, MdlOutputs and MdlTerminate sections of the sfunction s-function of the CanAc2 blocks. The new functions are compiled in a library, and a VicualCVisual C++ project is provided so that the user can modify the functions and recompile the library at will.
Thelibrary The library and files are organized as follows follow :
>- Sourcefiles Source files for the user-specific functions:
They arelocated are located in Simulink\libRn\user\src\Softing\CanAc2 where 'Rn' is one of the Matlab releases supported by RT-LAB such as R14, R2006b, etc. There is one file for each CanAc2 block : canac2_ctl_win32.c, canac2_recv_win32.c,canac2_send_win32.c and canac2_monitor_win32.c.
Each ofthese of these files contains 3 functions. For example, the canac2_ctl_win32.ccode c code contains the calls to :
OpalInit_canac2_ctl(OpalLocalData_canac2_ctl *ld), OpalClose_canac2_ctl(OpalLocalData_canac2_ctl *ld), OpalOutput_canac2_ctl(OpalLocalData_canac2_ctl *ld)
The argument ld passed to each of these functions is a structurespecific structure specific to the CanAc2 sfunctionss-functions. This structure is filled duringinitialization during initialization before the call to OpalInit_canac2_ctl(). The definition of the ld structures of each CanAc2 block can be foundin found in the directory common/include_target, in the files canac2_ctl.h,canac2_recv.h, canac2_send.h, canac2_montormonitor.h. Because these structuresare structures are used by the QNX code also, it is very important not to modifythese modify these structures, but OpalOPAL-RT may need to modify them from one releaseto release to the other.
RT-LAB release comes with a pre-compiled library of (quasi-)empty functions. As the user customizes the source codes of the functions, he will need to recompile the library. A Visual C++ project is provided in the same directory as the source codes. During compilation, the library, libOpalCanAc2_PCIwin32RTRn.lib, is placed in the directorySimulinkdirectory Simulink\libRn\user\lib (replace Rn by the actual Matlab release number).
After a recompilation of the library, the user simply needs to recompile its model and run it. The library gets linked to the model during compilation. For this reason, the name of the library should not be modified by the user.