Overview
The TwinCAT XML Server offers a PLC library with which write and read access to XML files can be implemented. The XML Server is characterized by its ease of use. It is particularly suitable, for example, for loading initialization data, as is often required when starting up a machine. It is also possible to save PLC variables formatted in an XML file including PLC comments. The structure of a variable in the XML document matches the structure of the variables in the PLC. This enables individual subelements of a variable to be accessed directly. Only those subelements (elements of a structure or an array) are transferred that are also defined in the XML file. When the PLC variables are written, missing elements can optionally be added.
Components
- TwinCAT XML Server: is a service that is started and stopped together with TwinCAT. It is the link between TwinCAT and the XML file.
- PLC library: the PLC library provides four different function blocks with which data from the PLC library can be written to and read from the XML file. Thus, variables can be stored formatted in an XML file and variables can be initialized in TwinCAT from an XML file.
Principle of operation
The XML Server communicates with the TwinCAT PLC via ADS. During a write operation, all variables to be written are converted to text and written to the XML file via the MSXML DOM parser. The XML file does not contain any information about the data types, but only the name of the variable as tag name and the value: <variable name> value </variable name>.
During a read operation, the data types for the variables to be read are determined via ADS and the texts from the XML file are converted accordingly.
