Twincat Vision Hardware Config
Twincat Vision is an integrated image processing solution of Beckhoff. Instead of handling vision sensors outside of the runtime environment of the PLC as a fieldbus slave, with Twincat vision it is possible to handle all vision sensors with real-time tracing, which is a big advantage. What can be a disadvantage ? Of course the source you need to spend to acquire these images and process on them. Images are tons of data and in this case PLC needs to hold this data in memory until the processing ends. Therefore you will need to spare too much source from your PLC for image processing. Without using Twincat vision, the vision sensor would acquire the image, process it with it’s own memory and processor and sends only the necessary data(such as results, user defined data, status etc.) which can be achieved with max. 100 bytes of data.
Twincat Vision is a system component just like the other Twincat engineering environment based on visual studio. So how this system works and what does it use ? Its better to understand how the whole system works before moving on to hardware configuration.
- Industrial cameras can be connected via the GigE Vision interface and assistants are available for configuration, calibration and simulation of the cameras. GigE Vision is an interface standard for industrial image processing, which uses gigabit Ethernet communication protocol. And assistants are like a setup wizard for easier configuration,calibration and etc. for cameras connected via GigE vision, it will be explained later.
- Images can be loaded to PLC runtime via a File Source elements, instead of getting images from camera directly on run time. This may be useful for fine-tuning or development of camera application with tons of images that is saved on a external storage.
- It is needed to make the configuration of cores and router memory for Twincat Vision via Twincat real-time settings.
- Vision Job Pool can be used to execute some algorithms in parallel on a different core.
There is a library for Twincat Vision , which provides a large number of algorithms for image processing , function blocks and functions for communication with file system and interface of the cameras. Programming of the application will not be covered here. More information can be found at API reference.
- ADS Image Watch: Its a tool that provides the possibility to monitor the captured image in a development environment. Normally PLC
receives images with a different interface to process it, ADS Image Watch receives the image with a displayable interface. However its
not possible to do image processing on this format.
- ADS Return Codes: Each Twincat Function provide information about their execution status via ADS Return Codes. These can be used for debugging.
- In addition, all debugging tools (breakpoints etc. ) can be also used for image processing programming.
GigE Vision Driver
GigE Vision Driver is the driver of Twincat to communicate with industrial cameras based on GigE Vision standards.
Twincat Vision Service
The Twincat Vision Service is a centralized, ADS-based communication interface between the Twincat runtime and external Vision components. If some functionalities are needed that requires Twincat Vision to communicate with components outside of the real-time environment at runtime(i.e File Source Control loads image from the file system), this communication interface needs to be used.
|TwinCAT 3 Platform-Level||Minimum P50 Performance Plus, e.g. Intel 4-core Atom CPU|
|Network adapter||TwinCAT real-time Ethernet-compatible Gigabit network cards (for connecting GigE Vision cameras)
Note: At least one network port should be available exclusively for cameras. It is recommended to use a separate network port for each camera.
|Minimum 4 GB recommended for pure runtime systems
Minimum 8 GB recommended for development systems
Minimum 8 GB recommended for the use of record/playback streams on runtime systems
|Hard disk||SSD hard disks with high reading/writing rates are recommended, especially if a lot of data is to be exchanged between PLC and hard disk.|
|Interface||Must support GigE Vision (marked with GigE Vision logo).
Note:The TwinCAT GigE Vision Connector is certified according to the GigE Vision Standard
version 2.0. However, this does not mean that all camera or GigE Vision features of the version are supported.
|Operating system||Windows 7 or 10 (64-bit only!)|
|Supported Visual Studio versions||2017 (Community, Professional)
2019 (Community, Professional)
TwinCAT XAE Shell (TcXaeShell)
|TwinCAT||Minimum version 3.1.4024.17|
|.NET Framework||Minimal version 4.6.1 (only for the development environment)|
After a successful installation, we will start with creating a project and do the basic settings like real-time settings.
- Its recommended to use isolated cores for Twincat Vision applications. Its OK to use shared cores for initial testing but as mentioned
at the beginning of the blog image processing requires tons of resource.
- Configure router memory according to application. Note that images requires high router memory but on the other hand this memory you allocated will be subtracted from RAM. Consider checking Estimating required memory size and be sure there is enough memory for rest of the applications.
- Default stack size probably not enough for image processing. It is recommended to increase the stack size 512 Kb minimum.
Create a Vision Device
Now we can set up a vision application. To be able to see the vision tool, we need to unhide it.
Step 1 : Right-click the TwinCAT project in the Solution Explorer > Show Hidden Configurations > Show VISION Configuration.
Step 2 : Now its visible, right click on it and add new application.
Step 3 : Right click on icon with your application name and select add new item. After that we have that windows below. Now we can add either a real camera, or a file source that we can get images from folder.
Step 4 : Select GigE vision camera from step 3 and click OK. A window will open which requires us to choose the ethernet port which the camera is connected.
Select IPStack and click OK.
Step 5 : Click discover devices and select the camera that you want to connect to the vision object and click OK.
Now camera can be seen under the vision application.
Double click on the camera node and following page will open. We can monitor general info and status of camera on “General” section.
It is very important to use the same Twincat Vision version for all TcCOM objects. If you are using a spesific version, check and confirm all of your TcCOM objects are at the same version. To check and update the versions, see the window below.
Ethernet Adapter Settings
1. Open the IP-Stack of the RT-Ethernet adapter in the I/O configuration.
2. Select the Parameter (Init) tab and display further parameters by clicking the Plus (+) in front of TcIoIpSettings.
3. Define the parameters .IpAddress and .SubnetMask.
4. Set the parameter .ManualSettings to TRUE.
If you want to add multiple cameras in one port ( its not recommended by Beckhoff but I think it will be needed) set these parameters below. These should be used camera quantity*2 (i.e if you have 3 cameras on port these will be 6).
Make sure that “Promiscuous Mode” for vision ports is deactivated. It may lead problems when communicating with GigE Vision devices.
Vision Node Settings
Twincat Vision Service is a bridge between non real-time components and real-time components. For example if you want to save an image that you have in real-time at runtime on a non real-time disk, Twincat Vision Service implements an ADS server to access both and enables communication.
Do not forget to make the installation for Twincat Vision Service.
Create PLC Project
Now let’s create a standard PLC project and add twincat vision libraries.
Click Add Library
Click Tc3_Vision and OK.
Then instantiate a FB with a library that we just installed.
We need to connect that FB, which we will use to manage the camera, to the image provider. To do that build the project, go to PLC instance tab and click Symbol Initialization section.
Here we can see our camera name that we instantiated. Click on the “Value” drop-down and link the symbol with the camera that we created.
Now activate the configuration.
Now we have a camera that is connected to our PLC and linked to Twincat, can be used by Twincat Vision Libraries.