Context and evolution in TIA Portal V21
In previous versions of TIA Portal it was already possible to integrate Git through Version Control Interface and add-ons such as VCI-VCS Connector. The previous series already covered how to prepare the environment, work with a local and remote repository, and recover versions: Part 1, Part 2 and Part 3.
The difference in this article is TIA Portal V21: SIMATIC Source Documents already existed for certain objects, such as LAD, DBs and PLC types, but Siemens extends its use to more languages, especially SCL, FBD and blocks with mixed languages. This allows more PLC logic to be represented through textual formats such as .s7dcl and .s7res, making comparison and versioning with Git easier.
The goal remains the same: traceability, comparison and recovery of PLC code changes. Instead of relying only on the TIA project binary file, the blocks are exported to a workspace with Version Control Interface and those files are versioned with Git.
Requirements
- TIA Portal V21 with Version Control Interface available.
- Git installed on Windows.
- GitHub Desktop, optional but convenient for reviewing diffs, commits and push.
- A GitHub account signed in to GitHub Desktop if a remote copy is required.
- A dedicated local workspace folder, for example
C:\PHS\TIA_GIT_TEST.
SIMATIC SD and VCI
SIMATIC Source Documents does not appear for the first time in V21: it is the textual format that TIA Portal can use to represent certain engineering objects outside the project. VCI exports blocks and types to files such as .s7dcl and, where applicable, .s7res. This allows Git to show line-by-line changes: new entries, modified conditions or removed logic.
Prepare the workspace
From the project tree, add a new workspace under Version control interface and associate it with the local folder shared by TIA Portal and Git. In this example the folder is C:\PHS\TIA_GIT_TEST.
Export formats
In Configure workspace, under Export formats, select SIMATIC SD for the available languages and objects: LAD, FBD, SCL, data blocks and PLC data types. It is best to define this when the workspace is created.
Change the formats to SIMATIC SD.
With that configuration, VCI generates the files in the folder shared by TIA Portal and Git.
First SCL FB exported
Program, save and compile the block. In the example, the motor FB in SCL is exported from VCI using Action: Export and Synchronize, taking advantage of the SIMATIC SD expansion in TIA Portal V21.
When the directory is checked, the exported file is already there, for example FB_Motor.s7dcl.
First commit and publication
Local Git
Now move to Git. First, open PowerShell in the workspace folder.
cd C:\PHS\TIA_GIT_TEST
git init
git status
git add .
git commit -m "Version inicial FB_Motor"
git log --oneline
Initialize the repository and check the project status.
Add all exported files and check that they are staged for the commit.
Create the first commit. If Git asks for identity, configure it once with git config --global user.name and git config --global user.email.
Check that the repository is on the master branch and that the working tree is clean.
GitHub Desktop
Then add the local repository in GitHub Desktop by selecting the same workspace folder.
At this point the repository is local, so publish it from GitHub Desktop. For real projects it can be kept private.
The motor block is now published in GitHub.
Changes, diff and history
Modify the FB
With the first version saved, modify the FB by adding one more variable and some logic.
The project detects the change. In the workspace, the synchronization status of the objects is visible.
To make the workspace match the project, select Export again.
GitHub Desktop shows the change because it compares the exported file with the version that was already uploaded before.
Commit, push and history
Create a commit with a clear comment, push it and check those changes in the history.
Key points: VCI is not Git; VCI synchronizes TIA with external files and Git keeps the history. Export moves changes from TIA to the workspace; Import does the opposite. Commit saves a local version; Push sends it to GitHub.
Ladder block: workflow check
The Ladder test remains a practical check of the same system: when the block is exported through SIMATIC SD, VCI generates files that Git can detect and compare within the workflow.
Export the Ladder block to the workspace.
Local Git detects the modified files and GitHub Desktop allows the change to be reviewed before confirming the version.
Then confirm the change with a commit and publish it to the remote branch.
The result is that the block is incorporated into the repository with traceable history, just like the other objects exported from TIA Portal.
Quick guide and related articles
Quick PDF guide
Compact summary of the workflow: TIA Portal, VCI Export, SIMATIC SD, Git diff, Commit, Push and GitHub.