【ARM+Codesys Case Study】Raspberry Pi + Codesys SoftPLC Solution Applied to Filling and Capping Machines in the Packaging Industry
ARM series supports: Allwinner T3, RK3568, Raspberry Pi
Machine Model Definition: Dual-Station Capping Machine
Capping machines are primarily suitable for capping (screwing/rolling) various materials and cap specifications. Applicable to screw caps, anti-theft caps, tamper-evident caps, press-on caps, etc. Pressure can be easily adjusted, and the cap pickup position can be set according to the cap size. The structure is compact and reasonable, allowing for easy integration with other equipment to form a production line. Machine advantages: Linear design, facilitating easy and aesthetically pleasing integration into a production line.
Control Process and Key Points

Key Control Points:
-
The equipment operates as part of a production line, requiring precise synchronized motion. Electronic cams are used to achieve synchronized speed and ensure capping synchronization.
-
The equipment has dual stations. The first station (the second machine in the production line) performs capping for odd-numbered bottles detected by the optical sensor, and the second station handles even-numbered bottles. In the program, the number of bottles detected by the optical sensor is divided by 2, and actions are triggered based on whether the remainder is 0 or 1.
-
The belt speed and capping torque require tuning. In the program, the conveyor belt frequency is acquired via a high-speed counting module and calculated through conversion. The conveyor belt's speed in meters per second is calculated as (conveyor belt circumference * conveyor belt frequency) / 1000.
-
Both stations have corresponding position buttons on the screen for convenient operator positioning. Horizontal waiting positions and support waiting positions can be set on the screen, facilitating operation during automatic running. The screen also features clear alarm and reset buttons.
Heshin Control Solution
Control System: CTH300 series controller developed based on CODESYS + DIT16 + DQT16 + HSC + A4N servo
The main controller uses an EtherCAT bus to connect 7 high-performance A4N servo drives.
Control System Configuration Diagram

On-site Photos



Control System Advantages
1 CTH300 series medium to large-scale PLCs developed based on CODESYS offer large program and data memory, strong expandability, and fast processor scan speeds.
2 CODESYS integrates mainstream industrial bus protocol stacks. This solution uses a high-speed EtherCAT bus to control the servo system, resulting in simplified wiring, high control precision, fast speed, and real-time response.
3 The CODESYS software allows for effective viewing and tracking of variable trend curves, facilitating adjustment.
4 CODESYS integrates complex motion control functions: Supports electronic cams, allowing custom cam curves and offering rich built-in configuration options for freely adding/removing cam followers and trigger types; Supports CNC functions, compliant with the DIN 66025 G-code standard, utilizing forward and inverse kinematic transformation algorithms and path preprocessing function blocks for various mechanisms; Supports robot programming, including extensive kinematic transformation libraries to support the development of industrial robots with different kinematics, such as Delta robots, SCARA robots, and gantry robots; Supports virtual axes, allowing project testing using virtual axes linked to real axes. The use of electronic cams on the capping machine allows for better control of the process.
CODESYS Motion Control Advantages
CODESYS unifies motion control and logic control, integrating them into the IEC61131-3 standard CODESYS programming system and CODESYS real-time runtime system, forming the CODESYS SoftMotion (CNC) toolkit. From single-axis motion to complex CNC control and robotic applications, all can be programmed using CODESYS SoftMotion (CNC).
Unlike traditional motion control solutions, CODESYS SoftMotion (CNC) provides a toolkit directly integrated into the CODESYS programming environment to implement all motion control functions. The CODESYS SoftMotion (CNC) toolkit is based on the international standard IEC 61131-3 programming language, allowing users to develop the most complex motion control applications.
CODESYS SoftMotion Features
(1) Motion control programming is independent of the bus and drives.
(2) Can be used with drives for numerous standard motion controllers, such as CiA DSP 402 controllers, stepper motors, frequency inverters, virtual axes, etc.
(3) Bus and drives can be configured directly within the CODESYS programming environment.
(4) Provides a POU library containing all motion control function blocks, enabling fast and efficient development of simple motion programs.
(5) Supports designing electronic cams in the integrated editor.
(6) Supports the integrated DIN 66025 editor (with G-code support) for planning and editing complex movements.
(7) Develop multi-axis robot controllers by using PLCopen Motion Part 4 and the axis group editor.
(8) Rich set of library functions, including geometric data processing (path preprocessing), spline curve calculation, CNC tool position correction, etc.
(9) Includes extensive exchange libraries (for backup and data exchange) to support the development of industrial robots with different kinematics, such as Delta robots, SCARA robots, portal robots, and gantry robots.
(10) Supports online CAM editor and CNC editor, allowing machine operators to graphically create and edit CNC programs.