PLC control method, system and controller for realizing time scheduling function
By defining timetable variables and time scheduling function blocks on the PLC control end, the problems of unreliability and delay in time series planning control of the PLC control system are solved, and unified programming and offline execution of the PLC end is realized, reducing network delay and development costs, improving system flexibility and reliability.
Patent Information
- Application Number
- CN202111590742.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-23
- Publication Date
- 2025-01-03
- Estimated Expiration
- 2041-12-23
AI Technical Summary
The existing PLC control system has problems such as operational unreliability, control delay and lack of scalability in planned control based on time series. Especially when the upper and lower computers are remotely deployed, network unreliability and Software complexity leads to schedule failure and delays.
By defining timetable variables and time scheduling function blocks on the PLC control end, the definition of time rules and event output are realized. Engineers only program on the PLC end, adding timetable variables and function blocks to achieve a variety of planning control strategies, and reducing the need for The dependence of the host computer ensures offline execution and reduces network delay.
It realizes unified programming on the PLC side, reduces software development costs and time, reduces control delays, and can still perform planned scheduling when the network is disconnected, improving the reliability and flexibility of the system.
Smart Images

Figure CN114488923B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of automatic control technology, and in particular to a PLC control method, system and controller for realizing a time scheduling function. Background Art
[0002] Carrying out planned control tasks based on time series is a common application scenario of PLC control systems. For example, in building automation control scenarios, for lighting, air conditioning, exhaust and other systems, manufacturers can implement different control strategies for different times such as work / holidays, work / off-get off work hours, different seasons, and emergencies to achieve the purpose of energy conservation and emission reduction and reduce equipment loss.
[0003] At present, most of this type of automatic control needs are mainly provided by the host computer software to provide a configuration interface for the scheduling plan, and a background program is developed to perform trigger judgment. After the judgment conditions are met, instructions are sent to the PLC through the network at the execution time. The problem with this is:
[0004] (1) The hardware of the host computer is mainly composed of computers, and the software is mostly large-scale software with complex architecture. There is inherent unreliability. Abnormalities such as blue screen crash / unexplained software exit / computer virus will cause the scheduling to fail;
[0005] (2) The upper and lower PLCs are often deployed remotely. In this case, the network mainly relies on the operator network with many links, which is not only unreliable, but also causes control delays.
[0006] (3) The host computer software is generally implemented by SCADA type monitoring software, which is generally not programmable. If the time series or control object needs to be changed, or the control scale needs to be expanded, the software development personnel are often required to modify the background program, which is time-consuming and labor-intensive and not flexible enough. Summary of the invention
[0007] 1. Technical issues to be resolved
[0008] In view of the above-mentioned shortcomings and deficiencies of the prior art, the present invention provides a PLC control method, system and controller for realizing the time scheduling function, which solves the technical problems that the existing control scheme based on time series planning is difficult to ensure operation reliability, has control delays and lacks scalability.
[0009] (II) Technical solution
[0010] In order to achieve the above object, the main technical solutions adopted by the present invention include:
[0011] In a first aspect, an embodiment of the present invention provides a PLC control method for implementing a time scheduling function, comprising:
[0012] The control method is executed at the PLC control end, and the control method includes:
[0013] Get the current time of the PLC control terminal;
[0014] Matching the current time with the time series described by the schedule variables;
[0015] If the time sequence does not match the current time, a default value is output and an abnormal state is prompted;
[0016] If the time sequence matches the current time, determining whether the current time meets a special time trigger determination condition;
[0017] When the special time trigger judgment is met, the special event output is executed and the normal state is prompted;
[0018] When the special time trigger judgment is not met, it is determined whether the current time meets the general time trigger judgment;
[0019] When the general time trigger judgment is met, the general event output is executed and the normal status is prompted;
[0020] When the general time trigger judgment is not met, the default value is output and the normal state is prompted;
[0021] Wherein, the timetable variables are set in the control program of the PLC control terminal.
[0022] Optionally, before obtaining the current time of the PLC control terminal, the following steps are also included:
[0023] By parsing the timetable variables, the time scheduling information is obtained;
[0024] Determining whether the time scheduling information is abnormal;
[0025] If the time scheduling information is abnormal, output a default value and prompt the abnormal state;
[0026] If the time scheduling information is not abnormal, the operation of obtaining the current time of the PLC control terminal is performed.
[0027] Optionally, after obtaining the current time of the PLC control terminal, the following steps are also included:
[0028] Determine whether the current time of the acquired PLC control terminal is abnormal;
[0029] If the current moment is abnormal, a default value is output and an abnormal state is prompted;
[0030] If the current time is not abnormal, the operation of matching the current time with the time series described by the schedule variable is entered.
[0031] Optionally, the schedule variables include schedule effective time, periodic events, special events and default values.
[0032] Optionally,
[0033] The effective time of the schedule includes the effective start time and effective end time;
[0034] The periodic event includes the start time of the periodic event, the end time of the periodic event and the signal output value after the periodic event is successfully judged;
[0035] The special event includes the start time of the special event, the end time of the special event and the signal output value after the special event is successfully judged.
[0036] In a second aspect, an embodiment of the present invention further provides a PLC control system for implementing a time scheduling function, including: a timetable variable, a time scheduling function block, and a control business logic block;
[0037] The time scheduling function block is used to parse the received timetable variables and output corresponding signals to the control business logic block after meeting the preset trigger conditions.
[0038] Optionally, the schedule variables include schedule effective time, periodic events, special events and default values;
[0039] The effective time of the schedule includes the effective start time and effective end time;
[0040] The periodic event includes the start time of the periodic event, the end time of the periodic event and the signal output value after the periodic event is successfully judged;
[0041] The special event includes the start time of the special event, the end time of the special event and the signal output value after the special event is successfully judged.
[0042] Optionally, the time scheduling function block includes:
[0043] Time acquisition module, used to obtain the current time of the PLC control system;
[0044] A time matching module is used to match the current time with the time sequence described by the schedule variable; if the time sequence does not match the current time, output a default value to the control business logic block and prompt an abnormal state; if the time sequence matches the current time, determine whether the current time meets the special time trigger determination condition;
[0045] The special time judgment module is used to execute the special event output to the control business logic block and prompt the normal state when the special time trigger judgment is met; and to judge whether the current time meets the general time trigger judgment when the special time trigger judgment is not met;
[0046] The general time judgment module is used to execute general event output to the business control logic block and prompt the normal state when the general time trigger judgment is met; when the general time trigger judgment is not met, output the default value to the business control logic block and prompt the normal state.
[0047] Optionally, the time scheduling module further includes: an abnormality judgment module, which is used to:
[0048] Before obtaining the current time of the PLC control system, the time schedule information is obtained by parsing the timetable variables; judging whether the time schedule information is abnormal; if the time schedule information is abnormal, outputting a default value and prompting the abnormal state; if the time schedule information is not abnormal, entering the operation of obtaining the current time of the PLC control system;
[0049] as well as,
[0050] After obtaining the current time of the PLC control system, determine whether the current time of the PLC control system is abnormal; if the current time is abnormal, output a default value and prompt the abnormal state; if the current time is not abnormal, enter the operation of matching the current time with the time series described by the schedule variable.
[0051] In a third aspect, an embodiment of the present invention provides a PLC hardware controller that implements a time scheduling function, on which computer executable instructions are stored. When the executable instructions are executed by a processor, a PLC control method that implements a time scheduling function as described above is implemented.
[0052] (III) Beneficial effects
[0053] The beneficial effects of the present invention are as follows: the present invention creatively uses timetable variables to define time rules and output events, and uses time scheduling function blocks to execute and obtain outputs, which are uniformly programmed with the original control business logic of the PLC end. At the same time, engineers can program related businesses only on the PLC end, and by copying and pasting to add timetable variables and time scheduling function blocks, they can obtain a variety of planning control strategies, and the quantity scale can be easily large, which is only limited by the program capacity of the PLC itself, and software personnel are no longer required to invest in development work, which greatly reduces time and cost. Because planning and scheduling no longer rely on upper computer analysis and distribution, even if the network is disconnected, the PLC can still be executed offline, and the control delay is greatly reduced. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] Figure 1 A flow chart of a PLC control method for realizing a time scheduling function provided by an embodiment of the present invention;
[0055] Figure 2 A schematic diagram of the flow chart before step S1 of a PLC control method for realizing a time scheduling function provided by an embodiment of the present invention;
[0056] Figure 3 A schematic diagram of the flow chart after step S1 of a PLC control method for realizing a time scheduling function provided by an embodiment of the present invention;
[0057] Figure 4 A schematic diagram of a timetable variable and a time scheduling function block of a PLC control method for realizing a time scheduling function provided by an embodiment of the present invention being set in a PLC logic control program;
[0058] Figure 5 A logic control diagram of a PLC control method for realizing a time scheduling function provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0059] In order to better explain the present invention and facilitate understanding, the present invention is described in detail below through specific implementation modes in conjunction with the accompanying drawings.
[0060] like Figure 1 As shown, a PLC control method for realizing a time scheduling function proposed in an embodiment of the present invention includes: obtaining the current time of the PLC control system; matching the current time with the time sequence described by the schedule variable; if the time sequence does not match the current time, outputting a default value and prompting an abnormal state; if the time sequence matches the current time, judging whether the current time meets the special time trigger judgment condition; when the special time trigger judgment is met, executing a special event output and prompting a normal state; when the special time trigger judgment is not met, judging whether the current time meets the general time trigger judgment; when the general time trigger judgment is met, executing a general event output and prompting a normal state; when the general time trigger judgment is not met, outputting a default value and prompting an abnormal state; wherein, the schedule variable is set in the control program of the PLC control system.
[0061] The present invention creatively uses timetable variables to define time rules and output events, and uses time scheduling function blocks to execute and obtain outputs, which are programmed in a unified manner with the original control business logic of the PLC end. At the same time, engineers can program related businesses only on the PLC end, and by copying and pasting to add timetable variables and time scheduling function blocks, they can obtain a variety of planning control strategies, and the quantity scale can be easily large, only limited by the program capacity of the PLC itself, and software personnel are no longer required to invest in development work, which greatly reduces time and cost. Because planning and scheduling no longer rely on upper computer analysis and distribution, even if the network is disconnected, the PLC can still be executed offline, and the control delay is greatly reduced.
[0062] In order to better understand the above technical solution, exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present invention are shown in the accompanying drawings, it should be understood that the present invention can be implemented in various forms and should not be limited by the embodiments described herein. On the contrary, these embodiments are provided to enable a clearer and more thorough understanding of the present invention and to fully convey the scope of the present invention to those skilled in the art.
[0063] Specifically, an embodiment of the present invention provides a PLC control method for realizing a time scheduling function, including:
[0064] S1. Get the current time of the PLC control system.
[0065] like Figure 2 As shown, before obtaining the current time of the PLC control system, it also includes:
[0066] By parsing the timetable variables, the time scheduling information is obtained;
[0067] Determine whether the time scheduling information is abnormal;
[0068] If the time scheduling information is abnormal, the default value is output and the abnormal status is prompted;
[0069] If the time scheduling information is not abnormal, the operation of obtaining the current time of the PLC control system is performed.
[0070] like Figure 3 As shown, after obtaining the current time of the PLC control system, it also includes:
[0071] Determine whether the current moment of the acquired PLC control system is abnormal;
[0072] If the current moment is abnormal, the default value is output and the abnormal state is prompted;
[0073] If the current time is not abnormal, the operation of matching the current time with the time series described by the schedule variables is entered.
[0074] S2. Match the current time with the time series described by the schedule variables.
[0075] S3a. If the time series does not match the current time, the default value is output and an abnormal state is prompted.
[0076] S3b. If the time sequence matches the current time, determine whether the current time meets the special time trigger determination condition.
[0077] S4a. When the special time trigger judgment is met, the special event output is executed and the normal state is prompted.
[0078] S4b: When the special time trigger determination is not satisfied, it is determined whether the current time satisfies the general time trigger determination.
[0079] S5a: When the general time trigger judgment is met, general event output is executed and a normal state is prompted.
[0080] S5b: When the general time trigger judgment is not met, the default value is output and the normal state is prompted.
[0081] Furthermore, the design of schedule variables considers supporting multiple time series types. Schedule variables are nested structures. Schedule variables include schedule effective time, periodic events, special events and default values.
[0082] Furthermore, the schedule effective time includes the effective start time and the effective end time; the periodic event includes the periodic event start time, the periodic event end time and the signal output value after the periodic event is successfully judged; the special event includes the special event start time, the special event end time and the signal output value after the special event is successfully judged.
[0083] The schedule variables are detailed in the following table:
[0084] Table 1: struct timetable type
[0085] member type illustrate groupname
[32] unsigned char Rule Aliases effect_scope struct DateRange See Table 2 for the effective time of the schedule. weeklytask[7] struct TimeValue See Table 3 for things to do in a 7-day cycle. accident struct SpecialEvent Special events, see Table 4 default_value float Default output value when the judgment fails
[0086] Table 2: struct DateRange type
[0087] member type illustrate begin_time int Start time, UNIX timestamp end_time int End time, UNIX timestamp
[0088] Table 3: struct TimeValue type
[0089] member type illustrate start_action_time int What time does it start? end_action_time int What time does it end? output float Signal output value after successful judgment
[0090] Table 4: struct SpecialEvent type
[0091]
[0092] In specific examples, such as the custom switch lights and start and stop ventilation system scenarios commonly seen in building automation. On regular working days (Monday to Friday), the lights are turned on at 8 am and turned off at 5 pm. The lights are not turned on on weekends (Saturday and Sunday). Any day of the week is periodic, and this type of periodic event is determined by general events. When a non-periodic event occurs, such as a smoke alarm that occurs accidentally one night (during the lights-off period), the PLC will prioritize turning on the lights as a special event to facilitate on-site processing by personnel. Holidays are also a scenario suitable for special event applications. Holidays are neither accidental nor sudden, but they are fixed and dispersed within a one-year cycle and can be foreseen in advance. They can also be preset using the time scheduling function.
[0093] like Figure 4 As shown, the present invention also provides a PLC control system that realizes the time scheduling function, including: timetable variables, a time scheduling function block and a control business logic block; the time scheduling function block is used to parse the received timetable variables and output a corresponding signal to the control business logic block after meeting the preset trigger conditions.
[0094] The core of the present invention is to design a new data type (timetable variable) and time scheduling function block for PLC configuration programming. These two programming elements are finally set in the PLC logic control program and run with the control task.
[0095] Furthermore, the schedule variables include the schedule effective time, periodic events, special events and default values; the schedule effective time includes the effective start time and the effective end time; the periodic events include the periodic event start time, the periodic event end time and the signal output value after the periodic event is successfully judged; the special events include the special event start time, the special event end time and the signal output value after the special event is successfully judged.
[0096] Furthermore, the time scheduling function block includes:
[0097] The time acquisition module is used to obtain the current time of the PLC control system.
[0098] The time matching module is used to match the current time with the time sequence described by the schedule variable; if the time sequence does not match the current time, the default value is output to the control business logic block and an abnormal state is prompted; if the time sequence matches the current time, it is determined whether the current time meets the special time trigger judgment condition.
[0099] The special time judgment module is used to execute special event output to the control business logic block and prompt the normal state when the special time trigger judgment is met; it is used to judge whether the current time meets the general time trigger judgment when the special time trigger judgment is not met.
[0100] The general time judgment module is used to execute general event output to the business control logic block and prompt the normal state when the general time trigger judgment is met; when the general time trigger judgment is not met, output the default value to the business control logic block and prompt the normal state.
[0101] At the same time, the time scheduling module also includes: an abnormality judgment module, which is used to:
[0102] Before obtaining the current time of the PLC control system, the time schedule information is obtained by parsing the timetable variables; judging whether the time schedule information is abnormal; if the time schedule information is abnormal, outputting the default value and prompting the abnormal state; if the time schedule information is not abnormal, entering the operation of obtaining the current time of the PLC control system;
[0103] Also, after obtaining the current moment of the PLC control system, determine whether the current moment of the PLC control system is abnormal; if the current moment is abnormal, output the default value and prompt the abnormal state; if the current moment is not abnormal, enter the operation of matching the current time with the time series described by the schedule variable.
[0104] In addition, an embodiment of the present invention further provides a PLC hardware controller that implements a time scheduling function, on which computer executable instructions are stored, and is characterized in that when the executable instructions are executed by a processor, a PLC control method that implements a time scheduling function as described above is implemented.
[0105] In summary, the present invention provides a PLC control method, system and controller for realizing the time scheduling function. In view of the functional requirements of time scheduling, the present invention designs and defines a special PLC composite variable type, namely a timetable. Through this composite variable, a set of time series can be described, including a start time, an end time, a repetition type, and an output value after a point trigger; and a time scheduling function block is designed and implemented. This function block can accept a timetable variable as input, parse the meaning of the time series therein, output a corresponding signal after meeting the trigger condition, and control the related control business logic block to execute an action.
[0106] like Figure 5As shown in the figure, the main process of the implementation logic based on the time scheduling function block is: first, check the time scheduling information described by the schedule variable to identify abnormal input; then obtain the current system time and determine whether it is abnormal; then compare it with the time series described in the schedule variable respectively. If there is a mismatch, keep the default output; if there is a match, determine the special time and general time in turn according to the configuration of the schedule variable, and execute the corresponding event output and related status indication according to the result.
[0107] Therefore, the present invention proposes a PLC programming solution suitable for executing planned tasks for a PLC automatic control scenario that requires planned scheduling based on a time series.
[0108] Since the system / device described in the above embodiments of the present invention is a system / device used to implement the method of the above embodiments of the present invention, a person skilled in the art can understand the specific structure and deformation of the system / device based on the method described in the above embodiments of the present invention, and thus will not be described in detail here. All systems / devices used in the method of the above embodiments of the present invention belong to the scope of protection of the present invention.
[0109] It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as methods, systems or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0110] The present invention is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems) and computer program products according to the embodiments of the present invention. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions.
[0111] It should be noted that in the claims, any reference numerals placed between brackets shall not be construed as limiting the claims. The word "comprising" does not exclude the presence of components or steps not listed in the claims. The word "a" or "an" preceding a component does not exclude the presence of a plurality of such components. The invention may be implemented by means of hardware comprising several different components and by means of a suitably programmed computer. In the claims enumerating several means, several of these means may be embodied by the same hardware. The use of the words first, second, third, etc., is for convenience of expression only and does not indicate any order. These words may be understood as part of the component name.
[0112] In addition, it should be noted that, in the description of this specification, the description of the terms "one embodiment", "some embodiments", "embodiment", "example", "specific example" or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, unless they are contradictory.
[0113] Although the preferred embodiments of the present invention have been described, those skilled in the art may make other changes and modifications to these embodiments after knowing the basic creative concept. Therefore, the claims should be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present invention.
[0114] Obviously, those skilled in the art can make various modifications and variations to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention should also include these modifications and variations.
Claims
1. A PLC control method for realizing a time scheduling function, characterized in that: The control method is executed at the PLC control end, and the control method includes: Get the current time of the PLC control terminal; Matching the current moment with the time series described by the schedule variables; If the time sequence does not match the current moment, a default value is output and an abnormal state is prompted; If the time sequence matches the current time, determining whether the current time satisfies a special time trigger determination condition; When the special time trigger judgment is met, the special event output is executed and the normal state is prompted; When the special time trigger judgment is not met, it is determined whether the current time satisfies the general time trigger judgment; When the general time trigger judgment is met, the general event output is executed and the normal status is prompted; When the general time trigger judgment is not met, the default value is output and the normal state is prompted; The schedule variable is set in the control program of the PLC control terminal, the schedule variable is a structure nested structure, and the schedule variable includes the schedule effective time, periodic events, special events and default values; The effective time of the schedule includes the effective start time and effective end time; The periodic event includes the start time of the periodic event, the end time of the periodic event and the signal output value after the periodic event is successfully judged; The special event includes the start time of the special event, the end time of the special event and the signal output value after the special event is successfully judged.
2. A PLC control method for realizing a time scheduling function as claimed in claim 1, characterized in that: Before obtaining the current time of the PLC control terminal, it also includes: By parsing the timetable variables, the time scheduling information is obtained; Determining whether the time scheduling information is abnormal; If the time scheduling information is abnormal, output a default value and prompt the abnormal state; If the time scheduling information is not abnormal, the operation of obtaining the current time of the PLC control terminal is performed.
3. A PLC control method for realizing a time scheduling function as claimed in claim 1, characterized in that: After obtaining the current time of the PLC control terminal, it also includes: Determine whether the current time of the acquired PLC control terminal is abnormal; If the current moment is abnormal, a default value is output and an abnormal state is prompted; If the current time is not abnormal, the operation of matching the current time with the time series described by the schedule variable is entered.
4. A PLC control system for realizing time scheduling function, characterized in that: include: Timetable variables, time scheduling function blocks, and control business logic blocks; The time scheduling function block is used to parse the received timetable variables and output corresponding signals to the control business logic block after meeting the preset trigger conditions; The schedule variable is a nested structure, and the schedule variable includes the schedule effective time, periodic events, special events and default values; The effective time of the schedule includes the effective start time and effective end time; The periodic event includes the start time of the periodic event, the end time of the periodic event and the signal output value after the periodic event is successfully judged; The special event includes the start time of the special event, the end time of the special event and the signal output value after the special event is successfully judged; The time scheduling function block includes: Time acquisition module, used to obtain the current time of the PLC control system; A time matching module is used to match the current moment with the time sequence described by the schedule variable; if the time sequence does not match the current moment, output a default value to the control business logic block and prompt an abnormal state; if the time sequence matches the current moment, determine whether the current moment meets the special time trigger determination condition; The special time judgment module is used to execute the special event output to the control business logic block and prompt the normal state when the special time trigger judgment is met; and to judge whether the current moment meets the general time trigger judgment when the special time trigger judgment is not met; The general time judgment module is used to execute general event output to the business control logic block and prompt the normal state when the general time trigger judgment is met; when the general time trigger judgment is not met, output the default value to the business control logic block and prompt the normal state.
5. A PLC control system for realizing time scheduling function as claimed in claim 4, characterized in that: The time scheduling function block also includes: an abnormality judgment module, which is used to: Before obtaining the current time of the PLC control system, the time schedule information is obtained by parsing the timetable variables; judging whether the time schedule information is abnormal; if the time schedule information is abnormal, outputting a default value and prompting the abnormal state; if the time schedule information is not abnormal, entering the operation of obtaining the current time of the PLC control system; as well as, After obtaining the current moment of the PLC control system, determine whether the current moment of the PLC control system is abnormal; if the current moment is abnormal, output a default value and prompt the abnormal state; if the current moment is not abnormal, enter the operation of matching the current moment with the time series described by the schedule variable.
6. A PLC hardware controller for implementing a time scheduling function, on which computer executable instructions are stored, characterized in that: When the executable instructions are executed by the processor, a PLC control method for realizing a time scheduling function as described in any one of claims 1 to 3 is implemented.