Open a TwinCAT 2 PLC project
- TwinCAT XAE is started. A TwinCAT project is open. You should be aware of the restrictions described below the following guide.
- 1. Mark the PLC object in the Solution Explorer view and select the Add Existing Item command in the Project menu or the context menu.
- 2. In the Open dialog, select the desired Plc 2.x project or library from the file system. To search, you can set the file filter in the bottom right-hand corner of the dialog.
- After that the TwinCAT 2.x converter starts automatically.
- 3. The TwinCAT 2.x converter checks whether the project can be compiled without error. If so, it processes the project automatically.
If the project contains visualization objects with placeholder variables that the converter cannot resolve, the respective visualizations are integrated directly as a grouping in place of the visualization references. - 4. Library conversion: If a library for which no conversion rule has been defined yet is referenced in the project to be opened, the dialog Converting a library reference appears. Define here whether and how the converter should replace the previous library reference by an up-to-date one. If in doing so you select a library for which the project information is missing, the Project information dialog appears, which you have to fill out.
- The converter loads the adapted project.
Restrictions when reusing a TwinCAT 2.x project in TwinCAT 3.1
Automatic syntax adjustments only with previous compilability The syntax differs between TwinCAT 2 (TC2) and TwinCAT 3 (TC3) in certain respects (e.g. when initializing arrays). Please note that the converter only adapts the syntax at these code positions if the TC2 project to be converted can be compiled on the TC2 side. Specifically, this means: During the conversion process, the converter contained in TC3 first compiles the selected TC2 project with a TC2 compiler. Syntax adjustments of the TC2 code are only made during the creation of the TC3 SPS project if this TC2-side compilation is successful. The prerequisite for a successful TC2-side compilation is that all necessary TC2 libraries are made available to the converter. This can be achieved, for example, by inserting the libraries referenced in the TC2 project into the folder C:\TwinCAT\\3.1\Components\\Plc\Converter\\Lib, or by notifying the converter of the locations of the TC2 libraries via the displayed conversion dialogs. |
Compilation | It must be possible to compile the project in TwinCAT 2.x PLC Control without compilation errors. Nevertheless, TwinCAT issues warnings during the compilation. These are evoked by implicit conversions that can lead to the loss of information (for example due to the change of a sign). TwinCAT 3.1 tests case statements against the switch variable: CASE USINT OF INT is not checked in TwinCAT 2.x, but an error message is displayed when importing into TwinCAT 3.1. |
Libraries | All variables and constants used in a library also have to be declared in this library. It must be possible to compile the library in TwinCAT 2.x without errors. |
Syntactic and semantic restrictions |
|
Memory |
|
Visualization
Placeholders and their replacement | Placeholder | VAR_INPUT | Use | Replacement |
| MAIN.$LocalVar$.aArr[0] | localVar: MyStruct; | localVar.aArr[0] | localVar := MAIN.myStructVar |
| $Var$.aArr[0] | Var : MyStruct; | Var.aArr[0] | Var := MAIN.myStructVar |
| MAIN.myStructVar.aArr[$Index$] | Index : INT; | MAIN.myStructVar.aArr[Index] | Index := 0 |
Problematic placeholders |
| |||
Non-importable elements | Trend, ActiveX – the import is not possible because the implementation is very different. In TwinCAT 3.1 a corresponding warning is given and a corresponding manual reproduction is necessary. |
Programming languages | ST, IL, FBD | No restrictions |
| LD | TwinCAT 3.1 imports function blocks with parallel branches so that the part before the branch is repeated for each branch. This corresponds to the generated code that TwinCAT 2.x generates for parallel branches.
|
| SFC |
Explanation: Implicit variables that TwinCAT 3.1 creates for actions are given an underscore as a prefix in TwinCAT 3.1. An invalid identifier with a double underscore would result. |
| CFC |
|
See also:
- TC3 User Interface documentation: Command Add Existing Item (Project)