Disclosure of Invention
First, the technical problem to be solved
In view of the above-mentioned drawbacks and shortcomings of the prior art, the present invention provides a PLC control method, system and controller for implementing a time scheduling function, which solve the technical problems that the existing control scheme based on time sequence development planning is difficult to ensure operation reliability, has control delay and does not have expansibility.
(II) technical scheme
In order to achieve the above purpose, the main technical scheme adopted by the invention comprises the following steps:
in a first aspect, an embodiment of the present invention provides a PLC control method for implementing a time scheduling function, including:
executing the control method at a PLC control end, wherein the control method comprises the following steps:
acquiring the current time of a PLC control end;
matching the current time with a time sequence described by a schedule variable;
If the time sequence is not matched with the current time, outputting a default value and prompting an abnormal state;
If the time sequence is matched with the current time, judging whether the current time meets a special time triggering judging condition or not;
When the special time triggering judgment is met, special event output is executed and the normal state is prompted;
When the special time trigger judgment is not met, judging whether the current time meets the general time trigger judgment or not;
when the general time trigger judgment is met, executing general event output and prompting a normal state;
when the normal time triggering judgment is not met, outputting a default value and prompting a normal state;
the schedule variable is arranged in a control program of the PLC control end.
Optionally, before the current time of the PLC control end is obtained, the method further includes:
obtaining time scheduling information by analyzing the schedule variable;
Judging whether the time scheduling information is abnormal or not;
If the time scheduling information is abnormal, outputting a default value and prompting an abnormal state;
and if the time scheduling information is not abnormal, entering an operation of acquiring the current moment of the PLC control end.
Optionally, after obtaining the current time of the PLC control terminal, the method further includes:
Judging whether the obtained current moment of the PLC control end is abnormal or not;
if the current moment is abnormal, outputting a default value and prompting an abnormal state;
if the current time is not abnormal, an operation of matching the current time with the time sequence described by the schedule variable is entered.
Optionally, the schedule variables include schedule validation time, periodic events, special events, and default values.
Alternatively, the process may be carried out in a single-stage,
The schedule validation time includes a validation start time and a validation end time;
The periodic event comprises a periodic event starting time, a periodic event ending time and a signal output value after the periodic event is judged to be successful;
The special event comprises a special event starting time, a special event ending time and a signal output value after the special event is judged to be successful.
In a second aspect, the embodiment of the invention also provides a PLC control system for realizing the time scheduling function, which comprises a time schedule variable, a time scheduling functional block and a control service logic block;
The time scheduling functional block is used for analyzing the received schedule variable, and outputting corresponding signals to the control service logic block after the received schedule variable accords with a preset trigger condition.
Optionally, the schedule variable includes a schedule validation time, a periodic event, a special event, and a default value;
The schedule validation time includes a validation start time and a validation end time;
The periodic event comprises a periodic event starting time, a periodic event ending time and a signal output value after the periodic event is judged to be successful;
The special event comprises a special event starting time, a special event ending time and a signal output value after the special event is judged to be successful.
Optionally, the time scheduling function block includes:
the time acquisition module is used for acquiring the current time of the PLC control system;
The time matching module is used for matching the current time with a time sequence described by a time schedule variable, outputting a default value to the control service logic block and prompting an abnormal state if the time sequence is not matched with the current time, and judging whether the current time meets a special time triggering judging condition or not if the time sequence is matched with the current time;
the special time judging module is used for executing special event output to the control service logic block and prompting a normal state when the special time trigger judgment is met;
And the general time judging module is used for executing general event output to the service control logic block and prompting the normal state when the general time trigger judgment is met, and outputting a default value to the service control logic block and prompting the normal state when the general time trigger judgment is not met.
Optionally, the time scheduling module further comprises an abnormality judging module for:
before the current moment of the PLC control system is obtained, time schedule information is obtained by analyzing a schedule variable, whether the time schedule information is abnormal or not is judged, a default value is output and an abnormal state is prompted if the time schedule information is abnormal, and if the time schedule information is not abnormal, the operation of obtaining the current moment of the PLC control system is entered;
And
After the current moment of the PLC control system is obtained, judging whether the obtained current moment of the PLC control system is abnormal, outputting a default value and prompting an abnormal state if the current moment is abnormal, and entering an operation of matching the current time with a time sequence described by a schedule variable if the current moment is not abnormal.
In a third aspect, an embodiment of the present invention provides a PLC hardware controller for implementing a time scheduling function, where computer executable instructions are stored, where the executable instructions, when executed by a processor, implement a PLC control method for implementing a time scheduling function as described above.
(III) beneficial effects
The invention has the beneficial effects that the time schedule variable is creatively used for defining the time rule and the output event, and the time scheduling functional block is used for executing to obtain the output, so that the output is programmed together with the original control business logic of the PLC end. Meanwhile, engineering personnel can program related services only at the PLC end, various plan control strategies can be obtained by copying and pasting added schedule variables and time scheduling functional blocks, the number scale can be easily large, the number scale is limited only by the program capacity of the PLC, software personnel are not required to put into development work, and time and cost are greatly reduced. Because the scheduling is not dependent on the analysis and the issuing of the upper computer, even if the network is disconnected, the PLC can still be executed off-line, and the control delay is greatly reduced.
Detailed Description
The invention will be better explained for understanding by referring to the following detailed description of the embodiments in conjunction with the accompanying drawings.
As shown in FIG. 1, the PLC control method for realizing the time scheduling function comprises the steps of obtaining the current time of a PLC control system, matching the current time with a time sequence described by a time table variable, outputting a default value and prompting an abnormal state if the time sequence is not matched with the current time, judging whether the current time meets a special time trigger judgment condition or not if the time sequence is matched with the current time, executing special event output and prompting a normal state if the special time trigger judgment is met, judging whether the current time meets a general time trigger judgment if the special time trigger judgment is not met, executing general event output and prompting the normal state if the general time trigger judgment is not met, and outputting the default value and prompting the abnormal state if the general time trigger judgment is not met, wherein the time table variable is arranged in a control program of the PLC control system.
The invention creatively uses the time table variable to define the time rule and the output event, uses the time scheduling function block to execute and obtain the output, and is programmed with the original control business logic of the PLC end in a unified way. Meanwhile, engineering personnel can program related services only at the PLC end, various plan control strategies can be obtained by copying and pasting added schedule variables and time scheduling functional blocks, the number scale can be easily large, the number scale is limited only by the program capacity of the PLC, software personnel are not required to put into development work, and time and cost are greatly reduced. Because the scheduling is not dependent on the analysis and the issuing of the upper computer, even if the network is disconnected, the PLC can still be executed off-line, and the control delay is greatly reduced.
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. While exemplary embodiments of the present invention are shown in the drawings, it should be understood that the present invention may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the invention to those skilled in the art.
Specifically, an embodiment of the present invention provides a PLC control method for implementing a time scheduling function, including:
s1, acquiring the current time of the PLC control system.
As shown in fig. 2, before acquiring the current time of the PLC control system, the method further includes:
obtaining time scheduling information by analyzing the schedule variable;
Judging whether the time scheduling information is abnormal or not;
If the time scheduling information is abnormal, outputting a default value and prompting an abnormal state;
if the time scheduling information is not abnormal, the operation of acquiring the current moment of the PLC control system is entered.
As shown in fig. 3, after obtaining the current time of the PLC control system, the method further includes:
Judging whether the obtained current moment of the PLC control system is abnormal or not;
if the current moment is abnormal, outputting a default value and prompting an abnormal state;
If the current time is not abnormal, an operation of matching the current time with the time series described by the schedule variable is entered.
S2, matching the current time with a time sequence described by a time schedule variable.
And S3a, if the time sequence is not matched with the current time, outputting a default value and prompting an abnormal state.
And S3b, if the time sequence is matched with the current time, judging whether the current time meets a special time triggering judging condition.
And S4a, when the special time triggering judgment is met, executing special event output and prompting a normal state.
And S4b, judging whether the current time meets the general time trigger judgment or not when the special time trigger judgment is not met.
And S5a, when the normal time triggering judgment is met, executing normal event output and prompting a normal state.
And S5b, outputting a default value and prompting a normal state when the normal time triggering judgment is not met.
Further, the design of the schedule variable, which is a structure nested structure, is considered to support various time sequence types, wherein the schedule variable comprises schedule effective time, periodic event, special event and default value.
Further, the schedule effective time comprises effective starting time and effective ending time, the periodic event comprises periodic event starting time, periodic event ending time and signal output value after the periodic event is judged to be successful, and the special event comprises special event starting time, special event ending time and signal output value after the special event is judged to be successful.
The schedule variables are detailed in the following table:
TABLE one struct timetable type
Member(s) |
Type(s) |
Description of the invention |
groupname[32] |
unsigned char |
Rule alias |
effect_scope |
struct DateRange |
Time table effective time, see Table II |
weeklytask[7] |
struct TimeValue |
7 Days a week is the matter to be done periodically, see Table three |
accident |
struct SpecialEvent |
Special events, see Table IV |
default_value |
float |
Determining a default output value when a failure occurs |
Type struct DateRange of Table II
Member(s) |
Type(s) |
Description of the invention |
begin_time |
int |
Start time, UNIX timestamp |
end_time |
int |
End time, UNIX timestamp |
TABLE III struct TimeValue type
Member(s) |
Type(s) |
Description of the invention |
start_action_time |
int |
Beginning at several hours, minutes and seconds |
end_action_time |
int |
End of minutes and seconds |
output |
float |
Signal output value after successful judgment |
TABLE IV struct SpecialEvent type
In a specific example, a ventilation system scenario is started and stopped, as is common in building automation for custom switch lights. On the regular workday (monday to friday), the lamp was turned on 8 a.m. and turned off 17 p.m.. The rest day (Saturday of Saturday) is not lighted, and any day of the week is periodic, and the periodic event is determined by a general event. When the aperiodic event occurs, such as smoke alarm happens at night (during the period of turning off the lamp), the PLC preferably performs the operation of turning on the lamp according to the special event at the moment, so that personnel can conveniently process the scene. Holidays are also a scenario suitable for special event applications, which are neither occasional nor bursty, but are fixed and scattered over a period of one year and can be foreseen in advance, and can also be preset with time scheduling functions.
As shown in fig. 4, the invention further provides a PLC control system for implementing a time scheduling function, which includes a schedule variable, a time scheduling function block and a control service logic block, wherein the time scheduling function block is used for resolving the received schedule variable, and outputting a corresponding signal to the control service logic block after meeting a preset trigger condition.
The core of the invention is that a novel data type (schedule variable) and time scheduling functional block are designed for the configuration programming of the PLC, and the 2 programming elements are finally arranged in a PLC logic control program and run along with control tasks.
Further, the schedule variable comprises schedule effective time, periodic event, special event and default value, the schedule effective time comprises effective start time and effective end time, the periodic event comprises periodic event start time, periodic event end time and signal output value after success of judging the periodic event, and the special event comprises special event start time, special event end time and signal output value after success of judging the special event.
Still further, the time scheduling function block includes:
And the time acquisition module is used for acquiring the current time of the PLC control system.
The time matching module is used for matching the current time with the time sequence described by the schedule variable, outputting a default value to the control service logic block and prompting an abnormal state if the time sequence is not matched with the current time, and judging whether the current time meets a special time triggering judging condition or not if the time sequence is matched with the current time.
The special time judging module is used for executing special event output to the control service logic block and prompting a normal state when the special time trigger judgment is met, and judging whether the current time meets the general time trigger judgment or not when the special time trigger judgment is not met.
And the general time judging module is used for executing general event output to the service control logic block and prompting the normal state when the general time trigger judgment is met, and outputting a default value to the service control logic block and prompting the normal state when the general time trigger judgment is not met.
Meanwhile, the time scheduling module further comprises an abnormality judging module for:
Before the current moment of the PLC control system is obtained, time schedule information is obtained by analyzing time schedule variables, whether the time schedule information is abnormal or not is judged, if the time schedule information is abnormal, a default value is output and an abnormal state is prompted, and if the time schedule information is not abnormal, the operation of obtaining the current moment of the PLC control system is entered;
And after the current moment of the PLC control system is obtained, judging whether the obtained current moment of the PLC control system is abnormal, outputting a default value and prompting an abnormal state if the current moment is abnormal, and entering an operation of matching the current time with a time sequence described by a schedule variable if the current moment is not abnormal.
In addition, the embodiment of the invention also provides a PLC hardware controller for realizing the time scheduling function, which is stored with computer executable instructions, and is characterized in that the executable instructions realize the PLC control method for realizing the time scheduling function when being executed by a processor.
In summary, the invention provides a method, a system and a controller for controlling a PLC for implementing a time scheduling function, and the invention designs and defines a special type of a PLC composite variable of a time table according to the functional requirement of the time scheduling, and by using the composite variable, a group of time sequences including a start time, an end time, a repetition type and an output value after point triggering can be described; the time scheduling functional block is designed and realized, the functional block can accept a time schedule variable as input, analyzes the time sequence meaning in the time schedule variable, outputs corresponding signals after meeting the triggering condition, and controls the related control service logic block to execute actions.
As shown in FIG. 5, the main logic flow of the implementation logic based on the time scheduling function block is that firstly, the time scheduling information described by the time schedule variable is checked, abnormal input is identified, then the current time of the system is acquired and whether the system is abnormal is judged, then, the current time is respectively compared with the time sequence described by the time schedule variable, if the current time is not matched with the time sequence described by the time schedule variable, default output is kept, if the current time is not matched with the time sequence, the judgment of the special time and the general time is sequentially carried out according to the configuration of the time schedule variable, and corresponding event output and related state indication are executed according to the result.
Therefore, the invention provides a PLC programming scheme suitable for executing the planned tasks aiming at the PLC automatic control scene requiring the planned scheduling based on the time sequence.
Since the system/device described in the foregoing embodiments of the present invention is a system/device used for implementing the method of the foregoing embodiments of the present invention, those skilled in the art will be able to understand the specific structure and modification of the system/device based on the method of the foregoing embodiments of the present invention, and thus will not be described in detail herein. All systems/devices used in the methods of the above embodiments of the present invention are within the scope of the present invention.
It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions.
It should be noted that in the claims, any reference signs placed between parentheses shall not be construed as limiting the claim. The word "comprising" does not exclude the presence of elements or steps not listed in a claim. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The invention may be implemented by means of hardware comprising several distinct elements, and by means of a suitably programmed computer. In the claims enumerating several means, several of these means may be embodied by one and the same item of hardware. The use of the terms first, second, third, etc. are for convenience of description only and do not denote any order. These terms may be understood as part of the component name.
Furthermore, it should be noted that in the description of the present specification, the terms "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., refer to a specific feature, structure, material, or characteristic described in connection with the embodiment or example being included in at least one embodiment or example of the present invention. In this specification, schematic representations of the above terms are not necessarily directed to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Furthermore, the different embodiments or examples described in this specification and the features of the different embodiments or examples may be combined and combined by those skilled in the art without contradiction.
While preferred embodiments of the present invention have been described, additional variations and modifications in those embodiments may occur to those skilled in the art upon learning the basic inventive concepts. Therefore, the appended claims should be construed to include preferred embodiments and all such variations and modifications as fall within the scope of the invention.
It will be apparent to those skilled in the art that various modifications and variations can be made to the present invention without departing from the spirit or scope of the invention. Thus, the present invention should also include such modifications and variations provided that they come within the scope of the following claims and their equivalents.