Programming method and system suitable for instruction source switching
By constructing instruction source switching program blocks and batch data area switching methods, the problems of instruction source switching programming complexity and CPU load in PLC programs are solved, achieving efficient instruction source switching and multi-instruction source adaptability, simplifying the programming process and reducing the error rate.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHANGHAI BAOSIGHT SOFTWARE CO LTD
- Filing Date
- 2024-01-15
- Publication Date
- 2026-04-21
AI Technical Summary
In existing technologies, when switching instruction sources in a PLC program, it is necessary to write separate logic programs for local and remote instruction sources, which leads to a large programming workload and an increase in CPU processing load, and it is difficult to adapt to the switching requirements of multiple instruction sources.
Construct an instruction source switching program block, including instruction source data and control instruction data block. A batch data area switching is achieved by setting a start word and an end word. It supports switching between local or remote instruction sources and assigns the selected instruction source data to the control instruction data block in batches, allowing direct programming using control instructions in the program.
It simplifies the programming process, reduces the workload of programmers and CPU processing power, improves programming efficiency, reduces the error rate, and supports flexible switching of multiple instruction sources, saving programming time and PLC storage space.
Smart Images

Figure CN118859820B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of network technology, and more specifically, to a programming method and system suitable for instruction source switching. Background Technology
[0002] With the development of industrial technology, centralized control has become a trend in newly built power generation units. A power generation unit integrates many individual devices in addition to the main equipment. For each individual device, besides the control functions of its own system, it must meet the requirements of centralized control while also ensuring safety during commissioning and maintenance. To address this, instruction source switching needs to be implemented in the PLC program, typically using a dual instruction source switching method of "local" and "remote." When switched to "local" operation, remote operation is limited to monitoring; similarly, when switched to "remote" control, local operation is limited to monitoring. To achieve the switching function between "local" and "remote," a corresponding switching program needs to be added to the equipment's control program. The more operable components the equipment contains, the larger the program size becomes, increasing both the programming workload and the CPU's processing load.
[0003] Traditional programming methods such as Figure 1 :
[0004] Local / remote dual command source control motor 1 start program.
[0005] When Network1 selects "local" control, the logic needs to be written using local instructions;
[0006] When Network2 selects "Remote" control, the logic needs to be written using remote commands;
[0007] Network3 then combines the local and remote logic in parallel and outputs the results.
[0008] Chinese patent document CN115756730A discloses a virtual machine scheduling method, apparatus, GPU, and electronic device. The method includes: when the usage time of the current virtual machine ends, switching the buffer corresponding to the next virtual machine to the instruction source of the instruction processor, so that the instruction processor processes the instructions in the buffer corresponding to the next virtual machine. However, this patent document only implements virtual machine operation switching based on usage time, which improves fairness, but still cannot solve the above-mentioned problem. Summary of the Invention
[0009] In view of the deficiencies in the prior art, the purpose of this invention is to provide a programming method and system suitable for instruction source switching.
[0010] A programming method for instruction source switching provided by the present invention includes:
[0011] Step S1: Construct the instruction source switching program block;
[0012] The instruction source switching program block includes instruction source data and control instruction data blocks;
[0013] Step S2: Switch between different instruction sources based on the instruction source switching program block;
[0014] The command sources include local command sources and remote command sources.
[0015] Preferably, the data from the selected instruction source is assigned in batches to the control instruction data block, and the control instructions are used directly in the program for programming.
[0016] Preferably, the instruction source switching function is set in the local operation panel; the local operation panel switches instruction sources based on local modules or remote modules.
[0017] Preferably, step S2 includes switching between different data areas based on a set start word and end word, and multiple calls to the instruction switching function can select multiple data areas.
[0018] Preferably, the switching of the data area includes converting the start word into a data pointer, assigning the instruction data corresponding to the data pointer to the corresponding control instruction, incrementing the data pointer by two and pointing to the next data, and repeating the loop until the end word is assigned; if the data area is not continuous, multiple calls are performed.
[0019] A programming system for instruction source switching, provided by the present invention, includes:
[0020] Module M1: Constructs the instruction source switching program block;
[0021] The instruction source switching program block includes instruction source data and control instruction data blocks;
[0022] Module M2: Uses an instruction source switching program block to switch between different instruction sources;
[0023] The instruction sources include local instruction sources and remote instruction sources.
[0024] Preferably, after the instruction source switching program block selects an instruction source of a certain type, it assigns the data of the selected instruction source in batches to the control instruction data block, and directly uses the control instructions for programming within the program.
[0025] Preferably, the instruction source switching function is set in the local operation panel; the local operation panel switches instruction sources based on local modules or remote modules.
[0026] Preferably, step S2 includes switching between different data areas based on a set start word and end word, and multiple calls to the instruction switching function can select multiple data areas.
[0027] Preferably, the switching of the data area includes converting the start word into a data pointer, assigning the instruction data corresponding to the data pointer to the corresponding control instruction, incrementing the data pointer by two and pointing to the next data, and repeating the loop until the end word is assigned; if the data area is not continuous, multiple calls are performed.
[0028] Compared with the prior art, the present invention has the following beneficial effects:
[0029] 1. The instruction source switching program block provided by this invention can batch assign the data of the selected instruction source to the control instruction data block according to the selected instruction source type. The control instructions can be directly used for programming in the program, and there is no need to write a logic program corresponding to each instruction source.
[0030] 2. This invention can greatly reduce the workload of programmers and reduce the amount of program processing by the CPU. Because it can switch program instructions in batches, it greatly simplifies the programming process, improves the programming efficiency of programmers, and reduces the error rate. The more device components that need to switch instruction sources, the more obvious the advantages of this invention become. It is not limited to industry, but can also be extended to various industries for use in control systems.
[0031] 3. The programming method provided by this invention can simplify programming, reduce the error rate of programmers, and facilitate the troubleshooting process. The disclosed modular programming method is not limited to dual instruction source control programs. With simple modifications, it can also be applied to switching between multiple instruction sources, which has high flexibility.
[0032] 4. In projects where this invention is applied, when equipment requires instruction source switching, the control program can effectively reduce the amount of program by calling the instruction source switching (FC100) program function, saving a lot of programming time and PLC storage space, and reducing the CPU's operating load; the instruction source switching function can be encapsulated into a function block, which is convenient to use and can be used in other projects by copying and pasting, with good versatility.
[0033] Other beneficial effects of the present invention will be explained in detail through the introduction of specific technical features and technical solutions in specific embodiments. Those skilled in the art should be able to understand the beneficial technical effects brought about by these technical features and technical solutions through the introduction of these technical features and technical solutions. Attached Figure Description
[0034] Other features, objects, and advantages of the present invention will become more apparent from the following detailed description of non-limiting embodiments with reference to the accompanying drawings:
[0035] Figure 1 This is a schematic diagram of a motor start-up procedure controlled by a local / remote dual command source using a traditional method.
[0036] Figure 2 The instruction source switching principle diagram provided by this invention.
[0037] Figure 3 This is a schematic diagram illustrating the usage of the instruction source switching function in this invention.
[0038] Figure 4 This is a code diagram of the instruction source switching function in an embodiment of the present invention.
[0039] Figure 5 This is a schematic diagram of the local / remote motor start-up procedure after switching the instruction source in an embodiment of the present invention.
[0040] Figure 6 This is a schematic diagram illustrating the principle of multi-instruction source switching in an embodiment of the present invention.
[0041] Figure 7 This is a schematic diagram illustrating the usage of the multi-instruction source switching function in an embodiment of the present invention.
[0042] Figure 8 This is a code diagram of the multi-instruction source switching function in an embodiment of the present invention. Detailed Implementation
[0043] The present invention will now be described in detail with reference to specific embodiments. These embodiments will help those skilled in the art to further understand the present invention, but do not limit the invention in any way. It should be noted that those skilled in the art can make several changes and improvements without departing from the concept of the present invention. These all fall within the scope of protection of the present invention.
[0044] A programming method suitable for instruction source switching, comprising:
[0045] First, construct an instruction source switching program block.
[0046] This instruction source switching block can batch assign data from the selected instruction source to the control instruction data block according to the type of the selected instruction source, and directly use control instructions for programming within the program, eliminating the need to write logic programs for each instruction source separately. Traditional control involves writing logic programs for each instruction source separately, and then selecting the output based on the selected instruction source; while this invention first batch switches the instruction source data, then writes a unified logic program, and outputs the results.
[0047] Reference Figure 2As shown, based on the selected instruction source, the corresponding instruction source 1 (DB1) or instruction source 2 (DB2) is assigned to the actual controlled instruction (DB10) through the instruction source switching function. When writing the logic program, the data of the instruction (DB10) can be used directly. The more device components that need to switch instruction sources, the more obvious the advantages of this invention become.
[0048] This invention can significantly reduce the workload of programmers and the amount of program processing required by the CPU. Because it allows for batch switching of program instructions, it greatly simplifies the programming process, improves programmer efficiency, and reduces the error rate.
[0049] The above are basic embodiments of the present invention. The technical solution of the present invention will be further described below through a preferred embodiment.
[0050] Example 1
[0051] In this embodiment, the function of switching between "local" and "remote" dual command sources is set on the local operation panel, and the command source can be switched through the "local / remote" on the local operation panel.
[0052] The instruction source switching (FC100) function is invoked within the program:
[0053] When #CommandSelect = 0, the contents of the 'Local Instructions' data block DB1 are assigned to the 'Control Instructions' data block DB10; when #CommandSelect = 1, the contents of the 'Remote Instructions' data block DB2 are assigned to the 'Control Instructions' data block DB10. In programming, the instructions in the 'Control Instructions' data block DB10 can be used directly.
[0054] By setting the start word 'iFirstWord' and the end word 'iLastWord', programmers can easily select the data area to switch to. Multiple calls to the instruction switching function allow selection of multiple data areas. Specifically, the start word 'iFirstWord' is converted into a data pointer. After assigning the instruction data corresponding to the data pointer to the corresponding control instruction, the data pointer is incremented by 2 to point to the next data. After the assignment is complete, it points to the next data, and so on, until the end word 'iLastWord' is assigned a value, at which point the program terminates. If the data area is not contiguous, multiple calls can be made to achieve this.
[0055] Reference Figure 3 As shown, during instruction source switching, Network4: Batch instruction source switching. (Refer to...) Figure 4 As shown, the program code for the dual instruction source switching function is as follows:
[0056]
[0057] Reference Figure 7 and Figure 8 As shown, the program code for the multi-instruction source switching function is as follows:
[0058]
[0059]
[0060] After using the instruction source switching function, via the following Figure 5 This can be achieved with a single program segment (Network5: Motor 1 run command control output). Figure 1 The three-part program (Network1-Network3) functionality is used. The more device components are controlled, the more obvious the advantages of this method become.
[0061] The programming method provided by this invention simplifies programming, reduces the error rate for programmers, and facilitates troubleshooting. The disclosed modular programming method is not limited to dual-instruction source control programs; with simple modifications, it can also be applied to switching between multiple instruction sources. (See reference...) Figure 6 As shown, based on the selected instruction source, the multi-instruction source switching function (FC101) assigns the corresponding instruction source 1 (DB1), instruction source 2 (DB2), or instruction source 3 (DB3) to the actual control instruction (DB10). When writing the logic program, the data of the instruction (DB10) can be used directly. This offers high flexibility. When equipment in the application project requires instruction source switching, the control program can effectively reduce the amount of code by calling the instruction source switching (FC100) program function, saving significant programming time and PLC storage space, and reducing the CPU's operating load. The instruction source switching function can be encapsulated into a function block, making it easy to use; it can be copied and pasted into other projects, demonstrating good versatility.
[0062] The present invention also provides a programming system suitable for instruction source switching. The programming system suitable for instruction source switching can be implemented by executing the process steps of the programming method suitable for instruction source switching. That is, those skilled in the art can understand the programming method suitable for instruction source switching as a preferred embodiment of the programming system suitable for instruction source switching.
[0063] Specifically, a programming system suitable for instruction source switching includes:
[0064] Module M1: Constructs the instruction source switching program block;
[0065] The instruction source switching program block includes instruction source data and control instruction data blocks;
[0066] Module M2: Uses an instruction source switching program block to switch between different instruction sources;
[0067] The instruction sources include local instruction sources and remote instruction sources.
[0068] After selecting a type of instruction source, the instruction source switching program block assigns the data of the selected instruction source in batches to the control instruction data block, and directly uses the control instructions for programming within the program.
[0069] The instruction source switching function is set in the local operation panel; the local operation panel switches instruction sources based on local modules or remote modules.
[0070] Step S2 includes switching between different data areas based on a set start word and end word, and multiple calls to the instruction switching function can select multiple data areas.
[0071] The switching of the data area includes converting the start word into a data pointer, assigning the instruction data corresponding to the data pointer to the corresponding control instruction, incrementing the data pointer by two and pointing to the next data, and repeating the loop until the end word is assigned. If the data area is not continuous, multiple calls are made.
[0072] Those skilled in the art will understand that, besides implementing the system and its various devices, modules, and units provided by this invention in the form of purely computer-readable program code, the same functions can be achieved entirely through logical programming of the method steps, making the system and its various devices, modules, and units of this invention function in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers. Therefore, the system and its various devices, modules, and units provided by this invention can be considered as a hardware component, and the devices, modules, and units included therein for implementing various functions can also be considered as structures within the hardware component; alternatively, the devices, modules, and units for implementing various functions can be considered as both software modules implementing the method and structures within the hardware component.
[0073] In the description of this application, it should be understood that the terms "upper", "lower", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inner", "outer", etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are only for the convenience of describing this application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on this application.
[0074] Specific embodiments of the present invention have been described above. It should be understood that the present invention is not limited to the specific embodiments described above, and those skilled in the art can make various changes or modifications within the scope of the claims, which do not affect the essence of the present invention. Unless otherwise specified, the embodiments and features described in this application can be arbitrarily combined with each other.
Claims
1. A programming method suitable for instruction source switching, characterized in that, include: Step S1: Construct the instruction source switching program block; The instruction source switching program block includes instruction source data and control instruction data blocks; Step S2: Switch between different instruction sources based on the instruction source switching program block; The instruction sources include local instruction sources and remote instruction sources; Step S2 includes switching between different data areas based on a set start word and end word, and multiple calls to the instruction switching function can select multiple data areas; The switching of the data area includes converting the start word into a data pointer, assigning the instruction data corresponding to the data pointer to the corresponding control instruction, incrementing the data pointer by two and pointing to the next data, and repeating the loop until the end word is assigned. If the data area is not continuous, multiple calls are made.
2. The programming method for instruction source switching according to claim 1, characterized in that, After selecting a type of instruction source, the instruction source switching program block assigns the data of the selected instruction source in batches to the control instruction data block, and directly uses the control instructions for programming within the program.
3. The programming method for instruction source switching according to claim 1, characterized in that, The instruction source switching function is set in the local operation panel; the local operation panel switches instruction sources based on local modules or remote modules.
4. A programming system suitable for instruction source switching, characterized in that, include: Module M1: Constructs the instruction source switching program block; The instruction source switching program block includes instruction source data and control instruction data blocks; Module M2: Uses an instruction source switching program block to switch between different instruction sources; The instruction sources include local instruction sources and remote instruction sources; Step M2 includes switching between different data areas based on a set start word and end word, and multiple calls to the instruction switching function can select multiple data areas; The switching of the data area includes converting the start word into a data pointer, assigning the instruction data corresponding to the data pointer to the corresponding control instruction, incrementing the data pointer by two and pointing to the next data, and repeating the loop until the end word is assigned. If the data area is not continuous, multiple calls are made.
5. A programming system suitable for instruction source switching according to claim 4, characterized in that, After selecting a type of instruction source, the instruction source switching program block assigns the data of the selected instruction source in batches to the control instruction data block, and directly uses the control instructions for programming within the program.
6. A programming system suitable for instruction source switching according to claim 4, characterized in that, The instruction source switching function is set in the local operation panel; the local operation panel switches instruction sources based on local modules or remote modules.
Citation Information
Patent Citations
Virtual machine scheduling method and device, GPU and electronic equipment
CN115756730A
Device control method and apparatus
CN106452994A
Microprocessor, and operation method therefor
US20220113972A1