Real-time control method, real-time control device, computing equipment and storage medium

CN119522418APending Publication Date: 2025-02-25SIEMENS AG
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202280098022.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2022-08-11
Publication Date
2025-02-25

AI Technical Summary

Technical Problem

Existing real-time control systems have limitations in supporting multi-language programming, cannot effectively utilize the powerful features of RTOS, and are difficult to achieve efficient multi-task scheduling and real-time control.

Method used

By running the language interpreter on the real-time operating system and setting up the command interaction interface, checking the type of external instructions received, executing language script instructions or transparently passing them to the RTOS for execution, ensuring the priority allocation of real-time tasks and non-real-time tasks, and supporting assembly Language, C/C++, Java, Python, Lua and other programming languages.

Benefits of technology

It realizes the use of the powerful features of RTOS while supporting multi-language programming, improving the efficiency and safety of real-time control, ensuring timely response to external instructions and good real-time performance of the real-time operating system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119522418A_ABST
    Figure CN119522418A_ABST
Patent Text Reader

Abstract

The invention relates to a real-time control method, a real-time control device, computing equipment and a storage medium. According to the real-time control method of the controller, a language interpreter runs on a real-time operating system of the controller, the language interpreter can read a file system and a device driver on the real-time operating system, the language interpreter comprises a command interaction interface, and the method comprises the steps that an external instruction is received through the command interaction interface of the language interpreter; the language interpreter checks whether the external instruction is a language script instruction for the language interpreter or an instruction for a real-time operating system; if the instruction is the language script instruction for the language interpreter, the language interpreter executes the language script instruction; and if the operating system instruction aims at the real-time operating system, the language interpreter transmits the operating system instruction to the real-time operating system for execution.
Need to check novelty before this filing date? Find Prior Art

Description

Real-time control method, real-time control device, computing device and storage medium Technical Field

[0001] The present disclosure generally relates to the field of automation system technology, and more particularly to a real-time control method, a real-time control apparatus, a computing device, and a storage medium. Background Art

[0002] Real-time control (or deterministic control) is a crucial feature for MCU-based industrial controllers, ensuring they can respond to external signals within a limited timeframe. Traditionally, real-time programs are typically written in C / C++ or assembly language because they interact directly with the RTOS or hardware. However, there are many other programming languages ​​(Java, Python, Lua, etc.) that offer superior efficiency and convenience in certain situations. Using these languages ​​for real-time control (or deterministic control) holds great potential.

[0003] There are compiler / interpreter versions of some specific programming languages ​​that provide optimized mechanisms and extended APIs for real-time programming, typically including:

[0004] 1.Micro-Python(https: / / micropython.org / )

[0005] MicroPython is a complete Python compiler and runtime that runs on bare metal. The hardware floating point accelerator on the bare metal hardware ensures fast and accurate floating point calculations with little impact on real-time performance. By using interrupts and timers, and using appropriate design techniques, most real-time deadlines can be easily met.

[0006] 2.pyRTOS(https: / / github.com / Rybec / pyRTOS)

[0007] pyRTOS is a real-time operating system (RTOS) written in Python. It is modeled after FreeRTOS, but with some key differences. The biggest difference is that it uses voluntary task preemption, whereas FreeRTOS typically performs preemption via timer interrupts. This means that the user has a greater responsibility to ensure that all tasks behave well. pyRTOS also uses a different naming convention, and tasks have built-in message passing.

[0008] That is, a pure Micro-Python solution runs the interpreter directly on the bare metal hardware, but the problem is that existing source code and libraries developed on the RTOS cannot be reused. Multitasking scheduling is also generally more difficult for embedded interpreters than for popular RTOS software.

[0009] The PyRTOS solution uses an RTOS written in Python, so applications (tasks) can also be written in Python. The real-time operating system and applications share the same interpreter. However, the problem is that applications cannot be written in other languages, and the RTOS limits the language choice for applications.

[0010] Summary of the Invention

[0011] A brief overview of the present invention is provided below to provide a basic understanding of certain aspects of the present invention. It should be understood that this overview is not an exhaustive overview of the present invention. It is not intended to identify key or important aspects of the present invention, nor is it intended to limit the scope of the present invention. Its purpose is simply to present certain concepts in a simplified form as a prelude to the more detailed description discussed later.

[0012] In view of this, the present disclosure proposes a real-time control method for a controller, which can not only utilize the powerful characteristics of a real-time operating system but also has high efficiency in supporting multiple languages.

[0013] According to one aspect of the present disclosure, a real-time control method for a controller is provided, wherein a language interpreter runs on a real-time operating system of the controller, the language interpreter is capable of reading and writing a file system and device drivers on the real-time operating system, and the language interpreter includes a command interaction interface. The method comprises:

[0014] receiving external instructions through the command interaction interface of the language interpreter;

[0015] The language interpreter checks whether the external instruction is a language script instruction for the language interpreter or an instruction for the real-time operating system;

[0016] If it is a language script instruction for the language interpreter, the language interpreter executes the language script instruction;

[0017] If the operating system instruction is for a real-time operating system, the language interpreter transparently transmits the operating system instruction to the real-time operating system for execution.

[0018] In this way, the powerful features of the real-time operating system can be utilized while also having the high efficiency of supporting multiple languages; and because only one command interaction interface is retained, it is easy to achieve real-time control and security.

[0019] Optionally, in an example of the above aspect, the real-time control method further includes:

[0020] The real-time operating system executes the real-time tasks of the real-time operating system itself and the non-real-time tasks of the real-time operating system itself,

[0021] Among them, executing the external instructions received from the command interaction interface has a high priority, executing the real-time tasks of the real-time operating system itself has a medium priority, and executing the non-real-time tasks of the real-time operating system itself has a low priority.

[0022] In this way, the instructions from the command interaction interface can be responded to in a timely manner, and the real-time tasks of the real-time operating system can be completed before the deadline, thus ensuring good real-time performance of the control.

[0023] Optionally, in an example of the above aspect, the external instruction is written in at least one of assembly language, C / C++ language, Java, python, and Lua.

[0024] In this way, multi-language instructions can be supported, providing high efficiency and convenience.

[0025] According to another aspect of the present disclosure, a real-time control device is provided, comprising: a real-time operating system, a language interpreter, and a command interaction interface, wherein:

[0026] The command interaction interface is configured to receive external instructions;

[0027] The language interpreter is configured to check whether the received external instruction is a language script instruction for the language interpreter or an instruction for a real-time operating system; if it is a language script instruction for the language interpreter, the language interpreter executes the language script instruction; if it is an operating system instruction for the real-time operating system, the language interpreter transparently transmits the operating system instruction to the real-time operating system; and

[0028] The operating system is configured to execute the operating system instructions.

[0029] Optionally, in an example of the above aspect, the real-time operating system is further configured to execute the real-time tasks of the real-time operating system itself and the non-real-time tasks of the real-time operating system itself,

[0030] Among them, executing the external instructions received from the command interaction interface has a high priority, executing the real-time tasks of the real-time operating system itself has a medium priority, and executing the non-real-time tasks of the real-time operating system itself has a low priority.

[0031] Optionally, in an example of the above aspect, the external instruction is written in at least one of assembly language, C / C++ language, Java, python, and Lua.

[0032] According to another aspect of the present disclosure, a computing device is provided, comprising: at least one processor; and a memory coupled to the at least one processor, the memory being configured to store instructions that, when executed by the at least one processor, enable the processor to perform the method described above.

[0033] According to another aspect of the present disclosure, a non-transitory machine-readable storage medium is provided, which stores executable instructions. When the instructions are executed, the machine is caused to perform the method described above.

[0034] According to another aspect of the present disclosure, a computer program is provided, comprising computer-executable instructions, which, when executed, cause at least one processor to perform the method described above.

[0035] According to another aspect of the present disclosure, a computer program product is provided, which is tangibly stored on a computer-readable medium and includes computer-executable instructions that, when executed, cause at least one processor to perform the method described above. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] The above and other purposes, features and advantages of the present invention will be more easily understood by referring to the following description of the embodiments of the present invention in conjunction with the accompanying drawings. The components in the accompanying drawings are only for illustrating the principles of the present invention. In the accompanying drawings, the same or similar technical features or components will be represented by the same or similar reference numerals. In the accompanying drawings:

[0037] FIG1 is a schematic diagram of a real-time controller using a real-time control method according to an embodiment of the present disclosure.

[0038] FIG2 is a flowchart of an exemplary process of a real-time control method of a controller according to an embodiment of the present disclosure.

[0039] FIG3 is a block diagram showing an exemplary configuration of a real-time control apparatus according to an embodiment of the present disclosure.

[0040] FIG4 shows a block diagram of a computing device for implementing a real-time control method of a real-time controller according to an embodiment of the present disclosure.

[0041] The accompanying drawings are numerals as follows:

[0042] 100: Real-time Controller 102: Controller Hardware

[0043] 104: Real-time operating system 106: File system

[0044] 108: Driver 110: Language Interpreter

[0045] 112: Real-time tasks 114: Non-real-time tasks

[0046] 120: Peripheral devices 116: Command interaction interface

[0047] 200: Real-time control method S202, S204, S206, S208, S210: Steps

[0048] 300: Real-time control device 302: Real-time operating system

[0049] 304: Language interpreter 306: Command interaction interface

[0050] 400: Computing device 402: Processor

[0051] 404: Memory DETAILED DESCRIPTION

[0052] The subject matter described herein will now be discussed with reference to example embodiments. It should be understood that discussing these embodiments is intended only to enable those skilled in the art to better understand and implement the subject matter described herein, and is not intended to limit the scope of protection, applicability, or examples set forth in the claims. The functions and arrangements of the elements discussed may be changed without departing from the scope of protection of this disclosure. Various examples may omit, replace, or add various processes or components as needed. For example, the described method may be performed in an order different from the described order, and various steps may be added, omitted, or combined. In addition, features described relative to some examples may also be combined in other examples.

[0053] As used herein, the term "including" and its variations are open terms meaning "including but not limited to". The term "based on" means "based at least in part on". The terms "one embodiment" and "an embodiment" mean "at least one embodiment". The term "another embodiment" means "at least one other embodiment". The terms "first", "second", etc. may refer to different or the same objects. Other definitions may be included below, whether explicit or implicit. Unless the context clearly indicates otherwise, the definition of a term is consistent throughout the specification.

[0054] In view of this, the present disclosure proposes a real-time control method for a controller, which can not only utilize the powerful characteristics of a real-time operating system but also has high efficiency in supporting multiple languages.

[0055] The real-time control method according to the embodiments of the present disclosure will be described below with reference to the accompanying drawings.

[0056] FIG1 is a schematic diagram of a real-time controller 100 using a real-time control method according to an embodiment of the present disclosure.

[0057] As shown in FIG1 , a real-time operating system (RTOS) 104 is running on the controller hardware 102. The RTOS is responsible for establishing a file system 106 of the controller 100 and drivers 108 for peripheral devices.

[0058] In order to support multiple different programming languages, the language interpreter 110 is run as a task on the RTOS.

[0059] Typically, a language interpreter has its own file system and peripheral devices, as well as interfaces for accessing the file system and peripheral devices. In a controller according to the present disclosure, the language interpreter does not have its own file system and device drivers, but rather interfaces with the file system and device drivers of the RTOS. In this way, the language interpreter 110 and other tasks of the RTOS, such as the real-time task 112 and the non-real-time task 114, can access the same file system, exchange data (files), and control the peripheral devices 120.

[0060] In addition, the language interpreter 110 is provided with a command interaction interface 116 , which may adopt, for example, a REPL (read-eval-print loop) to receive instructions from outside the controller.

[0061] The following describes a real-time control method for the above-mentioned real-time controller with reference to Figure 2. Figure 2 is a flow chart of an exemplary process of a real-time control method 200 for a controller according to an embodiment of the present disclosure.

[0062] First, in step S202, an external instruction is received through the command interaction interface of the language interpreter.

[0063] External instructions originate from outside the controller and generally fall into two categories: language script instructions and RTOS instructions. Language script instructions, such as Python script instructions, are executed by the language interpreter, for example, "responding to hello." RTOS instructions are executed by the real-time operating system (RTOS). After receiving instructions for the RTOS, the language interpreter transparently transmits the RTOS instructions.

[0064] Therefore, in step S204 , the language interpreter checks whether the external instruction is a language script instruction for the language interpreter or an instruction for the real-time operating system.

[0065] If it is a language script instruction for the language interpreter, in step S206, the language interpreter executes the language script instruction.

[0066] If it is an operating system instruction for a real-time operating system, in step S208, the language interpreter transparently transmits the operating system instruction to the real-time operating system for execution.

[0067] In this way, only one command interaction interface is retained, making it easy to achieve real-time control and security.

[0068] In addition to receiving external instructions, the RTOS also has its own tasks. Therefore, the real-time control method further includes step S210:

[0069] The real-time operating system executes the real-time tasks of the real-time operating system itself and the non-real-time tasks of the real-time operating system itself,

[0070] Among them, executing the external instructions received from the command interaction interface has a high priority, executing the real-time tasks of the real-time operating system itself has a medium priority, and executing the non-real-time tasks of the real-time operating system itself has a low priority.

[0071] Assume that the controller has a cycle time A. In one cycle time, the external instructions received through the command interaction interface need to occupy CPU time to complete, and the real-time tasks and other non-real-time tasks of the RTOS also need to occupy CPU time. In order to maintain a good user experience for the command interaction interface, in the real-time control according to the present disclosure, the highest priority is assigned to the execution of external instructions received from the command interaction interface, while the real-time tasks of the real-time operating system itself are assigned a medium priority, and the non-real-time tasks of the real-time operating system itself are assigned a low priority. That is to say, in one cycle, if an external instruction is received, the external instruction is executed first, the real-time tasks of the RTOS are executed second priority, and then the non-real-time tasks are executed.

[0072] In this way, the instructions from the command interaction interface can be responded to in a timely manner, and the real-time tasks of the real-time operating system can be completed before the deadline, thus ensuring good real-time performance of the control.

[0073] In the real-time control method according to the present disclosure, since a language interpreter is run on the RTOS, instructions written in different programming languages ​​can be executed, for example, assembly language, C / C++ language, Java, Python, Lua and other programming languages ​​can be used.

[0074] In this way, multi-language instructions can be supported, providing high efficiency and convenience.

[0075] FIG3 is a block diagram showing an exemplary configuration of a real-time control apparatus 300 for executing the real-time control method shown in FIG2 .

[0076] In FIG3 , a real-time control device 300 includes a real-time operating system 302 , a language interpreter 304 , and a command interaction interface 306 .

[0077] The command interaction interface 306 is configured to receive external instructions.

[0078] The language interpreter 304 is configured to check whether the received external instruction is a language script instruction for the language interpreter or an instruction for the real-time operating system. If it is a language script instruction for the language interpreter, the language interpreter executes the language script instruction; if it is an operating system instruction for the real-time operating system, the language interpreter passes the operating system instruction to the real-time operating system.

[0079] The real-time operating system 306 is configured to execute the operating system instructions.

[0080] In which, the real-time operating system 306 is further configured to execute the real-time tasks and non-real-time tasks of the real-time operating system itself, wherein executing the external instructions received from the command interaction interface has a high priority, executing the real-time tasks of the real-time operating system itself has a medium priority, and executing the non-real-time tasks of the real-time operating system itself has a low priority.

[0081] The external instructions are written in at least one of assembly language, C / C++ language, Java, Python, and Lua.

[0082] It should be noted that the structure of the real-time control device 300 and its constituent units shown in FIG3 is merely exemplary, and those skilled in the art may modify the structural block diagram shown in FIG3 as needed.

[0083] The details of the operations and functions of the various parts of the real-time control device 300 may be the same as or similar to the relevant parts of the embodiment of the real-time control method of the real-time controller of the present disclosure described in conjunction with Figures 1-2, and will not be described in detail here.

[0084] 1 to 3, the real-time control method and the real-time control device of the real-time controller according to the present disclosure are described. Each unit of the real-time control device described above can be implemented by hardware, software, or a combination of hardware and software.

[0085] 4 shows a block diagram of a computing device 400 for implementing a real-time control method for a real-time controller according to an embodiment of the present disclosure. According to one embodiment, the computing device 400 may include at least one processor 402 that executes at least one computer-readable instruction (i.e., the aforementioned elements implemented in software form) stored or encoded in a computer-readable storage medium (i.e., memory 404).

[0086] It should be understood that the computer executable instructions stored in the memory 404, when executed, cause the at least one processor 402 to perform the various operations and functions described above in conjunction with Figures 1-3 in various embodiments of the present disclosure.

[0087] According to one embodiment, a non-transitory machine-readable medium is provided. The non-transitory machine-readable medium may have machine-executable instructions (i.e., the elements implemented in software above), which, when executed by a machine, cause the machine to perform the various operations and functions described above in conjunction with Figures 1-3 in various embodiments of the present disclosure.

[0088] According to one embodiment, a computer program is provided, including computer-executable instructions, which, when executed, enable at least one processor to perform the various operations and functions described above in conjunction with Figures 1-3 in various embodiments of the present disclosure.

[0089] According to one embodiment, a computer program product is provided, including computer-executable instructions, which, when executed, enable at least one processor to perform the various operations and functions described above in conjunction with Figures 1-3 in various embodiments of the present disclosure.

[0090] It should be understood that the various embodiments in this specification are described in a progressive manner, and reference can be made to the common or similar parts of the various embodiments. Each embodiment focuses on the differences from the other embodiments. For example, the above-mentioned apparatus embodiments, computing device embodiments, and machine-readable storage medium embodiments are generally similar to the method embodiments, so their descriptions are relatively simple. For relevant details, reference can be made to the descriptions of the method embodiments.

[0091] The foregoing description of this specification describes specific embodiments. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims can be performed in an order different from that described in the embodiments and still achieve the desired results. Furthermore, the processes depicted in the accompanying drawings do not necessarily require the specific order shown or the sequential order to achieve the desired results. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0092] Not all steps and units in the above processes and system structure diagrams are required, and some steps or units may be omitted according to actual needs. The device structures described in the above embodiments can be physical structures or logical structures, that is, some units may be implemented by the same physical entity, or some units may be implemented by multiple physical entities, or may be implemented by certain components in multiple independent devices.

[0093] The specific embodiments described above in conjunction with the accompanying drawings describe exemplary embodiments, but do not represent all embodiments that can be implemented or fall within the scope of protection of the claims. The term "exemplary" used throughout this specification means "used as an example, instance or illustration" and does not mean "preferred" or "having advantages" over other embodiments. For the purpose of providing an understanding of the described technology, the specific embodiments include specific details. However, these technologies can be implemented without these specific details. In some instances, in order to avoid obscuring the concepts of the described embodiments, well-known structures and devices are shown in block diagram form.

[0094] The foregoing description of the present disclosure is provided to enable any person skilled in the art to implement or use the present disclosure. Various modifications to the present disclosure will be readily apparent to those skilled in the art, and the general principles defined herein may be applied to other variations without departing from the scope of the present disclosure. Therefore, the present disclosure is not limited to the examples and designs described herein, but is intended to be consistent with the widest range of principles and novel features disclosed herein.

[0095] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. A real-time control method of a controller, wherein: A language interpreter is run on the real-time operating system of the controller, the language interpreter can read and write the file system and device drivers on the real-time operating system, and the language interpreter includes a command interaction interface. The method includes: receiving external instructions through the command interaction interface of the language interpreter; The language interpreter checks whether the external instruction is a language script instruction for the language interpreter or an instruction for the real-time operating system; If it is a language script instruction for the language interpreter, the language interpreter executes the language script instruction; If the operating system instruction is for a real-time operating system, the language interpreter transparently transmits the operating system instruction to the real-time operating system for execution.

2. The method of claim 1, further comprising: The real-time operating system executes the real-time tasks of the real-time operating system itself and the non-real-time tasks of the real-time operating system itself, Among them, executing the external instructions received from the command interaction interface has a high priority, executing the real-time tasks of the real-time operating system itself has a medium priority, and executing the non-real-time tasks of the real-time operating system itself has a low priority.

3. The method according to claim 1, wherein The external instructions are written in at least one of assembly language, C / C++ language, Java, Python, and Lua.

4. Real-time control device (300), comprising: A real-time operating system (302), a language interpreter (304), and a command interaction interface (306), wherein: The command interaction interface (306) is configured to receive external instructions; The language interpreter (304) is configured to check whether the received external instruction is a language script instruction for the language interpreter or an instruction for a real-time operating system; if it is a language script instruction for the language interpreter, the language interpreter executes the language script instruction; if it is an operating system instruction for the real-time operating system, the language interpreter transparently transmits the operating system instruction to the real-time operating system; and The operating system (302) is configured to execute the operating system instructions.

5. The real-time control device (300) according to claim 4, wherein the real-time operating system (302) is further configured to execute the real-time tasks of the real-time operating system (302) itself and the non-real-time tasks of the real-time operating system (302) itself. in, Executing the external instructions received from the command interaction interface has a high priority, executing the real-time tasks of the real-time operating system itself has a medium priority, and executing the non-real-time tasks of the real-time operating system itself has a low priority.

6. The real-time control device (300) according to claim 4, wherein: The external instructions are written in at least one of assembly language, C / C++ language, Java, Python, and Lua.

7. A computing device (400), comprising: at least one processor (402); as well as A memory (404) coupled to the at least one processor (402), the memory being configured to store instructions, which, when executed by the at least one processor (402), causes the processor (402) to perform the method according to any one of claims 1 to 3.

8. A non-transitory machine-readable storage medium storing executable instructions, which, when executed, cause a machine to perform the method according to any one of claims 1 to 3.

9. A computer program product tangibly stored on a computer-readable medium and comprising computer-executable instructions which, when executed, cause at least one processor to perform the method according to any one of claims 1 to 3.