Overview
The PLC library Tc2_TcXmlDataSrv is supplied with the TC3 XML Server and copied into folder ...C:\TwinCAT\3.1\Components\Plc\Managed Libraries\Beckhoff Automation GmbH 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. 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.
Primitive data types
The following primitive data types are supported:
Data type | PLC example | XML example |
---|---|---|
UDINT, DINT, UINT, INT, USINT, SINT, DWORD, WORD, BYTE | value1 : DINT := -1; value2 : UDINT := 65535; | <dataentry> <MAIN.value1>-1</MAIN.value1> |
LREAL, REAL | value1 : LREAL = 1.2; | <dataentry> <MAIN.value1>1.2</MAIN.value1> |
STRING | str1 : STRING = 'hallo'; | <dataentry> <MAIN.str1>hallo</MAIN.str1> |
TIME, DATE, TOD,DT | date1:DATE :=D#2005-05-04; (* Time types are stored in the XML file as DWORD*) | <dataentry> <MAIN.date1>1115164800</MAIN.date1> |
BOOL | bool1:BOOL := TRUE; bool2:BOOL := FALSE; | <dataentry> <MAIN.bool1>true</MAIN.bool1> |
Requirements
Development environment |
Target system type |
PLC libraries to be linked |
---|---|---|
TwinCAT v3.1 Build 4011 |
PC or CX (x86, x64, ARM) |
Tc2_XmlDataSrv |