Creating a TwinCAT Vision Project (TF7000) step-by-step

Feb., 2022

TwinCAT Vision frontcover

TwinCAT Vision is an integrated image processing solution, inside Beckhoff’s TwinCAT 3.

Using the same platform (TwinCAT) and hardware (IPC-based PLC), it is possible to perform motion control, robotics, high-end measurement technology, IoT, and HMI. A strategy aligned with Industry 4.0, quality optimization, and track-and-trace.

TwinCAT Vision has the benefit of being synchronized in the runtime system precisely, Vision tasks are executed in real-time.


 Starting a TC Vision project – complete guide

Here is a step-by-step tutorial about how to emulate a camera in TwinCAT Vision (TF7000).
This example is made with a file source, instead of using a function block to read images from the disk.

  1. Install TwinCAT Vision.
  2. Create a new TwinCAT 3 project, version 4024.xx or higher. Currently, I have 4024.12.
  3. Enable the Vision node, and you hide the other we won’t use, like motion, safety, C++, and analytics.
  4. Add a new vision item by right-clicking over the vision node and selecting “add new item”, then give it a name, for example: “BasicDemo”.
  5. To add a vision device (a camera, or a file source), right-click over the application created in the previous step (BasicDemo), click on “Add new item” and select “FileSource”.
  6. Double-click on the file source we have created, move to the “File Source Control” tab.
  1. Before continuing, be sure that TwinCAT is in config mode, the blue icon.
  2. To read files from disk, emulating a camera, click on “Read From target”, then on “Add Files” and select the files from disk.
  3. Set the cycle time, this will emulate the framerate of a real camera device, which means every elapsed cycle time a new image will be loaded.
  4. It is highly recommended to increase the router memory. This is done in the TwinCAT project under SYSTEM > Real-Time > Settings > Router Memory (Mbyte). Adjust it to 256 Mb.
  5. Create a vision task: It is mandatory to work with images and recommended to run on an isolated core. This is done by right-clicking on Tasks in SYSTEM >Tasks and selecting “Add new item”. Select the option “TwinCAT Task with image” and name it “VisionTask”.
  1. Isolate one core for the regular automation tasks and another one for the vision tasks. This is done by double-clicking in the TwinCAT project under SYSTEM > Real-Time. This step may not be mandatory for tests purposes running on local machines, but if you using a virtual machine you have to do it.
  2. Activate configuration and insert trial licenses if required.
  3. Add a new PLC standard project, called “MainPLC”.
  4. Add the TwinCAT Vision library to that PLC, right-click on References and select Add library. Select the Tc3_Vision.
  5. Add new POU, called “MainVision”
  6. Add the previous vision task to the PLC project. Right-click on “MainPLC Project”, then Add>Referenced Task.
  7. Select vision task and click open.
  8. The most simple way to add the MainVision (POU) to the vision task is simply to drag and drop the MainVision (POU) to the vision task.
  1. In the “MainVision” (POU) we add the following basic variables and basic state machine to acquire images.
					hr          : HResult;
fbControl   : FB_VN_SimpleCameraControl;
eState      : ETcVnCameraState;
ipImage     : ITcVnImage;
ipDisplayImage : ITcVnDisplayableImage;

The state machine code:

					eState := fbControl.GetState();

CASE eState OF
		hr := fbControl.StartAcquisition();
		hr := fbControl.GetCurrentImage(ipImage);
		IF SUCCEEDED(hr) AND ipImage <> 0 THEN
			// Place to call vision algorithms
			hr := F_VN_TransformIntoDisplayableImage (ipImage, ipDisplayImage, hr);

  1. Now build the project!
  2. The instance fbCamera of the function block FB_VN_SimpleCameraControl from the PLC program must be linked with the image provider of the Vision device. Double-click the instance of the PLC project and open the Symbol Initialization tab.
  3. Activate configuration and go to run mode.
  4. Add a ADS image watch window to see results.
    ADS image window
  5. Login and run the program.
  6. If no images are shown in the ADS image window, please reload image symbols and select the variable that points to the output image.

Sample images are from the Azores, a Portuguese archipelago in the Atlantic Ocean, between Portugal mainland and New York City (USA).

This was a begginer’s guide about how to configure a TwinCAT Vision project.

Additional hints about TC Vision

The complete information about TC Vision methods to build your own industrial vision system or your machine vision equipment is accessible through the Beckhoff Information System (aka Infosys).

The above link will guide you to sample code provided directly from Beckhoff. It is useful to know how to calibrate a vision system in TwinCAT Vision.

The documentation has also a guide on how to integrate the vision package on a HMI.



Share on linkedin
Share on facebook
Share on twitter
Share on telegram
Share on whatsapp
Share on email

Fique a par das novidades, subscreva:

Post recentes:

Startup TwinCAT Vision Project (TF7000)

Creating a TwinCAT Vision Project (TF7000) step-by-step Rúben Oliveira Feb., 2022 TwinCAT Vision is an integrated image processing solution, inside Beckhoff’s TwinCAT 3. Using the