Documentation Home Page RT-LAB Home Page
Pour la documentation en FRANÇAIS, utilisez l'outil de traduction de votre navigateur Chrome, Edge ou Safari. Voir un exemple.

CanAc2Host simulation


Simulink blocks for the Softing CanAc2 board now support simulation on Win32 target. In this mode, the s-functions do not actually access a CanAc2board. This mode is rather used to emulate CanAc2 transmission. In order to achieve this, the 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 s-function of the CanAc2 blocks. The new functions are compiled in a library, and a Visual C++ project is provided so that the user can modify the functions and recompile the library at will.

The library and files are organized as follow :

>- Source files for the user-specific functions:

They are located in Simulink\libRXXXXy\user\src\Softing\CanAc2 where 'RXXXXy' is one of the Matlab releases supported by RT-LAB. 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 of these files contains 3 functions. For example, the canac2_ctl_win32.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 structure specific to the CanAc2 s-functions. This structure is filled during initialization before the call to OpalInit_canac2_ctl(). The definition of the ld structures of each CanAc2 block can be found in the directory common/include_target, in the files canac2_ctl.h,canac2_recv.h, canac2_send.h, canac2_monitor.h. Because these structures are used by the QNX code also, it is very important not to modify these structures, but OPAL-RT may need to modify them from one 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 directory Simulink\libRXXXXy\user\lib (replace RXXXXy 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.

OPAL-RT TECHNOLOGIES, Inc. | 1751, rue Richardson, bureau 1060 | Montréal, Québec Canada H3K 1G6 | | +1 514-935-2323