Memory usage
The CX7293 has 32 MB of main memory that is used by the firmware (TwinCAT/RTOS) and TwinCAT (TwinCAT memory). The TwinCAT memory is further divided into the router memory and the PLC memory. The router memory is used for ADS communication and the PLC memory for the actual PLC program including TcConfiguration, mapping and data.
19.1 MB of TwinCAT memory are available to the CX7293. Because the size of the memory is limited, it is important to check the memory usage and to adapt your PLC project if it is exceeded.
Router memory
On the one hand, you can adjust the size of the router memory in TwinCAT and set a smaller router memory depending on the ADS communication actually used.
By default, a value of 32 MB is entered in TwinCAT, which in turn is limited to 9 MB for the CX7293 because of the small main memory in the CX7293. A router memory of 9 MB is usually far too large for a small controller. A router memory of 4 MB is recommended for the CX7293 and can be even smaller if little to no ADS communication is used. However, a router memory of at least 1 MB should be adhered to and should not be less. How much router memory is used can be determined with the function block FB_GetRouterStatusInfo or alternatively with the Beckhoff Device Manager.
Note that the router memory is only re-created with a power off/on of the CX7293. A TwinCAT restart is not sufficient. As a rule of thumb, the smaller the router memory for ADS communication is set, the larger the application can be, i.e. the PLC program, TcConfiguration, mapping and data.
Determining the memory usage
With the function block FB_GetRouterStatusInfo, or alternatively with the Beckhoff Device Manager, it is possible to determine how large the memory requirement of the router memory is.
The Router display can be used to determine the memory requirements of the router memory. In this example, 20.5 kB of a maximum of 4 MB are used. The TcOs display shows the total memory usage of the TwinCAT memory including router memory and PLC program. In this example, a total of 7.1 MB is used.
With the help of this display, the size of the PLC program can also be calculated, as the router memory is fixed at 4 MB and is part of the TwinCAT memory. If you subtract the 4 MB from 7.1 MB, the PLC program occupies 3.1 MB.
Memory reserve
Since 7.1 MB of the 19.1 MB TwinCAT memory are used in this example, a reserve of 12 MB remains for the PLC program. Note that more memory is needed for a short time for an Online Change in TwinCAT. If you want to use the Online Change function, it is advisable to always have a certain reserve. In the most extreme case, twice the currently consumed PLC program may be required to execute an Online Change. An error message is displayed in TwinCAT if there is not enough memory available for the Online Change.