Programmable controller device based on dual-core hard real-time Linux system and implementation method

By using dual-core hard real-time Linux system and Xenomai operating system in the motion control programmable controller, real-time and non-real-time parts are divided and compiled, the problem of difficult to achieve efficient hard real-time characteristics and powerful basic functions in the existing technology is solved, and real-time performance and autonomous controllable capabilities that meet the needs of motion control are achieved.

CN119882580APending Publication Date: 2025-04-25BEIJING SIFANG JIBAO ENG TECH +2
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411904092.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-23
Publication Date
2025-04-25

AI Technical Summary

Technical Problem

The prior art is difficult to achieve efficient hard real-time features and powerful basic functions in motion-controlled programmable controllers, and cannot meet the growing communication and computing power driving requirements of modern programmable controllers.

Method used

The programmable controller device based on dual-core hard real-time Linux system is adopted, combined with the Xenomai operating system, and the programmable controller runtime application is divided into real-time and non-real-time parts, and runs on the non-real-time kernel and real-time kernel of the Xenomai operating system respectively, to realize integrated compilation and data exchange.

Benefits of technology

It has achieved improvements in the hard real-time characteristics and basic functions of the motion control programmable controller, met the necessary real-time performance and autonomous control requirements in motion control, and formed a reliable technical route.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119882580A_ABST
    Figure CN119882580A_ABST
Patent Text Reader

Abstract

The invention discloses a programmable controller device based on a dual-core hard real-time Linux system and an implementation method. The method comprises the following steps: transplanting a programmable controller into a Xenomai operating system to run; the method comprises the following steps of: logically dividing an application program into a real-time part and a non-real-time part when the programmable controller runs; based on a Xenomai operating system, performing integrated compiling by taking an application program as a whole when the programmable controller operates; and respectively running the compiled real-time part and the compiled non-real-time part on a non-real-time kernel and a real-time kernel of the Xenomai operating system, and respectively calling respective corresponding infrastructures through the non-real-time kernel and the real-time kernel to execute the corresponding infrastructures so as to execute the motion control task. And a real-time bus protocol is transplanted to a real-time core kernel part, so that the execution efficiency is further improved. According to the invention, an autonomous and controllable motion control programmable controller design method is realized, and the real-time performance index necessary for motion control is satisfied.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of programmable controllers, and in particular, relates to a programmable controller device based on a dual-core hard real-time Linux system and an implementation method thereof. Background Art

[0002] In the scenario of autonomous and controllable PLC (Programmable Logic Controller) for motion control, the operating system as the basic platform needs to maintain powerful network, multi-core CPU driver and other functions while requiring efficient hard real-time characteristics and meet the requirements of autonomous control. Although the microkernel operating system has excellent hard real-time performance, its basic functions are limited and cannot meet the growing communication and computing power drive requirements of modern programmable controllers. Although the hard real-time characteristics of domestic macrokernel operating systems such as Yihui are met, the technology is still in the development stage and there are still risks in stability.

[0003] Therefore, it is necessary to propose a new technical solution to improve the problems existing in the prior art. Summary of the invention

[0004] In order to solve the deficiencies in the prior art, the present invention provides a programmable controller device and implementation method for a dual-core hard real-time Linux system, which solves the related problems of the motion control programmable controller running based on the Xenomai operating system, so that the motion control programmable controller can meet the hard real-time characteristics required for motion control during operation, and can use the powerful basic functions of the Linux system to expand advanced characteristics.

[0005] The present invention adopts the following technical solution.

[0006] A first aspect of the present invention provides a programmable controller device based on a dual-core hard real-time Linux system, comprising:

[0007] A hardware body, wherein the hardware body includes a non-real-time dedicated CPU core and a hard real-time dedicated CPU core;

[0008] Xenomai operating system, embedded in the hardware body, including Xenomai non-real-time kernel and Xenomai real-time kernel, the Xenomai operating system is based on Linux system;

[0009] Programmable controller runtime application, running in the Xenomai operating system, is used to perform motion control tasks.

[0010] A second aspect of the present invention provides a method for implementing a programmable controller based on a dual-core hard real-time Linux system, comprising:

[0011] Transplant the programmable controller to the Xenomai operating system;

[0012] Logically divide the programmable controller runtime application into real-time and non-real-time parts;

[0013] Based on the Xenomai operating system, the programmable controller runtime application is compiled as a whole;

[0014] The compiled real-time part and non-real-time part are run on the non-real-time kernel and real-time kernel of the Xenomai operating system respectively, and the corresponding infrastructure is called through the non-real-time kernel and the real-time kernel to execute the motion control task.

[0015] Optionally, the non-real-time part includes at least one of the following: initialization, upper communication software, wave recording and log recording, and the infrastructure controlled by the non-real-time kernel of the Xenomai operating system includes at least one of the following: display, TCP / IP protocol stack and file system.

[0016] Optionally, the real-time part includes at least one of the following: user task calculation, lower IO device bus communication, and the infrastructure controlled by the real-time kernel of the Xenomai operating system includes: IO devices.

[0017] Optionally, the method further comprises:

[0018] The data that needs to be exchanged between the real-time part and the non-real-time part is exchanged using globally allocated shared memory.

[0019] Optionally, the method further includes: performing at least one of the following isolation operations on the real-time part and the non-real-time part: CPU isolation, network port isolation and interrupt processing isolation.

[0020] Optionally, the programmable controller includes at least two CPUs, the first CPU is used to run a non-real-time kernel of the Xenomai operating system, and the second CPU is used to run a real-time kernel of the Xenomai operating system.

[0021] Optionally, the method further comprises:

[0022] After isolation, the CPU bus lock instruction is disabled in the non-real-time section.

[0023] Optionally, the method further comprises:

[0024] The communication parsing program related to the interaction with the motion control device is ported to the kernel state of the Xenomai operating system, and the parsed communication data is copied from the kernel state to the user state using the address mapping method.

[0025] Compared with the prior art, the beneficial effects of the present invention include at least:

[0026] The present invention applies the open source operating system Xenomai of the Linux dual-core hard real-time transformation route to the motion control programmable controller device, achieving autonomous control while satisfying the real-time performance required in motion control, and having application feasibility. The present invention can effectively solve various problems encountered by the motion control programmable controller when transplanting to Xenomai, forming a reliable technical route. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for describing the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative labor. Among them:

[0028] Figure 1 A schematic diagram of an implementation architecture of a programmable controller based on a dual-core hard real-time Linux system provided by an embodiment of the present invention;

[0029] Figure 2 A schematic diagram of EtherCAT interaction provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0030] In order to make the purpose, technical scheme and advantages of the present invention clearer, the technical scheme of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. The embodiments described in this application are only embodiments of a part of the present invention, rather than all embodiments. Based on the spirit of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work belong to the protection scope of the present invention.

[0031] The Xenomai operating system is a real-time framework used on Linux systems. It enhances the real-time performance of Linux by providing an additional real-time kernel, enabling Linux to meet the requirements of hard real-time systems.

[0032] Combination Figure 1 As shown, Embodiment 1 of the present invention provides a programmable controller device of a dual-core hard real-time Linux system, comprising:

[0033] Hardware entity, including non-real-time dedicated CPU core and hard real-time dedicated CPU core;

[0034] Xenomai operating system, embedded in the hardware body, including Xenomai non-real-time kernel and Xenomai real-time kernel, the Xenomai operating system is based on Linux system;

[0035] PLC runtime application, running in the Xenomai operating system, is used to perform motion control tasks.

[0036] Embodiment 1 of the present invention provides a programmable controller implementation method based on a dual-core hard real-time Linux system, which is applied to a motion control programmable controller device installed with a Xenomai operating system, comprising:

[0037] S1. Transplant the programmable controller to the Xenomai operating system based on Linux system.

[0038] S2. The RTE (Real Time Environment) application of the programmable controller is logically divided into a real-time part and a non-real-time part, and communication is performed.

[0039] Optionally, the non-real-time part includes at least one of the following: initialization, upper communication software, wave recording and log recording, and the infrastructure controlled by the non-real-time kernel of the Xenomai operating system includes at least one of the following: display, TCP / IP protocol stack and file system.

[0040] Specifically, initialization and upper software communication do not require real-time characteristics. Wave recording and logging will call the slow file system for processing, and the corresponding functions are planned to the non-real-time part.

[0041] Optionally, the real-time part includes at least one of the following: user task calculation, lower IO device bus communication, and the infrastructure controlled by the real-time kernel of the Xenomai operating system includes: IO devices.

[0042] Specifically, user task calculation and lower-level IO device bus communication need to be strictly scheduled according to the cycle, and the corresponding functions should be planned into the real-time part.

[0043] S3. Based on the Xenomai operating system, the programmable controller runtime application is compiled as a whole.

[0044] In this embodiment, the programmable controller RTE is compiled as a Xenomai integrated application. Compared with the split compilation method commonly used in the prior art, in which the real-time part is compiled as a Xenomai application and the non-real-time part is compiled as a Linux application, the integrated application method has better compatibility with ordinary Linux programs and does not require a lot of modification work. In addition, during the invention process, the present invention found that the integrated compilation can unexpectedly improve the real-time performance of the system and meet the hard real-time performance requirements of the motion control system.

[0045] S4. Run the compiled real-time part and non-real-time part on the non-real-time kernel and real-time kernel of the Xenomai operating system respectively, and call the corresponding infrastructure through the non-real-time kernel and the real-time kernel to execute the motion control task.

[0046] Specifically, in the programming implementation stage, threads are divided into non-real-time threads and real-time threads by specifying a thread scheduling strategy.

[0047] More specifically, the POSIX interface setschedpolicy function is called, and the function prototype is as follows:

[0048] int pthread_attr_setschedpolicy(pthread_attr_t*attr,int policy)

[0049] The function parameters are as follows: attr: pointer to the thread attribute object. policy: the scheduling policy to be set, which can be one of the following: SCHED_FIFO: first-in-first-out scheduling policy, high-priority threads will run first. Set as a real-time process in xenomai. SCHED_OTHER: the default scheduling policy, the operating system automatically selects the thread running order. Set as a non-real-time process in xenomai. Return value: 0 on success. Return an error code on failure, such as EINVAL (invalid parameter), EFAULT (invalid pointer)

[0050] In this embodiment, by logically dividing the PLC application structure into a real-time part and a non-real-time part, the non-real-time part can arbitrarily call the infrastructure controlled by the Xenomai non-real-time kernel, such as display, file system, TCP / IP protocol stack, etc., while the real-time part strictly guarantees to call the infrastructure controlled by the Xenomai real-time kernel. By adapting the application to the Xenomai dual-core structure, the dual cores work together to improve the hard real-time characteristics of the motion control system.

[0051] Furthermore, the method further comprises: exchanging data to be exchanged between the real-time part and the non-real-time part using a globally allocated shared memory.

[0052] For example, the data related to the motion control process that needs to be exchanged is set as global variables in the programmable controller runtime application.

[0053] In this embodiment, during the operation of the programmable controller, the real-time part and the non-real-time part mainly exchange IO data, which is characterized by being fast and intensive. Since the real-time function and the non-real-time function are compiled in an integrated application, the data exchange is carried out in a globally allocated shared memory manner, which is more efficient than the XDDP (XenomaieXtensible Device Driver Protocol) data exchange method of the split application, and is more suitable for the 250us-1ms level fast large data volume exchange required by motion control.

[0054] Furthermore, the method also includes: isolating the real-time part from the non-real-time part by at least one of the following operations: CPU isolation, network port isolation, and interrupt processing isolation.

[0055] Specifically, network port isolation: the programmable controller includes at least two or more physical network ports, of which the real-time physical network port is initialized, driver loaded and application layer used in the real-time kernel of the Xenomai system, and the non-real-time physical network port is initialized, driver loaded and application layer used in the non-real-time kernel of the Xenomai system.

[0056] Interrupt processing isolation: Interrupt handlers run on any available CPU core by default. By binding specific interrupt processing of the real-time system part to a specific CPU core, context switching is reduced, cache hit rate is improved, and performance is optimized.

[0057] The specific implementation method is to use / proc / irq / <irq_number> / smp_affinity or smp_affinity_list file to set IRQ affinity. Find the IRQ, determine the CPU mask, set affinity, and use the echo command to write the CPU mask to the corresponding / proc / irq / <irq_number> / smp_affinity file. For example, if you want to set the affinity of IRQ 42 to CPU 0 and CPU 2 mentioned above, you can execute the following command: echo 5> / proc / irq / 42 / smp_affinity.

[0058] Optionally, the programmable controller includes at least two CPUs, the first CPU is used to run a non-real-time kernel of the Xenomai operating system, and the second CPU is used to run a real-time kernel of the Xenomai operating system.

[0059] During the invention process, it was found that, for example, when the non-real-time part is debugging periodic printing, a large number of frequent interruption operations will cause the real-time part to jitter more and affect the real-time performance without isolation. The isolation operation reduces the hardware occupation of the non-real-time part at the hardware level, which leads to a decrease in the real-time performance of the real-time part.

[0060] It should be noted that the programmable controller is not limited to including two CPUs, but may also include four CPUs, at least one of which is used to run the non-real-time kernel of the Xenomai operating system, and at least one of which is used to run the real-time kernel of the Xenomai operating system. That is to say, two CPUs may be used to run the non-real-time kernel of the Xenomai operating system, and the embodiment of the present invention does not further limit the number of CPUs actually used for operation.

[0061] Furthermore, the method further comprises: after the isolation is performed, disabling the CPU bus lock instruction in the non-real-time part.

[0062] During the invention process, it was found that, for example, when the non-real-time desktop program is performing a large-area image update, some graphics card drivers will lock the system bus for image data exchange, which will cause the real-time part to be unable to be scheduled in time, affecting real-time performance.

[0063] This embodiment disables the CPU bus lock instruction, which can reduce the situation where the non-real-time part locks the bus and memory resources, causing the real-time part to be unable to seize resources in time, thereby improving the real-time performance of the system.

[0064] Furthermore, the method also includes: transplanting the communication parsing program related to the interaction with the motion control device to the kernel state of the Xenomai operating system for operation, and using the address mapping method to copy the parsed communication data from the kernel state to the user state.

[0065] Combination Figure 2 As shown, the communication parsing program related to the interaction with the motion control device includes the motion control bus protocol stack, for example, the motion control bus often selects EtherCAT (Ethernet for Control Automation Technology, Ethernet communication protocol). The EtherCAT master station has a large amount of data exchange with the slave station through the real-time Ethernet, and the data exchange load with the application layer is relatively heavy, so the EtherCAT master station is run in the kernel state as a kernel module, and light data exchange is performed with the motion control algorithm through system calls, which reduces the amount of data interaction, can improve the process data exchange performance, and thus improve the real-time performance of the system.

[0066] Furthermore, the UDD (User-space Device Driver framework) mechanism based on Xenomai directly uses address mapping to copy the parsed communication data from kernel state to user state, reducing memory copying and improving communication data exchange performance. For example, communication data includes PDO (Process Data Object), which includes motion process control variables, such as data for controlling the speed of the motor and collecting data from various sensors.

[0067] Embodiment 3 of the present invention provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the method described in Embodiment 2 when loaded into the processor.

[0068] Specifically, the electronic device may be a motion control programmable controller device, or may be a terminal device.

[0069] Embodiment 4 of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to embodiment 2 is implemented.

[0070] Compared with the prior art, the beneficial effects of the present invention include at least:

[0071] The present invention applies the open source operating system Xenomai of the Linux dual-core hard real-time transformation route to the motion control programmable controller device, achieving autonomous control while satisfying the real-time performance required in motion control, and having application feasibility. The present invention can effectively solve various problems encountered by the motion control programmable controller when transplanting to Xenomai, forming a reliable technical route.

[0072] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.

[0073] The present disclosure may be a system, a method and / or a computer program product. The computer program product may include a computer-readable storage medium carrying computer-readable program instructions for causing a processor to implement various aspects of the present disclosure.

[0074] A computer-readable storage medium may be a tangible device that can hold and store instructions used by an instruction execution device. A computer-readable storage medium may be, for example, but not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. More specific examples of computer-readable storage media (a non-exhaustive list) include: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a static random access memory (SRAM), a portable compact disk read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanical encoding device, such as a punch card or a raised structure in a groove on which instructions are stored, and any suitable combination of the foregoing. As used herein, a computer-readable storage medium is not to be interpreted as a transient signal per se, such as a radio wave or other freely propagating electromagnetic wave, an electromagnetic wave propagating through a waveguide or other transmission medium (e.g., a light pulse through a fiber optic cable), or an electrical signal transmitted through a wire.

[0075] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network can include copper transmission cables, optical fiber transmissions, wireless transmissions, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in the computer-readable storage medium in each computing / processing device.

[0076] The computer program instructions for performing the operation of the present disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-related instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages, such as Smalltalk, C++, etc., and conventional procedural programming languages, such as "C" language or similar programming languages. Computer-readable program instructions may be executed completely on a user's computer, partially on a user's computer, as an independent software package, partially on a user's computer, partially on a remote computer, or completely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., using an Internet service provider to connect via the Internet). In some embodiments, an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), may be customized by utilizing the state information of the computer-readable program instructions, and the electronic circuit may execute the computer-readable program instructions, thereby realizing various aspects of the present disclosure.

[0077] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, ordinary technicians in the relevant field should understand that the specific implementation methods of the present invention can still be modified or replaced by equivalents, and any modifications or equivalent replacements that do not depart from the spirit and scope of the present invention should be covered within the scope of protection of the claims of the present invention.

Claims

1. A programmable controller device based on a dual-core hard real-time Linux system, characterized in that: include: A hardware body, wherein the hardware body includes a non-real-time dedicated CPU core and a hard real-time dedicated CPU core; Xenomai operating system, embedded in the hardware body, including Xenomai non-real-time kernel and Xenomai real-time kernel, the Xenomai operating system is based on Linux system; Programmable controller runtime application, running in the Xenomai operating system, is used to perform motion control tasks.

2. A method for implementing a programmable controller based on a dual-core hard real-time Linux system using the programmable controller device based on a dual-core hard real-time Linux system according to claim 1, characterized in that: include: Transplant the programmable controller to the Xenomai operating system; Logically divide the programmable controller runtime application into real-time and non-real-time parts; Based on the Xenomai operating system, the programmable controller runtime application is compiled as a whole; The compiled real-time part and non-real-time part are run on the non-real-time kernel and real-time kernel of the Xenomai operating system respectively, and the corresponding infrastructure is called through the non-real-time kernel and the real-time kernel to execute the motion control task.

3. The method for implementing a programmable controller based on a dual-core hard real-time Linux system according to claim 2, characterized in that: The non-real-time part includes at least one of the following: initialization, upper communication software, wave recording and log recording, and the infrastructure controlled by the non-real-time kernel of the Xenomai operating system includes at least one of the following: display, TCP / IP protocol stack and file system.

4. The method for implementing a programmable controller based on a dual-core hard real-time Linux system according to claim 2, characterized in that: The real-time part includes at least one of the following: user task calculation, lower IO device bus communication, and the infrastructure controlled by the real-time kernel of the Xenomai operating system includes: IO devices.

5. The method for implementing a programmable controller based on a dual-core hard real-time Linux system according to claim 2, characterized in that: The method further comprises: The data that needs to be exchanged between the real-time part and the non-real-time part is exchanged using globally allocated shared memory.

6. The method for implementing a programmable controller based on a dual-core hard real-time Linux system according to claim 2, characterized in that: The method further comprises: The real-time part is isolated from the non-real-time part by at least one of the following operations: CPU isolation, network port isolation, and interrupt processing isolation.

7. The method for implementing a programmable controller based on a dual-core hard real-time Linux system according to claim 6, characterized in that: The programmable controller comprises at least two CPUs, the first CPU is used to run the non-real-time kernel of the Xenomai operating system, and the second CPU is used to run the real-time kernel of the Xenomai operating system.

8. The method for implementing a programmable controller based on a dual-core hard real-time Linux system according to claim 6, characterized in that: The method further comprises: After isolation, the CPU bus lock instruction is disabled in the non-real-time section.

9. The method for implementing a programmable controller based on a dual-core hard real-time Linux system according to claim 2, characterized in that: The method further comprises: The communication parsing program related to the interaction with the motion control device is ported to the kernel state of the Xenomai operating system, and the parsed communication data is copied from the kernel state to the user state using the address mapping method.

Citation Information

Cited By

  • Real-time kernel-oriented program real-time compiling method and device and storage medium

    CN121501286A