SPT Libraries
The SPT Libraries are stored publicly on github.com1. This allows everyone easy access to the latest releases and a central location for everyone to access the libraries, documentation, and also provide feedback to the Special Projects Team (SPT). The libraries can be added to a development PC by directly downloading the zip file or by using a Software Repository Management tool. While the zip file might be easier for a one time download, using a repo cloning tool is more effective for long term use.
Option 1 (Download the zip file):
This method is only recommended for those who wish to explore the libraries and do some simple and temporary testing. For continued use of the libraries Option 2 is the preferred method.
Clone the repo by downloading a zip, by simply clicking the green button that says ‘<> Code’, and at the bottom of the menu that appears select ‘Download ZIP’. Once the download is complete, extract the zip file to the location of your choosing. Where you extract it to doesn’t matter, and the files can be deleted at the end of the process. Each library can then be installed as instructed below.
Option 2 (Clone the Repo):
Using a Repo management tool The biggest advantage of using a Repo management tool is the ability to easily update your local repo and have new versions readily available without having to repeat the install process. Starting from the same GitHub page as before click on the green button that says ‘<> Code’, but this time click the ‘Copy url to clipboard’ button to the right of the HTTPS url. You can then use this within your cloning tool to make a local copy of the repo (More details are covered in the section on ’Other Software Tools’). Once you have a local copy of the repo, your cloning tool can be used to pull updates from the server. This will include not only new versions of existing libraries, but also new libraries added to the repo. Each library can then be installed as instructed below.
Installing the libraries
Open TwinCAT XAE and from the PLC menu select Library Repository. Set the ‘Location’ drop down list to ‘System’ and click the ‘Install’ button. Locate the extracted files and install them one at a time, multiple versions of the same library can also be installed this way, and any time a new version is available the entire zip file will have to be downloaded again and the install process repeated for the new version of the library. The first library will appear below the Miscellaneous tree item. After TwinCAT XAE is closed and reopened, a new tree item for SPT will appear in the Library Repository.
Using the Libraries in a project
Once the libraries have been installed, they can be added to the project in the same way as any other library. Either double click on the ‘References’ tree item and select ‘Add library’ or right-click on the ‘References’ tree item and select ‘Add library’. Within the ‘Add Library’ window navigate to the SPT Base Type library and double click to add it to the project. When a library is added, the default setting is to always use the newest version. Represented by the * in the Library Manager.
Pinned Versions
When starting out the option to use the latest version is recommended, but at some point, it might be optimal to pin your library versions (compliance, tracking, etc.). By selecting a library under the References tree item in the Solution Explorer and then viewing its Properties window, you can select a specific version of a library in order to pin your project to that version.
Placeholders
Some libraries make use of other libraries and therefore hold a reference to them, and to the version of the library. By default, the reference to the other libraries will always be set to ‘Newest Version’, but it could be that a change to a library can break a library that is dependent on it. Or again for compliance, testing, etc. library dependencies might need to be pinned to a version. While good programming practices should prevent dependency errors it can still happen. For this reason, we can choose the specific version of dependency. Within the ‘Library Manager’ if you expand a library and one of its dependencies is set to the newest version *. You can use the 'Placeholders' window to select specific dependency versions. Be aware that when this dependency version is set, it will also set the version for the used library. For example, if you add the SPT Base Types library to your project, it has a dependency on the SPT Event Logger library. If you use the Placeholder to set the version of the SPT Event Logger library and then later add the SPT Event Logger library to your project, it will also be pinned to that same version, and it is not possible to set them to different versions. The other situation where this becomes important is when you open a project that uses a pinned version of a library and you do not have that version available on your system. Your options are to either obtain that version and install it or change the dependency to a version you have (but this can create other compatibility problems).
Install Project Library
If a full project is provided to you and it contains libraries that you have not previously installed, then from the PLC Project tree item in the Solution Explorer it is possible to install these libraries. It is important to note that the libraries must be present in the project folder that was provided and not just a reference to them. For example, in the demo projects on our GitHub the .gitignore file is configured to ignore the library files; therefore, they are not included within that repository. This means that when you clone the repo if you have not previously installed the SPT libraries you will not be able to compile the project, and if you try to Install Project Libraries it will not be able to because the libraries do not exist within the project folder. To resolve this issue you must separately download and install the SPT libraries.
-
https://github.com/Beckhoff-USA-Community/SPT-Libraries ↩