An EtherCAT master system based on Qt and a multi-task scheduling method
By using a Qt-based EtherCAT master station system, combined with multi-task scheduling management and event-driven, asynchronous operation, the complexity of development and cumbersome task scheduling of traditional EtherCAT master station systems are solved. This enables the development of efficient and stable industrial control systems and user interfaces, suitable for applications such as robot control and automated production lines.
Patent Information
- Application Number
- CN202411568604.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-05
- Publication Date
- 2026-01-30
- Estimated Expiration
- 2044-11-05
AI Technical Summary
Traditional EtherCAT master station systems are complex to develop, have cumbersome task scheduling, and are inconvenient to develop interfaces, resulting in high development and maintenance costs and making it difficult to meet the requirements of modern industrial control systems for real-time performance, stability, and user experience.
An EtherCAT master station system based on Qt is adopted. Combining the cross-platform characteristics and rich graphical interface library of the Qt framework, an efficient and easy-to-maintain master station system is built. Through the multi-task scheduling and management module, the EtherCAT master station protocol stack function module and the human-computer interaction module, a unified development platform is realized. The stability of tasks is ensured by combining event-driven, asynchronous operation and queue.
It improves the development efficiency and system performance of the EtherCAT master station system, meets the requirements of real-time performance, stability and user experience, achieves cross-platform support, and is suitable for application systems with high real-time requirements.
Smart Images

Figure CN119449893B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the technical field of program control systems, and more specifically, relates to an EtherCAT master station system based on Qt and a multi-task scheduling method. Background Technology
[0002] In modern industrial automation systems, achieving efficient, stable, and real-time control is crucial. EtherCAT (Ethernet for Control Automation Technology), as a high-performance real-time Ethernet communication protocol, is widely used in industrial automation control systems, such as robot control, automated production lines, and test and measurement equipment, due to its low latency, high synchronization performance, and high-speed data transmission capabilities.
[0003] Meanwhile, with the increasing demands for Human-Computer Interfaces (HMIs) and user experiences, developing efficient and user-friendly interfaces has become particularly important. Qt is a widely used cross-platform C++ application development framework, widely used for interface development in desktop applications, embedded systems, and mobile devices due to its rich graphical interface library and flexible development tools.
[0004] Traditional EtherCAT master system development typically involves a combination of various technologies and tools, such as a real-time operating system (RTOS) and a dedicated hardware platform, to achieve multi-task scheduling and control. However, this development approach has several problems:
[0005] 1. High system complexity: It requires the comprehensive use of multiple development environments and tools, resulting in a complex system architecture and high development and maintenance costs.
[0006] 2. Cumbersome task scheduling: Ensuring real-time performance while effectively scheduling multiple tasks and managing resources is a major challenge.
[0007] 3. Inconvenient interface development: In traditional real-time system development, interface development is often a separate step, lacking close integration with the control system, resulting in low development efficiency.
[0008] Chinese patent document CN112486112A discloses an EtherCAT master station control system and its control method. The method includes: a master station controller of the EtherCAT master station control system, comprising: an EtherCAT master control system and an industrial control subsystem; the EtherCAT master control system is used to send control data from a slave drive controller to the industrial control subsystem; the industrial control subsystem is used to receive the control data sent by the EtherCAT master control system and buffer it, and then send the buffered control data to the slave drive controller; wherein the slave drive controller receives the control data sent by the industrial control subsystem and parses the corresponding control signals according to the control data to control the operation of the drive device module.
[0009] In view of this, the present invention proposes an EtherCAT master station system based on Qt and a multi-task scheduling method. By utilizing the cross-platform characteristics and rich graphical interface library of the Qt framework, combined with the real-time performance of the EtherCAT protocol, an efficient, flexible and easy-to-maintain master station system is constructed. Summary of the Invention
[0010] The present invention aims to overcome at least one of the defects of the prior art and provide an EtherCAT master station system based on Qt;
[0011] This invention also discloses a multi-task scheduling method for an EtherCAT master system based on Qt, in order to improve the development efficiency and system performance of the EtherCAT master system and meet the requirements of modern industrial control systems for real-time performance, stability and user experience.
[0012] The detailed technical solution of this invention is as follows:
[0013] An EtherCAT master station system based on Qt, the system includes a human-computer interaction module, a task scheduling and management module, an EtherCAT master station protocol stack function module, an XML slave station configuration file parsing module, a network port communication module, and a serial port communication module;
[0014] The human-computer interaction module includes: a real-time service display and control module, an EtherCAT communication data online debugging module, a service basic configuration and modular debugging module, and a system authentication module;
[0015] The task scheduling management module refers to the module in the EtherCAT master station system that is responsible for the management of the entire business process, the processing of complex data, and task scheduling, including: the system's work status management module, the complex business data processing module, and the task scheduling module;
[0016] The EtherCAT master protocol stack functional modules include, but are not limited to: the real-time data processing module of the controlled object, the business control logic management module of the controlled slave station, the EtherCAT master initialization process module, and the business processing interface implementation module of the controlled object.
[0017] The XML slave configuration file parsing module is used to parse the XML format slave configuration file and use the parsed data in the EtherCAT communication data online debugging module in the above-mentioned human-computer interaction module;
[0018] The network port communication module is used to expand the network port communication function according to business needs. The system defaults to TCP long connection communication, and free data protocols can be added for data communication according to business needs.
[0019] The serial communication module is used to expand the serial communication function according to business needs. The system defaults to Modbus protocol communication, and other communication protocols, such as 86 protocol, can be added according to business needs.
[0020] According to a preferred embodiment of the present invention, the real-time display and control module for services includes, but is not limited to, real-time display data required by the services and real-time control functions required by the services.
[0021] The EtherCAT communication data online debugging module includes, but is not limited to: PDO data read / write and SDO data read / write;
[0022] The business basic configuration and modular debugging module includes a basic configuration part and a modular debugging part;
[0023] The system authentication module is used to restrict user access permissions; the final business user only has access to the real-time business display and control module, and other human-computer interaction interfaces are disabled; only business personnel with administrator privileges, such as system administrators or business maintenance personnel, are qualified to use the real-time business display and control module, the EtherCAT communication data online debugging module, and the business basic configuration and modular debugging module simultaneously.
[0024] According to a preferred embodiment of the present invention, the system's working status management module refers to recording the working status of each business and sending the real-time working status to the human-computer interaction module by sending signals; the complex business data processing module refers to calculating the data stored in the business process that participates in the calculation, and the data participating in the calculation includes, but is not limited to: the configuration data in the business basic configuration and modular debugging module, and the PDO data in the real-time data processing module of the controlled object; the task scheduling module refers to scheduling and executing the business process.
[0025] According to a preferred embodiment of the present invention, the master station protocol stack is implemented by porting the open-source SOEM master station protocol stack source code.
[0026] According to a preferred embodiment of the present invention, the real-time data processing module of the controlled object refers to reading and storing PDO data in real time in EtherCAT communication, and formatting or performing complex calculations on the data according to the usage requirements of the controlled object. For example, if the data that needs to be called in real time in the business task is data based on complex calculations of PDO data, it is transmitted to the task scheduling management module for data processing through the signal and slot mechanism in Qt, and then sent back for calling.
[0027] The business control logic management of the controlled slave station refers to the process in the EtherCAT master station system where the master station periodically sends and receives PDO data and performs business logic processing on the data; the periodic sending and receiving function is implemented using a precision timer, and the business logic processing and control are performed during the precision timer interrupt;
[0028] The EtherCAT master station initialization process includes: network configuration, data storage area mapping, clock initialization, and EtherCAT state switching.
[0029] The implementation of the business processing interface of the controlled object refers to the implementation of the business logic processing function of the controlled object.
[0030] According to a preferred embodiment of the present invention, the network configuration refers to connecting to the EtherCAT network port; the data storage area mapping refers to mapping PDO data to the local storage area; the clock initialization refers to selecting and initializing the appropriate EtherCAT clock working mode according to the actual application requirements; the EtherCAT clock working modes include free mode, SM synchronization mode, and DC synchronization mode; the free mode means that each slave station has a different timing period and executes its own program; the SM synchronization mode means that each slave station task is triggered to execute when it receives a data frame from the master station; the DC synchronization mode is a high-precision time synchronization mode.
[0031] A multi-task scheduling method for an EtherCAT master station system based on Qt is provided. The method includes a method for multi-threaded task partitioning and priority setting, and a method for ensuring the stable operation of the highest priority task.
[0032] According to a preferred embodiment of the present invention, the method for multi-threaded task partitioning and priority setting includes the following steps:
[0033] S1. Based on business requirements, allocate multiple tasks to multiple threads. The thread allocation rules are as follows: thread1 is the real-time control task; thread2 is the business logic management task; and thread3 is the human-computer interaction task.
[0034] S2. Assign thread ownership to the tasks in each module: thread1 includes tasks in the EtherCAT master station protocol stack function module; thread2 includes tasks in the task scheduling management module, TCP network communication module, and Modbus serial communication module; thread3 includes tasks in the human-computer interaction module.
[0035] S3. Based on the actual task priorities, prioritize the three threads (thread1, thread2, and thread3): The process data communication task, being high-frequency real-time communication, is set to the highest priority. This process data communication task is implemented within a 1ms precision timer interrupt. Based on Qt language rules, thread1 has the highest priority requirement and is set to TimeCriticalPriority, using a high-frequency timer interrupt for wake-up execution. Since thread3 is part of the human-computer interaction module, it defaults to NormalPriority based on Qt language rules. Because the business logic management-related tasks of thread2 have a higher priority than the human-computer interaction tasks of thread3, but lower than the EtherCAT real-time control tasks of thread1, thread2 is set to HighestPriority or HighPriority. In summary: thread1 - TimeCriticalPriority > thread2 - HighestPriority / HighPriority > thread3 - NormalPriority.
[0036] According to a preferred embodiment of the present invention, the method for ensuring the stable operation of the highest priority task includes the following:
[0037] S1. Event-driven approach is used as the trigger condition for business processes. Specifically, the business process managed by thread2 uses a signal and slot mechanism to interact with the high-priority thread1 and control the smooth execution of the entire business process. The human-computer interaction task of thread3, the lowest priority thread, also uses a signal and slot mechanism to interact with thread2. If data in thread1 wants to be passed to thread3, it must be forwarded through thread2.
[0038] S2. Asynchronous operation is used to process complex data. The asynchronous operation means that all complex operations involved in the high-priority thread1 are transferred to the lower-priority thread2 for execution and data storage. Thread1 only reads and uses the data processed by thread2 without performing any operations. This ensures high real-time communication processing of thread1 and avoids the program crashing due to simultaneous data modification.
[0039] S3. Use a queue to manage tasks to be executed. When the business process is executed in the high-frequency timer interrupt of thread1, put a series of operations similar to task b into the queue and set the execution conditions. Then, place the queue in the high-frequency timer interrupt and trigger the execution of task a in the order of timing conditions, so that task a and task b are executed in the order of timing.
[0040] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0041] (1) Compared with the traditional EtherCAT master station system development method, the present invention has the following technical advantages: a unified development platform based on Qt, an efficient multi-task scheduling method, an integrated graphical user interface, and cross-platform support.
[0042] (2) The application software developed based on Qt has the advantages of cross-platform compatibility and easy portability. For some application systems with low real-time requirements, such as sorting distributed control systems, it can be deployed and used under the Windows operating system. For application systems with high real-time requirements, such as robot control systems and automated production lines, it can be deployed and used under operating systems such as RT-Linux, QNX, VxWorks or Windows Embedded series.
[0043] (3) This invention adopts a combination of event-driven, asynchronous operation and queue to achieve the stability of the highest priority task operation; the event-driven approach uses the signal and slot mechanism to realize task scheduling between threads, thereby avoiding the execution of long-term tasks in the main thread and not interfering with the execution of high-frequency events; the asynchronous operation puts complex calculations in lower-priority threads for processing and storage, and high-priority threads call them, avoiding the crash of the program due to simultaneous modification of data; the use of queues enables multiple tasks that operate on the same variable area at the same time to be executed in the queue in a conditional and sequential manner, avoiding conflicts.
[0044] (4) Taking the express sorting control system as an application example, the EtherCAT master station system described in this invention is deployed on a non-real-time Windows platform. In SM working mode, i.e., the working mode triggered when the slave station receives periodic data frames, experiments have verified that when the master station sends periodic data at 1ms, the time to receive feedback from the slave station is between 1-2ms. Therefore, for distributed applications with slave station task cycles of more than 2ms, the EtherCAT master station system deployed on the Windows platform can be used. That is, if the system is deployed on a real-time operating system, the real-time performance will be even higher. Attached Figure Description
[0045] Figure 1 This is a schematic diagram of the express sorting main station system and functional modules in an embodiment of the present invention;
[0046] Figure 2 This is a schematic diagram of task thread allocation in the express sorting master station system of this invention.
[0047] Figure 3 This is the main human-computer interaction interface of the express sorting master station system in this embodiment of the invention;
[0048] Figure 4 This is the main human-computer interaction interface of the express sorting master station system in this embodiment of the invention;
[0049] Figure 5 This is the human-computer interaction encoder debugging interface of the express sorting main station system in this embodiment of the invention;
[0050] Figure 6 This is the basic human-computer interaction settings interface of the express sorting main station system in this embodiment of the invention;
[0051] Figure 7 This is a line graph of performance test experimental data in an embodiment of the present invention. Detailed Implementation
[0052] The present disclosure will be further described below with reference to the accompanying drawings and embodiments.
[0053] Example 1
[0054] like Figure 1 As shown, this embodiment provides an EtherCAT master system based on Qt, which includes at least:
[0055] M1: Human-computer interaction module; M2: Task scheduling and management module; M3: EtherCAT master station protocol stack function module; M4: XML slave station configuration file parsing module; M5: Network port communication module; M6: Serial port communication module;
[0056] M1: Human-Computer Interaction Module
[0057] The human-computer interaction module includes: a real-time service display and control module, an EtherCAT communication data online debugging module, a service basic configuration and modular debugging module, and a system authentication module;
[0058] The real-time display and control module includes, but is not limited to: real-time display of data required by the business and real-time control functions required by the business; the real-time display of data required by the business includes, but is not limited to: production process data, business process data, error alarm data, and status display; the real-time control functions required by the business include, but are not limited to: EtherCAT master station scanning and connection to slave stations, power-on control, power-off control, network socket connection, and serial port connection.
[0059] The EtherCAT communication data online debugging module includes, but is not limited to: PDO data read / write and SDO data read / write; PDO data read / write refers to the online reading and writing of process data during real-time transmission between the master station and the slave station, such as sensor data, execution status, etc.; SDO data read / write refers to a client / server model communication object between the master station and the slave station, used to achieve low-latency and reliable data transmission, such as configuration parameters, device status information, etc.
[0060] The business basic configuration and modular debugging module includes a basic configuration part and a modular debugging part. The basic configuration refers to the business parameters that need to be configured in the business application, which are mostly data that is saved after power failure. The modular debugging refers to the business functions that need to be tested independently in the business application. This function is usually used to verify and correct whether the configured parameters are appropriate.
[0061] The system authentication module is used to restrict user access permissions. The final business user only has access to the real-time business display and control module, and other human-computer interaction interfaces are disabled. Only business personnel with administrator privileges, such as system administrators or business maintenance personnel, are qualified to use the real-time business display and control module, the EtherCAT communication data online debugging module, and the business basic configuration and modular debugging module at the same time.
[0062] M2: Task Scheduling and Management Module
[0063] The task scheduling and management module refers to the module in the EtherCAT master station system responsible for the management of the entire business process, the processing of complex data, and task scheduling. It includes: system work status management, complex business data processing, and task scheduling. System work status management refers to recording the various work states of the business process and sending real-time work status signals to the aforementioned human-computer interaction interface. Complex business data processing refers to the calculation and storage of data that needs to be calculated in the business process within this module. The data involved in the calculation includes, but is not limited to: configuration data in the business basic configuration and modular debugging module, and PDO data in the real-time data processing module of the controlled object. Task scheduling refers to the scheduling and execution of the business process.
[0064] M3: EtherCAT Master Protocol Stack Functional Module
[0065] The EtherCAT master protocol stack functional module refers to the communication between the EtherCAT master station and slave stations in the EtherCAT master station system through the master station protocol stack. The master station protocol stack is ported and implemented based on the open-source SOEM master station protocol stack source code. The EtherCAT master protocol stack functional module includes, but is not limited to: real-time data processing of the controlled object, business control logic management of the controlled slave station, EtherCAT master station initialization process, and interface implementation of the business processing process of the controlled object.
[0066] The real-time data processing module of the controlled object refers to the module that reads and stores PDO data in real time during EtherCAT communication, and formats or performs complex calculations on the data according to the usage requirements of the controlled object. For example, it can combine stored single-byte data into a meaningful four-byte variable according to the configuration format. For example, if the data that needs to be called in real time in the business task is data that is based on complex calculations of PDO data, it can be transmitted to the task scheduling and management module through the signal and slot mechanism in Qt for data processing, and then sent back for calling.
[0067] The controlled slave station's business control logic management refers to the EtherCAT master station system where the master station periodically sends and receives PDO data and performs business logic processing on the data. The timing interval is usually within 10ms, typically a 1ms clock cycle. The periodic sending and receiving function is implemented using a precision timer, and business logic processing and control are performed during the precision timer interrupt.
[0068] The EtherCAT master station initialization process includes: network configuration, data storage area mapping, clock initialization, and EtherCAT state switching. Network configuration refers to connecting to the EtherCAT network port. Data storage area mapping refers to mapping PDO data to local storage. Clock initialization refers to selecting and initializing the appropriate EtherCAT clock operating mode according to actual application requirements. The EtherCAT clock operating modes include free mode, SM synchronization mode, and DC synchronization mode. Free mode means that each slave station has a different timing period and executes its own program. SM synchronization mode means that each slave station task is triggered to execute when it receives a data frame from the master station. DC synchronization mode is a high-precision time synchronization mode.
[0069] The implementation of the business processing interface of the controlled object refers to the implementation of the business logic processing function of the controlled object, such as the motor turning 90 degrees to the left.
[0070] M4: XML slave configuration file parsing module
[0071] The XML slave configuration file parsing module parses the XML-formatted slave configuration file and uses the parsed data in the EtherCAT communication data online debugging module within the aforementioned human-computer interaction module. The slave configuration file primarily includes manufacturer information and slave description information. The manufacturer information mainly includes the manufacturer name and manufacturer ID. The slave description information configures the basic information of the slave device and related variables for data communication. The basic information of the slave device includes its identifier, name, and interface type. The related variables for data communication include the index, name, and type of the process data.
[0072] M5: Network communication module
[0073] The network port communication module refers to the network port communication function that can be expanded according to business needs. The system defaults to TCP long connection communication, and free data protocols can be added for data communication according to business needs.
[0074] M6: Serial communication module
[0075] The serial communication module refers to the serial communication function that can be expanded according to business needs. The system defaults to Modbus protocol communication, and other communication protocols, such as the 86 protocol, can be added according to business needs.
[0076] Example 2
[0077] This embodiment provides a multi-task scheduling method for an EtherCAT master station system. The method includes at least: a method for multi-threaded task partitioning and priority setting, and a method for ensuring the stable operation of the highest priority task.
[0078] The method for multi-threaded task partitioning and priority setting includes:
[0079] Step 1: Allocate multiple tasks to multiple threads according to business requirements. The thread allocation rules are as follows: thread1 is the real-time control task; thread2 is the business logic management task; thread3 is the human-computer interaction task.
[0080] The second step is to assign threads to the tasks in the business logic. Thread 1 includes the EtherCAT master protocol stack functions mentioned above; thread 2 includes the task scheduling and management module, TCP network communication module, and Modbus serial communication module; thread 3 includes the human-computer interaction module.
[0081] Step 3: Prioritize the three threads according to the actual task priorities. Since the process data communication task in the EtherCAT master system is high-frequency real-time communication, it must be the highest priority task. Furthermore, this task is implemented within a 1ms precision timer interrupt. Based on Qt language rules, thread1 should be set to TimeCriticalPriority and executed using a high-frequency timer interrupt. Since thread3 is a human-computer interaction module, it defaults to NormalPriority based on Qt language rules. Because the business logic management-related tasks of thread2 have a higher priority than the human-computer interaction task of thread3, but lower than the EtherCAT real-time control task of thread1, thread2 should be set to HighestPriority or HighPriority. In summary: thread1 - TimeCriticalPriority >
[0082] thread2-HighestPriority / HighPriority>thread3-NormalPriority;
[0083] The methods for ensuring the stable operation of the highest priority task include,
[0084] Method 1: Using event-driven approach as the trigger condition for business processes. In more detail, the business process managed by thread2 uses a signal and slot mechanism to interact with the high-priority thread1, controlling the smooth execution of the entire business process; while the human-computer interaction task of thread3, which has the lowest priority among the three threads, also uses a signal and slot mechanism to interact with thread2. In this case, if data in thread1 wants to be passed to data in thread3, it must be forwarded through thread2.
[0085] Method 2: Use asynchronous operations to process complex data. The asynchronous operation refers to transferring all complex calculations involved in the high real-time thread thread1 to the lower priority thread2 for execution and data storage. Thread1 only reads and uses the processed data without performing any operations. This ensures the high real-time communication processing of thread1 while avoiding the program crashing due to simultaneous data modification.
[0086] Method 3: Use a queue to manage tasks to be executed. When executing business processes in the high-frequency timer interrupt of thread1, there is a situation where task a is operating on a variable area in the timer interrupt, while another task b, which is not in the timer interrupt, also needs to operate on the same variable area. If task b is operating on the variable area and a timer interrupt suddenly occurs, interrupting task b and executing task a's operation on the same variable area, when task a finishes and returns to task b, task b will fail to execute normally due to the change in the variable area, resulting in an error. The solution to this extreme case is to ensure that task a and task b can be executed in sequence without conflict. This invention proposes to place a series of operations similar to task b in a queue and set execution conditions, and place the queue in the timer interrupt to trigger execution in sequence with task a according to the conditions.
[0087] Example 3
[0088] The following description, in conjunction with Embodiment 3 and the accompanying drawings, details the main station system configuration, task scheduling, and human-computer interaction of the present invention when applied to an express delivery sorting system:
[0089] like Figure 1It is a schematic diagram of the main station system for express sorting and its functional modules. Among them, an EtherCAT main station system for express sorting is deployed on the industrial control computer 2, and 1 DIO slave station, 1 encoder slave station and N motor drive slave stations are mounted. N is determined according to actual needs, and 1 < N < 256. The functional modules connected to the main station system include: an Ethernet communication module and a serial communication module. Among them, the Ethernet module is connected to the industrial control computer 1 and the industrial camera, and is responsible for the function of package photographing and processing. The serial communication module includes serial port 1 and serial port 2. Serial port 1 is connected to the frequency converter to control the operation of the conveyor belt. Serial port 2 is connected to the DC motor to control the operation of the bag pulling section.
[0090] According to the application requirements of the express main station system, the work tasks of the express sorting main station system can be divided into the following aspects:
[0091] S1: Reading the frequency of the frequency converter;
[0092] S2: Reading the speed of the DC motor;
[0093] S3: EtherCAT master timer interrupt task;
[0094] S4: EtherCAT master collecting optoelectronic signals;
[0095] S5: EtherCAT master collecting encoder values;
[0096] S6: The EtherCAT master sets the control bit to make the motor slave station swing;
[0097] S7: The EtherCAT master controls the industrial motor to take pictures;
[0098] S8: After the motor slave station finishes swinging, the EtherCAT master periodically resets the control bit;
[0099] S9: Calculating the speed of the conveyor belt;
[0100] S10: Calculating the position of the package;
[0101] S11: Human-computer interaction;
[0102] Such as Figure 2This is a diagram illustrating the task thread allocation of the express sorting main station system. Tasks S1-S11 can be divided into three threads: thread1, thread2, and thread3. Thread1 has the highest priority, set to TimeCriticalPriority, and is executed using a high-frequency timer interrupt. Thread2 has the next highest priority, set to HighestPriority. Thread3 has the lowest priority, set to NormalPriority by default. During the execution of the express sorting main station system program, tasks are executed in descending order of priority.
[0103] like Figure 3-6 This is a diagram illustrating the human-computer interaction of the express sorting main station system. Figure 3 The main user interface is primarily used by frontline sorting personnel in express delivery, but access is open to all personnel. The main interface includes three control buttons: system online, power on, and power off. Other interfaces display package data, running data, status data, business process data, and alarm data. Figure 4 It is a PDO / SDO debugging interface that allows online debugging of PDO and SDO data of motor drive slaves configured with XML. Figure 5 This is the encoder debugging interface, which allows you to debug the PDO data of the encoder slave station configured with XML online. Figure 6 It is the basic settings interface, which mainly includes the modular function parameter settings and debugging involved in the express sorting system, slave station parameter settings, relevant parameter settings involved in the express sorting scenario, encoder parameter settings, etc. Figure 4 , 5 6. This feature is designed for encrypted use by developers, system maintenance personnel, and equipment integrators. The password login entry is located on the "About" page.
[0104] Example 4
[0105] The following description, in conjunction with Embodiment 4 and the accompanying drawings, details the main station system configuration, task scheduling, and human-computer interaction of the present invention when applied to an express delivery sorting system:
[0106] The express sorting master station system of this invention was deployed on a Windows 11 Pro non-real-time operating system for performance testing. Although the express sorting system is a distributed real-time control system, the synchronization requirements for each slave station are not high. Therefore, EtherCAT was set to work in SM mode, i.e., the working mode triggered when a slave station receives a periodic data frame. The test steps are as follows:
[0107] 1) The communication cycle of the master station system's EtherCAT PDO is set to 1ms, and in the 1ms timer interrupt, DO15 is set to 1 and sent to slave station 2, and the sending time is recorded as t1;
[0108] 2) Upon receiving data from station 2, assign the value of DO15 to DI15;
[0109] 3) After the master station receives DI15 as 1, it records the reception time t2, clears DO15 to zero, and calculates the time difference Δt between transmission and reception.
[0110] Δt=t2-t1
[0111] 4) Repeat steps 1-3 to obtain 100 sets of data;
[0112] 5) Then set the EtherCAT PDO communication cycle in step 1 to 2ms and 3ms and test 100 sets of data respectively.
[0113] Figure 7 This is a line graph of experimental data, where the horizontal axis (x-axis) represents the number of data points collected, and the vertical axis (y-axis) represents the time difference Δt, in milliseconds (ms). Experiments have verified that the average time for EtherCAT to send data to receive data is between 1 and 2 ms, which meets the application requirements of express delivery sorting systems.
[0114] Obviously, the above embodiments of the present invention are merely examples for clearly illustrating the technical solutions of the present invention, and are not intended to limit the specific implementation of the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the claims of the present invention should be included within the protection scope of the claims of the present invention.
Claims
1. A Qt-based EtherCAT master station system, characterized in that, The system comprises a human-computer interaction module, a task scheduling management module, an EtherCAT master station protocol stack function module, an XML slave station configuration file parsing module, a network port communication module and a serial port communication module; The human-computer interaction module comprises a service real-time display and control module, an EtherCAT communication data online debugging module, a service basic configuration and modular debugging module and a system authentication module; The task scheduling management module comprises a system working state management module, a complex service data processing module and a task scheduling module; The EtherCAT master station protocol stack function module comprises a real-time data processing module of a controlled object, a service control logic management module of a controlled slave station, an EtherCAT master station initialization flow module and a service processing process interface implementation module of the controlled object; The XML slave station configuration file parsing module is used for parsing an XML format slave station configuration file and using parsed data for the EtherCAT communication data online debugging module in the human-computer interaction module; The network port communication module is used for expanding network port communication functions according to service requirements; The serial port communication module is used for expanding serial port communication functions according to service requirements; The multi-task scheduling method of the Qt-based EtherCAT master station system comprises a task multi-thread division and priority setting method and a method for ensuring stable operation of a highest priority task; The task multi-thread division and priority setting method comprises the following steps: S1, according to service requirements, performing multi-thread task allocation on a plurality of working tasks, and the thread allocation rule is as follows: thread1 is a real-time control task; thread2 is a service logic management task; thread3 is a human-computer interaction task; S2, performing thread attribution allocation on tasks in each module: the thread task included in thread1 is a task in the EtherCAT master station protocol stack function module; the thread task included in thread2 is a task in the task scheduling management module, the TCP network port communication module and the Modbus serial port communication module; the thread task included in thread3 is a task in the human-computer interaction module; S3, according to the actual task work priority, the priority of thread1, thread2 and thread3 three threads is set: the process data communication task is high-frequency real-time communication, which is set as the highest priority task, and the process data communication task is realized in the 1ms precision timer interrupt; based on the Qt language rule, thread1 is set as TimeCriticalPriority, and high-frequency timer interrupt is used to wake up execution; based on the Qt language rule, the default thread3 is NormalPriority; thread2 is set as HighestPriority or HighPriority; in summary: thread1-TimeCriticalPriority > thread2-HighestPriority / HighPriority > thread3-NormalPriority; The method for ensuring stable operation of the highest priority task comprises the following steps: S1, event-driven is used as a business process trigger condition, specifically, the business process of the task scheduling management of thread2 thread uses the signal and slot mechanism to interact with the high-priority thread thread1; the man-machine interaction task of the thread with the lowest priority thread3 also uses the signal and slot mechanism to interact with thread2, wherein the data in thread1 wants to be transmitted into thread3 through thread2 forwarding; S2, the asynchronous operation is used to process complex data, the asynchronous operation refers to that the complex operation involved in the high-priority thread thread1 is all transferred to the thread2 thread with lower priority to execute and store data, and the thread1 only reads and uses the data processed in the thread2 thread, without operation; S3, a queue is used to manage the tasks to be executed, when the business process is executed in the high-frequency timer interrupt of thread1, the series of operations of task b similar to task a are placed in the queue and the execution conditions are set, and the queue is placed in the high-frequency timer interrupt and triggered to execute according to the time sequence order condition, so that task a and task b are executed according to the time sequence order.
2. The Qt-based EtherCAT master station system of claim 1, wherein, The business real-time display and control module comprises real-time display data required by the business and real-time control functions required by the business. The EtherCAT communication data online debugging module comprises PDO data reading and writing and SDO data reading and writing. The business basic configuration and modular debugging module comprises a basic configuration part and a modular debugging part. The system authentication module is used to limit the user usage permission.
3. The Qt-based EtherCAT master station system of claim 1, wherein, The working state management module of the system refers to recording each working state of the business and sending real-time working state to the man-machine interaction module in the form of signal; the processing module of the complex business data refers to calculating the data participating in calculation stored in the business process, the participating calculation data including configuration data in the business basic configuration and modular debugging module, PDO data in the real-time data processing module of the controlled object; the task scheduling module refers to scheduling and executing the business process.
4. The Qt-based EtherCAT master station system of claim 1, wherein, The master station protocol stack is based on the transplantation of the SOEM master station protocol stack source code.
5. The Qt-based EtherCAT master station system of claim 1, wherein, The real-time data processing module of the controlled object refers to reading and storing PDO data in real time in EtherCAT communication, and performing format processing or complex calculation on the data according to the use requirements of the controlled object; if the data required to be called in real time in the business task is complex calculation data based on PDO data, the data is transmitted to the task scheduling management module for data processing through the signal and slot mechanism in Qt, and then called back; The business control logic management of the controlled slave station refers to that in the EtherCAT master station system, the master station sends and receives PDO data regularly and performs business logic processing on the data; the regular sending and receiving function is realized by using a precision timer, and the business logic processing and control are performed in the precision timer interrupt; The EtherCAT master station initialization process includes networking configuration, data storage area mapping, clock initialization, and EtherCAT state switching. The business processing process interface implementation of the controlled object refers to implementing the business logic processing function of the controlled object.
6. The Qt-based EtherCAT master station system of claim 5, wherein, The networking configuration refers to connecting the EtherCAT network port; the data storage area mapping refers to mapping the PDO data in the local storage area; the clock initialization refers to selecting a suitable EtherCAT clock working mode and initializing according to the actual application requirements of the business; the working mode of the EtherCAT clock includes free mode, SM synchronization mode and DC synchronization mode; the free mode refers to that the timing period of each slave station is different, and each slave station executes its own program; the SM synchronization mode refers to that each slave station task is triggered to execute when receiving the data frame of the master station; the DC synchronization mode is a high-precision time synchronization mode.
Citation Information
Patent Citations
EtherCAT master station control system and control method thereof
CN112486112A