Samples
In this chapter you will find samples for the application of many functions and function blocks in the PLC, as well as wizards and camera configuration. Before you start looking at the PLC samples, please have a look at First steps.
The samples are independent of each other. Each sample has a focus under which it is grouped below. Samples that focus on a function or a function block are listed based on the API structure.
Download
The samples can be obtained from a repository on GitHub: https://github.com/Beckhoff/TF7xxx_Samples. There you have the option to clone the repository or download a ZIP file containing all samples.
Sample images must be downloaded separately The GitHub repository contains only the TwinCAT projects with the corresponding code. The image data "TF7xxx_Sample_Images.zip" must be downloaded separately from the Beckhoff website. The link and more information can also be found in the Readme file in the GitHub repository. |
Project resources
Each sample is provided in a separate folder, according to the outline order and with the name of the chapter headings. In it there is a TwinCAT project with the corresponding PLC code.
The separate zip folder containing the sample images, for example, can be unzipped to the Images folder within the repository. The folder names as well as the structure in which the sample images are stored is identical to the project structure. Therefore, the assignment of the images is simply done via the path with the same folder name.
Pay attention to short paths to the repository or to the TwinCAT projects, for example Due to the possible limitation of the path length in the operating system to 255 characters, problems may occur when executing TwinCAT projects if the folder paths are too long. Since the folder structure with the chapter headings is already quite long for the sake of comprehensibility, a short path should be selected for the complete repository or for individual TwinCAT projects, e.g. C:\TF7xxx_Samples\. |
Before you execute a project, please adjust the system configuration according to your target system, with particular attention to configuration of the cores, the router memory and the PLC cycle time. Furthermore, check the version of the TcCOM objects of camera or file source as well as the PLC library as described in the Version overview and adjust the version if necessary.
In the GitHub repository you can find a PowerShell script (SetTcCOMModuleVersion.ps1) which adjusts the version in all projects of the PLC folder. To do this, run the script, e.g. via the PowerShell console, specifying the desired version as follows:
PS C:\TF7xxx_Samples> .\SetTcCOMModuleVersion.ps1 4.0.4.8
If images or streams are needed, integrate them via the File Source Control or the Record/Playback tab of the camera object.