Blog

PLC Code Diffs: See Exactly What Changed Between Any Two Versions

Flowchart diagram with blocks labeled EQU, CTU, and MOV, illustrating a process with counters and source/destination

A machine starts behaving differently, and nobody remembers changing the code. Before you can get back to a known-good state, you need to know exactly what is different between the version that is running and the last version that worked. Copia’s visual diffs render that comparison for PLC code, so you can see the changed logic between any two versions without opening both projects side by side. 

As these users get more comfortable with Git, it’s useful to dig a little deeper to leverage the maximum benefit possible from the tools at their disposal.  Let’s take a closer look at one of those fundamental tools in Copia’s built-in version control, Diffs.

The Basics

A Diff is a comparison between two commits, or project snapshots.  A Diff contains concise information about what exactly is different between the two versions.  Traditionally, a Diff is purely text-based, and can only be effectively leveraged for text-based files.  

Git diff of a Python function with removed lines highlighted in red and added lines in green
A Git Diff of a Python file

Copia developed Visual Diffs, or VisDiffs, to overcome this limitation for PLC code.  With VisDiffs, Copia’s built-in version control makes it easy to see what changed from one version to the next, just by clicking on a commit, either in Copia’s Desktop App, or in a web browser, on Copia’s Web App.

View Options

When viewing a Diff in Copia, it’s usually most helpful to view only the parts of the PLC code which have changed. By default, Copia hides things that haven’t changed, but it’s easy to show unchanged elements with the View Options dropdown menus.

Copia desktop app View Options menus for the project tree and render pane, with toggles to show or hide unchanged items
A Commit in Copia’s Desktop App showing both the Project Tree View Options (center) and Render Pane View Options (right)

Digging Deeper

Along with giving the ability to easily see what changed in a single commit, Copia also allows users to compare non-sequential commits, with just a couple extra clicks.

Copia desktop app with the Compare Commits toggle on, comparing two tagged versions of a ladder routine
By selecting Compare Commits (outlined in red), users can select any two commits to compare them, as shown

This makes it easy to see changes in bulk, allowing users to compare, for example, the current version of development code to the last major release version. 

This ability extends further, and allows users to even compare commits across different branches, allowing users to easily compare any two versions of a PLC project, even, for example, two coexisting, current versions of a PLC project undergoing parallel or multi-user development.

Copia desktop app comparing commits across branches, with the factory-testing branch selected and rung changes highlighted
Selecting a branch to compare (outlined in red) allows users to easily compare commits across branches; shown is a comparison between v1.1 on the main branch, and the most recent commit on the factory-testing branch.
With Copia’s VisDiffs, and the many tools made available for interacting with them, it’s quick and easy to compare any historical or current development versions against one another, or against a device backup captured with Copia’s DeviceLink™.  To see these tools in action for yourself, start your free trial at copia.io/trial

All Posts