PLC API
The PLC library is supplied with the TwinCAT XML Data Server and copied into folder ...\TwinCAT\PLC\Lib during installation.
There are two function blocks for reading variables from the XML file:
- FB_XmlSrvRead
- FB_XmlSrvReadByName
and two function blocks for writing PLC variables to the XML file:
- FB_XmlSrvWrite
- FB_XmlSrvWriteByName
The first version (FB_XMLSrvRead, FB_XMLSrvWrite) uses the address and the size of the PLC variable for specifying the variable. The second version (FB_XMLSrvReadByName, FB_XMLSrvWriteByName) uses the symbol name for specifying the variable. The first version offers higher performance, although it is only supported from Build 1235 of TwinCAT version 2.10. For older TwinCAT versions only the function blocks FB_XMLSrvReadByName and FB_XMLSrvWriteByName can be used. In addition, the path of the XML file and the location of the variables within the XML document has to be transferred as input parameter to the function blocks in XPath format.