Are there limitations with regard to executing modules in real-time?
Not all access operations that are possible in MATLAB® under non-real-time conditions can be performed in the TwinCAT real-time environment. Known limitations are described below.
- Direct file access:: the access to the file system of the IPC is restricted from the TwinCAT runtime. To read and write files from TwinCAT, use: fopen, fclose, fread and fwrite. See sample:
TwinCAT.ModuleGenerator.Samples.Show('FileAccess')
. - Direct hardware access: direct access to devices/interfaces requires a corresponding driver, e.g. RS232, USB, network card, etc. It is not possible to access the device drivers of the operating system from the real-time context. However, TwinCAT offers a wide range of communication options for linking external devices, see TwinCAT 3 Connectivity TF6xxx.
- Access to the operating system API: the API of the operating system cannot be used directly from the TwinCAT runtime. An example is the integration of windows.h in C/C++ code.
- Precompiled libraries: it is possible that during code generation by the MATLAB CoderTM, no platform-independent C/C++ code is generated, but precompiled libraries are included. In these cases, no real-time execution in TwinCAT is possible. The coder.HardwareImplementation setting helps to check whether generic C/C++ code can be generated. For example
coder.HardwareImplementation.ProdHWDeviceType = 'Generic->32-bit x86 compatible';
andcoder.HardwareImplementation.TargetHWDeviceType = 'Generic->32-bit x86 compatible';