Automate with XML
There are now four possibilities for editing variables in the zenon Editor:
- Import via a driver:
For example, Siemens S7 TIA portal, Allen-Bradley ControlLogix, OPC UA and many more.
- Export/import in dBase format:
An old format that can still be used by Excel and Access.
- Export/import in CSV (comma-separated text file):
This file format is particularly suitable for semi-automated engineering in Excel, where mass processing is often easier to handle than in zenon, for example when modifying addresses.
- Export/import with XML
The following particularly speak in favor of this supreme method:
- XML export/import is available for virtually all zenon modules.
- All data is exported (e.g. dBase and CSV only support four limit values).
- All files can be easily used with modern programming methods such as LINQ to XML.
- Very good performance.
Methods 2 to 4 are particularly well-suited to automation purposes, because they can be used to create, modify and delete variables (and also other objects with XML).
In addition to manual XML export/import, there is the particularly useful method of automating this process using the API. We even expressly advise doing this, because this way objects can be created or modified using the API directly. And with XML export/import, this usually works much more quickly because each object does not need to be handled individually.
We recommend the following procedure: export all existing objects by means of XML. Then carry out the necessary changes in the automation tool (for example, by LINQ to XML) and import the file again. A freely-available example in which the XML import is shown is the project wizard.
Another benefit of the XML method is that you can easily create and save templates with it. Two methods are available:
- Create the corresponding objects (variables, screens, functions, scripts, recipes, users, etc.) once manually in the zenon Editor and then export these by means of XML into a template folder. This can also be automated if required. What is important for this is a uniform naming convention, for example when all templates start with the “tpl_” prefix. This way, an automation tool can identify all templates and process them automatically.
- With the screens, it is also possible to create templates using the screen template mechanism. The advantage in doing this is that the name, description, screen size and preview screen are included in the zip file.
Ideas for practical use
The most frequent application for automated engineering is surely use in conjunction with variables. Be it just transferring variables from other tools or issuing Modbus addresses, correcting driver configuration information or converting a driver to a different one, including manipulating address information. The large amount of data and the error rate of manual entries speak in favor of automation here.
A very exciting possibility is offered in conjunction with zenon Logic, our integrated PLC system. The user positions graphic objects in a screen, in the form of symbols. In the background, the variables and detailed screens (faceplates) are then created by a wizard and even the PLC code is created.
A further example in conjunction with zenon Logic is the metering point administration: when a metering point is created, the code to calculate the relative values is also created in zenon Logic.
Many machine manufacturers use automation to individualize their projects. Instead of offering all options in a large project where options that are not required are deactivated for each individual machine, the machine project is tailor-made from a modular system with a wizard. The individual configurations are then stored as templates in XML format and are compiled as required. This configuration can also be carried out in part with external tools.
Examples of automated engineering in zenon
The zenon Excel macro
The zenon Excel macro was developed by COPA-DATA consultants and shows how easy it is to create drivers and variables in zenon from Excel. The example consists of an Excel table with its own macros and four buttons: the connection to zenon Editor is established with the first button; the second button provides all available projects; the drivers defined in the Excel table are created with the third button and the predefined variables are created in zenon with the fourth button. You can request this Excel file from COPA-DATA anytime.
The zenon Automotive Generator (zag)
“zag” is a very efficient example of automated engineering. You can find details about it on our web site.
The project wizard
The project wizard is supplied with zenon and is automatically opened with each new project. It is programmed in C# and covers the issues described very well with:
- Direct modifications using zenon API:
creating a driver for example.
- Import of existing XML files from stored templates:
importing a demo project.
- Handling of screen templates:
zenon standard and user-defined screen template selection and import.
The wizard also shows how multithreading can be implemented. For example, this is how the zenon screen templates are read in their own thread. The wizard is VSTA-based and is available as source code.
With automated engineering in zenon, you have a powerful tool at hand; compared to manual engineering you can save a great deal of time in project configuration and provide a significant increase in accuracy and reproducible results. zenon does indeed offer many possibilities out of the box for efficient project creation. However, with automated engineering, these can be multiplied and efficiency can be increased accordingly.
We wish you much success with your automation projects!