© Xin Hang Cheng
© Xin Hang Cheng

Jul 4, 2022

TwinCAT Vision optimizes soft capsule inspection

Quality control reaches new level of integration

Xin Hang Cheng has been developing high-end pharmaceutical processing machines for over 30 years. The latest generation of soft capsule inspection machines uses PC-based control and TwinCAT 3 from Beckhoff to integrate PLC, motion control, machine vision and HMI functions into a unified control platform with a simplified architecture.

While China has a rich tradition to produce medicine using herbs and other natural ingredients by hand, Beijing Xin Hang Cheng Technology Development Co., Ltd (Xin Hang Cheng) has been building a bridge between tradition and modernity by developing machines to produce high-quality pharmaceutical products. With its innovative technology and solutions, the company based in Langfang City in the Chinese Hebei Province has a strong competitive edge in the field of machines for softgel encapsulation.

Softgel capsules are filled with liquid ingredients in different procedures, but always in one work step, to safely enclose their valuable contents such as vitamin solutions in a protective gelatine shell. Ease of use and ingestion make soft capsules popular in the pharmaceutical, cosmetics and food supplements markets. Final inspection ensures the attractive appearance of the capsules produced in different colors and shapes, and the sorting out of products with blemishes such as air inclusions or foreign particles on the surface.

Highly integrated soft capsule inspection machine implemented with TwinCAT Vision and TwinCAT HMI.
Highly integrated soft capsule inspection machine implemented with TwinCAT Vision and TwinCAT HMI.

Xin Hang Cheng say that they developed the first fully automatic high-speed softgel encapsulation machine and the first highly efficient automatic conveyor-type soft capsule dryer in China. The company has always followed the R&D philosophy of "Innovation is Unlimited", focusing on the application of new and innovative technologies. Since 2015, they have relied on PC-based control technology and TwinCAT 3 automation software from Beckhoff as their main control platform. In 2020, Xin Hang Cheng was the first company in China’s soft capsule inspection industry to apply TwinCAT Vision and introduce a highly integrated control solution on that basis.

This latest generation of these inspection machines uses the Beckhoff software platform to seamlessly integrate all necessary functions with TwinCAT HMI, TwinCAT PLC and TwinCAT Vision into a unified environment, greatly simplifying the control system architecture by increasing the level of integration. With its simple structure, powerful control intelligence, speed and accuracy, the control solution attracted widespread attention when it was presented to trade experts at the China National Pharmaceutical Machinery Exposition 2021.

TwinCAT integrates machine vision functions

TwinCAT Vision integrates all machine vision functions directly into the runtime. Programming image processing and logic control functions on the same engineering platform ensures that the task cycle corresponds to the fixed refresh times of the image processing code. Moreover, the selected hardware platform meets the resulting control cycle time requirements. In this case, a CX2072 Embedded PC equipped with Intel® Xeon® CPU (12 cores) and a separate graphics card, provides ample computing power to implement the data-intensive image processing application along with all other functions.

As the machine vision and the PLC program both run on the same software platform, no additional time expenditure for communication between the two applications is required. The seamless interaction of all tasks within the real-time environment of the TwinCAT runtime makes sure that there are no delays between the image processing and sorting functions of the machine, and the resulting system throughput is very high.

A powerful CX2072 Embedded PC is used as the all-in-one control platform for the high-speed soft capsule inspection machine developed by Xin Hang Cheng.
A powerful CX2072 Embedded PC is used as the all-in-one control platform for the high-speed soft capsule inspection machine developed by Xin Hang Cheng.

The machine vision functions of the soft capsule inspection machines involve the detection and determination of defects such as abnormal colors, abnormal shapes, black spots as well as bubbles in soft capsule products. The TwinCAT Vision library provides ready-made function blocks for image pre-processing, color differentiation, appearance and contour analysis as well as spot detection, which are well suited to the requirements of a soft capsule inspection machine. The open templates also enable the development of individual image processing functions for customer applications.

One HMI for machine vision and PLC

Traditionally, machine vision has a control system that is independent of the PLC. And for ease of operation, machine vision systems usually have their own operator interface. Consequently, two separate HMIs would be necessary to operate the machine vision system and the PLC controller at the same time, which inevitably causes operational inconveniences.

TwinCAT HMI, on the other hand, offers the possibility to combine the visualization of the integrated PLC and image processing functions into just one user interface. This further simplifies the engineering process. It also reduces the hardware costs by eliminating the need to have two separate control platforms and two display devices for the machine. In this case, a CP2919 multi-touch Control Panel from Beckhoff provides high operating comfort.


The image processing solution TwinCAT Vision distinguishes itself from conventional machine vision solutions in that it can be perfectly combined with PLC and HMI functions. The integrated design greatly simplifies the system architecture and provides users with a more flexible and easy-to-operate solution. The vision code running in the TwinCAT runtime can interact with the PLC directly without communication delays, which ensures efficient use of the controller's resources and improves the cycle times. TwinCAT Vision handles general vision requirements via a programming language familiar to the common control engineer, which greatly reduces the effort of developing machine vision functions and removes the need for an image processing specialist to do the programming.

The combined savings in terms of hardware costs and simplified engineering make it possible for Xin Hang Cheng to offer high-end and high-speed inspection solutions to the manufacturers in the pharmaceutical markets at competitive prices.

With the ongoing development of PC technology enabling further performance improvements of the PC-based control technology from Beckhoff, and the addition of new vision functions, TwinCAT Vision is bound to be used more and more in a variety of machine vision application scenarios, believes Xin Hang Cheng.

Further information