Are there limitations with regard to executing modules in real-time?
Not all access operations 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:: Access to the IPC file system is restricted within the TwinCAT runtime. To read and write files from TwinCAT, use: fopen, fclose, fread and fwrite. See the example:
TwinCAT.ModuleGenerator.Samples.Show('FileAccess')
. - Direct hardware access: Direct access to devices/interfaces requires a corresponding driver, e.g. RS232, USB, network interface 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 operating system’s API cannot be used directly from within the TwinCAT runtime. An example is the integration of windows.h in C/C++ code.
- Precompiled libraries: During code generation by the MATLAB® Coder™, it is possible that no platform-independent C/C++ code is generated, but precompiled libraries are included. Real-time execution in TwinCAT is not possible in these cases. The coder.HardwareImplementation setting helps determine if 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';