Cookies are important for this site to function properly, to guarantee your safety, and to provide you with the best experience. By clicking OK, you accept all cookies. For more information, please access our Privacy Policy.
Table of Contents
Tutorials / 
An Introduction to TIA Portal’s Version Control Interface Using Git and Github
Intermediate

An Introduction to TIA Portal’s Version Control Interface Using Git and Github

Siemens
TIA Portal
PLC Programming
Git Version Control

Introduction

Version control is a fundamental aspect of modern software development and project management. As automation engineers and programmers collaborate on intricate projects, ensuring seamless coordination, tracking changes, and preserving an organized history of revisions becomes imperative. The challenges arise when multiple individuals work simultaneously on the same project, leading to potential conflicts, unclear accountability for modifications, and difficulties in identifying and rectifying issues. This is where Version Control Interfaces come into play, providing a systematic approach to managing project files and codebase changes efficiently.

The Version Control Interface (VCI) in TIA Portal serves as a bridge between automation engineering projects and version control systems like Git and GitHub. VCI empowers engineers to seamlessly manage their project files, track modifications, and facilitate team collaboration. This interface simplifies the process of integrating version control into automation projects, program blocks are automatically converted to XML files and organized following the project’s structure. VCI ensures that every change made to the project is captured, attributed, and documented, providing a comprehensive history of the project's development lifecycle.

In this tutorial, you will learn how to integrate the Version Control Interface (VCI) within the TIA Portal environment, utilizing Git and GitHub as the underlying version control system. The tutorial begins with creating a GitHub repository, configuring Git, and establishing the connection between the local and GitHub repositories. Then, the focus shifts to the TIA Portal configuration, where you'll understand how to configure the VCI workspace, synchronize project elements, and manage modifications. Additionally, the tutorial introduces the VCI Git Connector Add-in, demonstrating how to automate commit and push operations directly from the TIA Portal interface. 

Prerequisites

To follow this tutorial, you will need an installation of TIA Portal. We will use the latest versions to date (v18), but you can use any other version. No additional hardware or software is required.

Version Control Interface in TIA Portal

Let’s start by opening your GitHub profile. If you don’t already have one, create an account on GitHub’s website. On your profile, copy the HTTPS link to your repository.

Figure 1.1 - Git / Version Control for PLCs | GitHub repository
Figure 1.1 - Git / Version Control for PLCs | GitHub repository

After that, we need to configure Git. Open a command prompt and type the following command

  • git init c:\Git_repository

This command will create and initialize a git repository at the specified location. This folder will contain all the files shared between TIA Portal and Git/GitHub.

Figure 1.2 - Git / Version Control for PLCs | Git repository initialization
Figure 1.2 - Git / Version Control for PLCs | Git repository initialization

Next, we need to type the following command to configure the username of this Git instance. Here, I set the username to “Redouane.”

  • git config –global user.name Redouane
Figure 1.3 - Git / Version Control for PLCs | Setting Git’s username
Figure 1.3 - Git / Version Control for PLCs | Setting Git’s username

The same logic applies to the user’s email. Type the following command to add the user’s email in the Git instance. I am using a fake email address in this example. Be sure to add a valid one.

  • git config –global user.email redouane@email.com
Figure 1.4 - Git / Version Control for PLCs | Setting Git’s email
Figure 1.4 - Git / Version Control for PLCs | Setting Git’s email

The last step is to link this Git session to the GitHub repository. First, we need to move to the Git repository we created with the following command

  • cd c:\Git_repository
Figure 1.5 - Git / Version Control for PLCs | Moving to the Git repository
Figure 1.5 - Git / Version Control for PLCs | Moving to the Git repository

Then, we use the following command to link this repository with the GitHub repository

  • git remote add origin <Link to your GitHub repository>
Figure 1.6 - Git / Version Control for PLCs | Linking Git with the GitHub repository
Figure 1.6 - Git / Version Control for PLCs | Linking Git with the GitHub repository

We are done configuring the Git side. We can move to the TIA Portal configuration. Open TIA Portal and create a new project with your chosen CPU. We will keep the main program empty by default for now.

Figure 1.7 - Git / Version Control for PLCs | Creating the TIA Portal project
Figure 1.7 - Git / Version Control for PLCs | Creating the TIA Portal project

Scroll down your project tree and open the “Version control interface” folder. Version Control Interface (VCI) streamlines project management by integrating with version control systems like Git/GitHub. As automation engineers and programmers collaborate on projects, VCI tracks changes to project files, offering transparency into who made modifications and when. This enables teams to maintain an organized history of revisions, simplifying the process of identifying and rectifying issues. The interface facilitates collaboration by allowing multiple users to work simultaneously, automatically merging changes and providing tools to resolve potential conflicts. 

Click on “Add new workspace.”

Figure 1.8 - Git / Version Control for PLCs | Accessing the version Control Interface
Figure 1.8 - Git / Version Control for PLCs | Accessing the version Control Interface

The VCI workspace is split into two parts. The left side contains all the program elements and blocks of your TIA Portal project, such as Program blocks, PLC tags, Technology objects, and PLC data types. The right side contains the folders and files created by VCI. PLC objects will be turned into XML files inside this folder. Since we already created a Git repository, we will select it as the VCI folder; This way, the VCI files will be ready to use directly in Git. 

To configure the VCI folder, click the “Workspace Configuration” button.

Figure 1.9 - Git / Version Control for PLCs | Workspace’s interface
Figure 1.9 - Git / Version Control for PLCs | Workspace’s interface

A small “Configure workspace” window will open. In the “Workspace path” section, we need to specify the path to the Git repository we created previously. Click on the “three dots” button to select the folder.

Figure 1.10 - Git / Version Control for PLCs | Workspace configuration
Figure 1.10 - Git / Version Control for PLCs | Workspace configuration

Be sure to have the right path to the Git repository. Once done, click on “OK.”

Figure 1.11 - Git / Version Control for PLCs | Adding the Git repository
Figure 1.11 - Git / Version Control for PLCs | Adding the Git repository

The VCI/Git folder is now configured. The next thing to do is to add the PLC station to the workspace. Select the PLC station, drag it to the workspace, and drop it. 

Figure 1.12 - Git / Version Control for PLCs | Adding the PLC station to the workspace
Figure 1.12 - Git / Version Control for PLCs | Adding the PLC station to the workspace

A folder named “PLC_1” will appear in the workspace containing all the files of your program elements. Also, status icons will appear on the project side. VCI compares the project blocks with the VCI files; if they are identical, it will indicate it with green icons.

Figure 1.13 - Git / Version Control for PLCs | Workspace folder and status icons
Figure 1.13 - Git / Version Control for PLCs | Workspace folder and status icons

You can browse to the VCI/Git folder, you should find all the files folders containing the XML files of your program.

Figure 1.14 - Git / Version Control for PLCs | VCI in the Git folder
Figure 1.14 - Git / Version Control for PLCs | VCI in the Git folder

Now let’s add a modification to the main program. Open it and reproduce the following program (Or any program of your choice).

Figure 1.15 - Git / Version Control for PLCs | Create a program in the main block
Figure 1.15 - Git / Version Control for PLCs | Create a program in the main block

Let’s go back to the VCI workspace. Since we introduced a modification, the status icons on the project side turned grey/blue. Indicating that these elements are not identical to the VCI files.

Figure 1.16 - Git / Version Control for PLCs | Blocks are no longer similar to the content of the workspace
Figure 1.16 - Git / Version Control for PLCs | Blocks are no longer similar to the content of the workspace

To synchronize the project side with the workspace, we must first select the export action on each nonsimilar element. Click on the “Action” section next to the main block and select “Export.”

Figure 1.17 - Git / Version Control for PLCs | Selecting the export action for the main block
Figure 1.17 - Git / Version Control for PLCs | Selecting the export action for the main block

And repeat the same step for the tag table.

Figure 1.18 - Git / Version Control for PLCs | Selecting the export action for the tag table
Figure 1.18 - Git / Version Control for PLCs | Selecting the export action for the tag table

Once done, click on the “Synchronize” button to apply the export actions.

Figure 1.19 - Git / Version Control for PLCs | VCI synchronization
Figure 1.19 - Git / Version Control for PLCs | VCI synchronization

The VCI workspace is updated, and the status icons should revert to green.

Figure 1.20 - Git / Version Control for PLCs | Blocks are now updated
Figure 1.20 - Git / Version Control for PLCs | Blocks are now updated

The VCI files have been generated, we can now create a Git commit and push (upload) it to the GitHub repository.

Open a common prompt and move to the VCI/Git repository with the “cd” command.

Figure 1.21 - Git / Version Control for PLCs | Moving the Git repository in the command prompt
Figure 1.21 - Git / Version Control for PLCs | Moving the Git repository in the command prompt

In Git, "add" and "commit" are fundamental commands in the version control process. "Add" refers to the action of staging changes made to your files, essentially preparing them for inclusion in the upcoming commit. This allows you to choose which changes to include selectively. Once changes are added, you "commit" them, creating a snapshot of the staged changes and a descriptive message. Commits represent milestones in the project's history and enable you to track and manage the evolution of your codebase over time.

Here, we will use the “git add -A” command to add all the files in the repository (with the -A argument)

  • git add -A
Figure 1.22 - Git / Version Control for PLCs | Adding the files to Git
Figure 1.22 - Git / Version Control for PLCs | Adding the files to Git

Then, we will commit the added files with the following command

  • git commit -m first

The “-m” argument adds a message to the commit. Here we’ll use “first” as the message to specify that it is the first commit.

Figure 1.23 - Git / Version Control for PLCs | Creating a new commit
Figure 1.23 - Git / Version Control for PLCs | Creating a new commit

The commit is created; we have now to push it to GitHub. To do this, we will use the following command

  • git push –set-upstream origin master
Figure 1.24 - Git / Version Control for PLCs | Pushing the commit to the GitHub repository
Figure 1.24 - Git / Version Control for PLCs | Pushing the commit to the GitHub repository

If we go to the GitHub repository, we will find the folders we committed with the right commit message.

Figure 1.25 - Git / Version Control for PLCs | The commit can be found in the GitHub repository
Figure 1.25 - Git / Version Control for PLCs | The commit can be found in the GitHub repository

VCI Git Connector - TIA Portal add-in

So far, we've covered how VCI and Git work and interact using manual commands. It is possible to automate Git operations directly from TIA Portal using an Add-in. This allows you to perform Git operations directly from the VCI interface and offers options for automating the commit and push process.

First, we need to install the VCI Git Connector Add-in. You can find its download page here. Once on the page, click on the “Add-in for TIA Portal V16-V18” link to download the add-in.

Figure 2.1 - Git / Version Control for PLCs | Downloading the VCI Git connector add-in
Figure 2.1 - Git / Version Control for PLCs | Downloading the VCI Git connector add-in

Once downloaded, go to the “Add-Ins” folder in your TIA Portal repository and copy the add-in into it.

Figure 2.2 - Git / Version Control for PLCs | Copying the downloaded file in the add-in folder
Figure 2.2 - Git / Version Control for PLCs | Copying the downloaded file in the add-in folder

Next, go to the “Add-Ins” tab in TIA Portal, right-click the add-in, and click “Activate.”

Figure 2.3 - Git / Version Control for PLCs | Activating the Add-In
Figure 2.3 - Git / Version Control for PLCs | Activating the Add-In

After that, we need to add the add-in to the VCI. Go back to the workspace, and click on the workspace configuration button. Then, in the “Version Control Add-in” section, select the “Git” add-in.

Figure 2.4 - Git / Version Control for PLCs | Enabling the add-in in the workspace
Figure 2.4 - Git / Version Control for PLCs | Enabling the add-in in the workspace

Let’s introduce another modification and commit/push it using the Git add-in. Click on “Add new block.”

Figure 2.5 - Git / Version Control for PLCs | Creating a new block
Figure 2.5 - Git / Version Control for PLCs | Creating a new block

We will add an FC block that will serve as a modification. Select “Function”, give a name to the block, and click on “OK”

Figure 2.6 - Git / Version Control for PLCs | Creating a new FC
Figure 2.6 - Git / Version Control for PLCs | Creating a new FC

If we go back to the VCI, we will find that it has no status icon because it is not present in the VCI/Git folder. Open the “PLC_1/Program blocks” folders in the workspace so we can add the function to it.

Figure 2.7 - Git / Version Control for PLCs | The FC has no status icon
Figure 2.7 - Git / Version Control for PLCs | The FC has no status icon

Drag and drop the function in the “Program blocks” folder in the workspace. 

Figure 2.8 - Git / Version Control for PLCs | Adding the FC block to the workspace
Figure 2.8 - Git / Version Control for PLCs | Adding the FC block to the workspace

Now we will perform Git command from the workspace. Return to the root folder and right-click on the “PLC_1” folder. You can notice that there is a “Git” section (from the add-in). Inside it, You will find all the most common Git commands, including add, commit, push, and pull (pull is used to retrieve the last commit from the GitHub repository).  Select “Add” to add the folder in Git.

Figure 2.9 - Git / Version Control for PLCs | Performing a “add” from the workspace
Figure 2.9 - Git / Version Control for PLCs | Performing a “add” from the workspace

Once added, repeat the same operation but select “Commit” instead to create a new Git commit.

Figure 2.10 - Git / Version Control for PLCs | Creating a new commit from the workspace
Figure 2.10 - Git / Version Control for PLCs | Creating a new commit from the workspace

A small window will open asking you to add a commit message. Type “Second” as the message and click on “OK”.

Figure 2.11 - Git / Version Control for PLCs | Adding a commit message
Figure 2.11 - Git / Version Control for PLCs | Adding a commit message

Now that we have a second commit, we need to push it to the GitHub repository. Repeat the same operation one last time but select the “Push” option.

Figure 2.12 - Git / Version Control for PLCs | Performing a “push” from the workspace
Figure 2.12 - Git / Version Control for PLCs | Performing a “push” from the workspace

Then, we can go back to the GitHub repository. We will find that the “PLC_1” folder has been update with the second commit.

Figure 2.13 - Git / Version Control for PLCs | The repository is updated with the second commit
Figure 2.13 - Git / Version Control for PLCs | The repository is updated with the second commit

We can automate this whole process by enabling the "Commit/Push on VCI synchronization" options. Each time a VCI synchronization is performed, this will automatically create a commit and push it to GitHub. To do this, right-click on the “PLC_1” folder, go to the settings, and enable both the “Commit on VCI synchronization” and “Push on VCI synchronization” checkboxes.

Figure 2.14 - Git / Version Control for PLCs | Enabling Commit/Push on VCI synchronization
Figure 2.14 - Git / Version Control for PLCs | Enabling Commit/Push on VCI synchronization

Conclusion

This tutorial taught you how to effectively integrate the Version Control Interface into TIA Portal projects and leverage Git/GitHub for streamlined version control. You began by setting up Git by initializing a repository and linking it to your GitHub repository. You configured the VCI workspace in TIA Portal, integrated it with your Git repository, and synchronized your project with the VCI files. You discovered the significance of status icons indicating changes, and you learned how to add, commit, and push changes to your GitHub repository using manual Git commands. Additionally, you explored the potential of the VCI Git Connector Add-in to automate these processes directly from TIA Portal, simplifying your version control workflows.

Utilizing version control offers numerous benefits and advantages for automation engineers. The ability to track changes and maintain an organized history of revisions enhances project transparency and accountability. Collaboration becomes smoother as team members work concurrently on projects, with automated merging and conflict resolution mechanisms simplifying the process. Version control safeguards against data loss and provides the means to revert to previous versions, ensuring project stability. The integration of version control with TIA Portal not only fosters efficient teamwork but also empowers engineers to confidently manage their automation projects, enabling innovation and continuous improvement.