Creating simulation template project
Creating and adding a new simulation PLC is done via selection and activating the Contextmenu entry "Create Simulation PLC-Project" of the PLC runtime that is intended to be simulated in the configuration navigation tree (see Figure 1).
Within the now appearing Dialog, the Simulation PLC runtime must be selected (Figure 2). This dialog shows the currently available target systems. If the designated simulation system is not in the tree, it can be added via the "Search" button. With leaving the dialog over "OK" the TwinCAT Simulation Manager generates a simulation framework for the selected PLC, assigns it to the specified target system and runtime and adds it to the TwinCAT Simulation Manager configuration project.
This PLC framework project will contain all located IO-Symbols of the original PLC project in reversed/mirrored allocation (inputs --> outputs and outputs --> inputs, see Table 1).
A template PLC project can be created via the menu item 'Edit' --> 'Generate simulation PLC project'. This template is created from the currently integrated original PLC projects. The following components of the original project(s) are considered and possibly adopted in the simulation PLC project.
- Libraries that are in the standard PLC control library path ("[INSTALLATIONSPFAD_PATH]\Plc\Lib"]
- All allocated input and output symbols (%I, %Q) of the original PLC projects are adopted in the simulation project. Inputs however are created as outputs and according to the rules defined in the table. Permanently allocated, universal variables and block variables as well as VAR_CONFIGs are used as symbols (also see 'Standard mappings').
|
Original PLC symbol |
Device I/O |
Signal direction |
Simulation PLC symbol |
Description |
---|---|---|---|---|---|
1 |
VAR_INPUT |
Input |
<-- |
VAR_OUTPUT (%O) |
A device delivers a signal to the PLC, e.g. an "On" switch. In the simulation mode, the simulation PLC delivers the switch position via an output symbol to the original PLC. |
2 |
VAR_OUTPUT |
Output |
--> |
VAR_INPUT (%I) |
A block output signal is transmitted to a device, e.g. a 'bRunning' flag to a light |
3 |
VAR_INPUT |
Output |
--> |
VAR_OUTPUT (%I) |
The symbol specifies the interface to a device input. The block is not usually filled with code |
4 |
VAR_OUTPUT |
Input |
<-- |
VAR_INPUT (% Q) |
The symbol specifies the interface to a device output. The block is not usually filled with code |
Table 1: Generation rules for "reverse" or "mirrored" symbolic
Figure 4: Case 1 and 2 (simulated)
- The data types of the allocated instances / symbols
- POUs, which contain allocated symbols.
POU blocks may contain other POUs. These are recursively created when they contain allocated symbols. In the process, the inputs and outputs and their allocations are mirrored.
The creation only takes into account symbols / instance paths that lead to a allocated symbol. Other variables will not be created. Symbols that are added to the orignal project after the Simulation configuration has been created, can be maintained into the simulation project via the Adding symbols to the simulation project functionality.
Restrictions:
- One original PLC project can be bound to exactly one Simulation PLC project.
- Located Symbols out of Libraries are not supported
- Located Pointer data types are not supported
The next step is to fill the empty shell of the simulation project with simulation code. This is specific to the application. For this task PLC Control Application can be opened via context menu "Open PlcControl ...".
In the simulation mode, the original symbols with their correspondences are connected in the simulation PLC.