Programmable logic controller and method of controlling the same

By determining whether the acquired values ​​of the event-generated signals are equal in the PLC, the repeated output of control signals during the event's duration is avoided, thus solving the problem of wasted PLC resources and achieving efficient resource utilization.

CN118625728BActive Publication Date: 2026-04-07HANS LASER TECH IND GRP CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-29
Publication Date
2026-04-07

AI Technical Summary

Technical Problem

The PLC continuously outputs control signals to the execution end during the duration of the event-generated signal, resulting in wasted resources.

Method used

In the first scan cycle after an event is detected, a value change signal is generated. Starting from the second scan cycle, it is determined whether the value collected in the current scan cycle is equal to the value collected in the previous scan cycle. If they are equal, no more value change signals are generated to avoid duplicate output.

Benefits of technology

It saves controller resources and improves resource utilization efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118625728B_ABST
    Figure CN118625728B_ABST
Patent Text Reader

Abstract

This invention provides a programmable logic controller and its control method. The method includes: generating a value change signal in the first scan cycle when a sampled value of an event generation signal is detected; outputting the value change signal to an execution terminal; starting from the second scan cycle when the sampled value of the event generation signal is detected, determining whether the sampled value of the current scan cycle is equal to the sampled value of the previous scan cycle; and if the sampled value of the next scan cycle is equal to the sampled value of the previous scan cycle, then not generating a value change signal. It can be seen that the control method of the controller in this application can save controller resources.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of automatic control technology, and more specifically, relates to a programmable logic controller and its control method. Background Technology

[0002] A Programmable Logic Controller (PLC) is a digital logic controller used for real-time automation control, widely applied in current industrial control fields. PLCs operate using a cycle-scanning method. Cycle-scanning means that after the PLC is powered on, it repeatedly scans the PLC system; that is, under the monitoring of the system program, it queries, judges, and executes various events within the PLC system in each cycle. The frequency of cycle-scanning varies depending on the response speed requirements of the actuator.

[0003] In a PLC, the input of an event generation signal needs to last for a period of time. When the PLC outputs the control signal corresponding to the event generation signal to the execution end, the execution end also needs to receive the control signal and execute the event corresponding to the control signal for a period of time. For example, when the input time of the event generation signal is longer than one scan cycle of the PLC, the PLC will scan the event generation signal in each scan cycle, and after scanning the event generation signal in each scan cycle, it will generate the corresponding control signal and output it to the execution end. That is, during the input time of the event generation signal, the PLC will output a control signal to the execution end in each scan cycle. However, after the PLC sends a control signal to the execution end in the first scan cycle, the execution end will not receive a new control signal until the corresponding event is completed. Therefore, if the PLC sends a control signal to the execution end in every scan cycle, it will cause a waste of resources. Summary of the Invention

[0004] This application aims to provide a programmable logic controller and a control method thereof to save controller resources.

[0005] The technical solution adopted in this application is a control method for a programmable logic controller, the method comprising:

[0006] A value change signal is generated in the first scan cycle when the acquired value of the event-generating signal is detected.

[0007] The value change signal is output to the execution end;

[0008] Starting from the second scan cycle after scanning to the acquisition value of the signal generated by the event, determine whether the acquisition value of the current scan cycle is equal to the acquisition value of the previous scan cycle; and

[0009] If the value acquired in the next scan cycle is equal to the value acquired in the previous scan cycle, no value change signal will be generated.

[0010] As can be seen, in this application, a value change signal is generated in the first scan cycle when the acquired value of the event generation signal is scanned. This value change signal is used to output to the execution end, so that the execution end can execute the pre-set event according to the value change signal. Starting from the second scan cycle when the acquired value of the event generation signal is scanned, it is determined whether the acquired value of the current scan cycle is equal to the acquired value of the previous scan cycle. If the acquired values ​​are not equal, the value change signal is no longer generated. In this way, it is not necessary to output the value change signal to the execution end. This method can avoid continuously outputting the value change signal to the execution end during the continuous phase of the event generation signal, which can save the controller resources.

[0011] Furthermore, the control method of the programmable logic controller in this application can be applied to the input values ​​of event change signals for both Boolean and numerical variables. Specifically, the Boolean variable's value during the scan cycle is 0 or 1, while the numerical variable's value during the scan cycle can be a real number, such as -10, -2.5, 3, or 8.5.

[0012] Optionally, the method further includes:

[0013] Define the baseline acquisition value in the first scan cycle after initialization;

[0014] Starting from the second scan cycle, determine whether the acquired value in the current scan cycle is equal to the acquired value in the previous scan cycle;

[0015] If the value acquired in the current scan cycle is equal to the value acquired in the previous scan cycle, then maintain the initialization state; and

[0016] If the value collected in the current scan cycle is not equal to the value collected in the previous scan cycle, it is determined that an event has been generated and a value change signal is generated in the current scan cycle.

[0017] Optionally, defining the reference acquisition value in the first scan cycle after initialization includes:

[0018] In the first scan cycle after initialization, the first register and the second register are assigned initial acquisition values;

[0019] At the start of the second scan cycle after initialization, the acquired value of the current scan cycle is stored in the second register; and

[0020] After determining whether the acquired value in the current scan cycle is equal to the acquired value in the previous scan cycle, the acquired value in the second register is transferred to the first register.

[0021] Optionally, the first relay generates a first scan cycle signal after initialization and assigns initial acquisition values ​​to the first register and the second register. The first relay is in the ON state during the first scan cycle and in the OFF state at the beginning of the second scan cycle.

[0022] The first relay is an M8002 relay.

[0023] Optionally, the second relay is used to perform an AND operation with the reference acquisition value during the first scan cycle after initialization, wherein the second relay is in the off state during the first scan cycle and in the on state at the beginning of the second scan cycle;

[0024] The second relay is an M8003 relay.

[0025] Optionally, it also includes:

[0026] At the start of the second scan cycle after initialization, within one scan cycle, the acquired value of the current scan cycle is stored in the second register, and it is determined whether the acquired value in the second register is equal to the acquired value in the first register. After the determination is completed, the acquired value in the second register is transferred to the first register, overwriting the acquired value in the first register.

[0027] Optionally, it also includes:

[0028] An initialization signal is defined in the first scan cycle after initialization, wherein the initialization signal keeps the controller in an initialized state.

[0029] Optionally, after generating the value change signal during the scanning period of the acquired value of the event generation signal, the method further includes:

[0030] Locking the value change signal; and

[0031] The locked value change signal is output to the execution end.

[0032] Optionally, the step of outputting the locked value change signal to the execution end further includes:

[0033] After receiving feedback that the execution event has been completed, the locked value change signal is then output to the execution end.

[0034] A programmable logic controller includes a processor and a memory, the memory being used to store program instructions, and the processor being used to invoke the program instructions to execute the method. Attached Figure Description

[0035] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0036] Figure 1 This is one of the flowcharts illustrating the control method of the programmable logic controller in the embodiments of this application;

[0037] Figure 2 This is a second schematic flowchart of the control method of the programmable logic controller in the embodiments of this application;

[0038] Figure 3 This is the third flowchart illustrating the control method of the programmable logic controller in the embodiments of this application;

[0039] Figure 4 This is the fourth flowchart illustrating the control method of the programmable logic controller in the embodiments of this application;

[0040] Figure 5 This is a schematic diagram of the structure of the programmable logic controller in the embodiments of this application. Specific Implementation

[0041] To make the technical problems, technical solutions, and beneficial effects to be solved by this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and are not intended to limit the scope of this application.

[0042] It should be noted that when a metastructure is said to be "fixed to" or "set to" another metastructure, it can be directly on or indirectly on that other metastructure. When a metastructure is said to be "connected to" another metastructure, it can be directly connected to or indirectly connected to that other metastructure.

[0043] It should be understood that the terms "length", "width", "upper", "lower", "front", "rear", "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 metastructure 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.

[0044] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the descriptions of some applications, "multiple" means two or more, unless otherwise explicitly specified.

[0045] A Programmable Logic Controller (PLC) is a digital logic controller used for real-time automation control. PLCs operate using a cycle-scanning method. Cycle-scanning means that after the PLC is powered on, it repeatedly scans the PLC system. Under the monitoring of the system program, each cycle queries, judges, and executes various events within the PLC system to determine if any event signals have been generated. It can promptly convert these event signals into value-changing signals and output them to the actuator, enabling the actuator to respond promptly. Therefore, the frequency or speed of the PLC's cycle-scanning varies depending on the response speed requirements of the actuator. The higher the response speed requirement of the actuator, the faster the PLC's cycle-scanning frequency or speed, ensuring that the PLC can promptly scan for event signals.

[0046] However, in a PLC, the input of an event-generating signal needs to last for a period of time. When the PLC outputs the corresponding control signal (value change signal) to the execution end, the execution end also needs to receive the control signal and execute the event corresponding to the control signal for a period of time. For example, when the input time of the event-generating signal is longer than one scan cycle of the PLC, the PLC will scan the event-generating signal in each scan cycle, and after scanning the event-generating signal in each scan cycle, it will generate the corresponding control signal and output it to the execution end. That is, during the input time of the event-generating signal, the PLC will output a control signal to the execution end in each scan cycle. However, after the PLC sends a control signal to the execution end in the first scan cycle, the execution end will not receive a new control signal until the corresponding event has been executed. Therefore, if the PLC sends a control signal to the execution end in every scan cycle, it will cause a waste of resources.

[0047] For example, the input time for an event signal needs to last 30ms. The scanning speed of each scan cycle of the PLC is 5ms. The time required for the execution end to receive the signal and complete the event execution is 6000ms. Assuming that the PLC scans the event signal the instant it is input and generates a corresponding control signal output to the execution end, it can be understood that it takes 6000ms for the execution end to receive the signal and complete the event execution. During this process, the PLC can scan the event signal once every 5ms, and can scan it 6 times before the event signal disappears. Therefore, the PLC will send 6 control signals to the execution end. However, after the PLC sends the control signal to the execution end for the first time, the execution end will no longer receive the subsequent 5 control signals. At this time, the PLC continuously sends control signals to the execution end, which wastes resources.

[0048] Therefore, this application provides a control method for a programmable logic controller that can avoid sending control signals to the execution end in every scan cycle during the duration of an event.

[0049] like Figure 1 As shown, a control method for a programmable logic controller includes the following steps:

[0050] Step S110: Generate a value change signal in the first scan cycle of the acquired value of the event-generated signal.

[0051] Specifically, the event generation signal refers to the trigger signal generated when the execution end needs to execute a certain event.

[0052] Step S120: Output the value change signal to the execution end.

[0053] Specifically, after the value change signal is output to the execution end, the execution end can trigger a pre-set event based on the received value change signal.

[0054] It should be noted that outputting the value change signal to the execution end does not mean that the value change signal needs to be output to the execution end immediately after it is generated. In some implementations, the value change signal can be output to the execution end only after receiving the feedback signal from the execution end.

[0055] Step S130: Starting from the second scan cycle from the acquisition value of the event generation signal, determine whether the acquisition value of the current scan cycle is equal to the acquisition value of the previous scan cycle.

[0056] Step S140: If the acquisition value of the next scan cycle is equal to the acquisition value of the previous scan cycle, no value change signal is generated.

[0057] It is understandable that when a value change signal is generated during the scan cycle, the value change signal needs to be sent to the execution end. Therefore, if the value collected in the next scan cycle is equal to the value collected in the previous scan cycle, no value change signal is generated. If no value change signal is generated, there is no need to output a signal to the execution end.

[0058] For example, after an event signal is generated, the controller will continuously input the acquisition value 1 during the duration of the same event signal. Each scan cycle can scan an acquisition value of 1. Therefore, a value change signal is generated in the first scan cycle in which the acquisition value of 1 is scanned, and this value change signal can be transmitted to the execution end. Then, starting from the second scan cycle in which the acquisition value of the event signal is scanned, it is determined whether the acquisition value of the current scan cycle is equal to the acquisition value of the previous scan cycle. If the acquisition value scanned in the current scan cycle is 1 again, it is determined that the acquisition value of the current scan cycle is equal to the acquisition value of the previous scan cycle. The acquisition value being equal means that the current scan cycle is still in the continuous stage of the event signal generation, which means that there is no need to output a value change signal to the execution end during this stage. Therefore, at this time, there is no need to generate a value change signal in the current scan cycle.

[0059] As can be seen, in this application, a value change signal is generated in the first scan cycle when the acquired value of the event generation signal is scanned. This value change signal is used to output to the execution end, so that the execution end can execute the pre-set event according to the value change signal. Starting from the second scan cycle when the acquired value of the event generation signal is scanned, it is determined whether the acquired value of the current scan cycle is equal to the acquired value of the previous scan cycle. If the acquired values ​​are not equal, the value change signal is no longer generated. In this way, it is not necessary to output the value change signal to the execution end. This method can avoid continuously outputting the value change signal to the execution end during the continuous phase of the event generation signal, which can save the controller resources.

[0060] Furthermore, the control method of the programmable logic controller in this application can be applied to the input values ​​of event change signals for both Boolean and numerical variables. Specifically, the Boolean variable's value during the scan cycle is 0 or 1, while the numerical variable's value during the scan cycle can be a real number, such as -10, -2.5, 3, or 8.5.

[0061] Furthermore, in some implementations, see [reference] Figure 2 The control method may also include the following steps:

[0062] Step S210: Define the reference acquisition value in the first scan cycle after initialization.

[0063] Specifically, the first scan cycle after initialization can refer to the first scan cycle after the controller is powered on, during which a reference acquisition value is defined or assigned.

[0064] Additionally, it is understandable that the baseline acquisition value is the same as the acquisition value during the scan cycle when no event generates a signal.

[0065] Step S220: Starting from the second scan cycle, determine whether the acquired value of the current scan cycle is equal to the acquired value of the previous scan cycle.

[0066] It is understandable that the acquisition value of the second scan cycle after initialization is compared with the acquisition value of the previous scan cycle, which is the baseline acquisition value defined in the first scan cycle after initialization. Therefore, defining the baseline acquisition value in the first scan cycle makes it convenient for the acquisition value of the second scan cycle to have a reference for comparison.

[0067] Step S230: If the acquisition value of the current scan cycle is equal to the acquisition value of the previous scan cycle, then maintain the initialization state; if the acquisition value of the current scan cycle is not equal to the acquisition value of the previous scan cycle, then determine that an event generation signal input has been generated, and generate a value change signal in the current scan cycle.

[0068] For example, if the baseline acquisition value is 0, and no event is generated as a signal input, the acquisition value of the current scan cycle is also 0. At this time, the acquisition value of 0 in the current scan cycle is equal to the acquisition value of 0 in the previous scan cycle, so the initialization state is maintained.

[0069] The baseline acquisition value is 0. When an event signal is generated, the acquisition value of the current scan cycle is also 100. At this time, the acquisition value of 100 in the current scan cycle is not equal to the acquisition value of 0 in the previous scan cycle. Therefore, it is determined that an event signal has been generated and a value change signal is generated in the current scan cycle.

[0070] Further, see Figure 3 In the first scan cycle after initialization, a baseline acquisition value is defined, which may include:

[0071] Step S211: In the first scan cycle after initialization, assign initial acquisition values ​​to the first register and the second register.

[0072] For example, in the first scan cycle after initialization, the first register and the second register can be assigned an initial acquisition value of 0 respectively.

[0073] Step S212: In the second scan cycle after initialization, store the acquisition value of the current scan cycle in the second register.

[0074] For example, when no event generates a signal input, the acquisition value of the current scan cycle is 0. At this time, the acquisition value 0 can be stored in the first register.

[0075] When an event generates a signal input, the acquisition value of the current scan cycle is 100. At this time, the acquisition value of 100 can be stored in the first register.

[0076] Step S213: After determining whether the acquired value of the current scan cycle is equal to the acquired value of the previous scan cycle, the acquired value in the current second register is transferred to the first register.

[0077] It is understandable that after determining whether the acquired value of the current scan cycle is equal to the acquired value of the previous scan cycle, the acquired value of the current scan cycle is transferred to the first register. In this way, the second register will have space to store the acquired value scanned in the next scan cycle.

[0078] In some implementations, at the start of the second scan cycle after initialization, the acquired value of the current scan cycle is stored in a second register within one scan cycle. It is then determined whether the acquired value in the second register is equal to the acquired value in the first register. If the determination is successful, the acquired value in the second register is transferred to the first register, overwriting the value in the first register. This method ensures that the scanned acquired value can be stored in the second register in a timely manner in the next scan cycle, avoiding signal leakage.

[0079] Furthermore, in some embodiments, the first relay can be used to generate the first scan cycle signal after the controller is initialized, and to assign initial acquisition values ​​to the first register and the second register. The first relay is in the on state during the first scan cycle and in the off state at the beginning of the second scan cycle.

[0080] For example, the first relay could be an M8002 relay.

[0081] In some implementations, the second relay can be used to perform an AND operation with the reference acquisition value during the first scan cycle after initialization, wherein the second relay is in an off state during the first scan cycle and in an on state at the beginning of the second scan cycle.

[0082] For example, the second relay is an M8003 relay.

[0083] It is understandable that a reference acquisition value needs to be defined in the first scan cycle. During the process of defining the reference acquisition value, the state of the system may change. In this case, by performing an AND operation between the second relay, which is in the off state in the first scan cycle and in the on state at the beginning of the second scan cycle, and the reference acquisition value, system chaos can be avoided when defining the reference acquisition value.

[0084] In addition, since the second relay is in the off state (i.e., its value is 0) during the first scan cycle, when the second relay is performing a bitwise AND operation with the reference acquisition value during the first scan cycle, the result will be 0 regardless of the reference acquisition value. Therefore, it will not cause an invalid and erroneous result due to the value change signal when defining the reference acquisition value during the first scan cycle.

[0085] Furthermore, in some implementations, an initialization signal is defined in the first scan cycle after initialization, wherein the initialization signal keeps the controller in an initialized state.

[0086] For example, in the first scan cycle, the initialization signal is defined as 0. When no event generation signal is detected, the initialization signal of 0 enables the controller to maintain its initial state. This method can prevent the controller from continuing to execute events that occurred before the power-off after power-on, and it can also maintain the initial state when no event generation signal is detected, thus avoiding controller malfunction.

[0087] See Figure 4 In some embodiments, after generating a value change signal in the first scan cycle of scanning the acquired value of the event generation signal, step S110 may further include:

[0088] Step S111: Lock the value change signal.

[0089] Step S112: Output the locked value change signal to the execution end.

[0090] In other words, in some implementations, after the value change signal is generated, the value change signal is first locked, and then the value change signal is output to the execution end.

[0091] Understandably, in some implementations, when the execution end has not completed the event corresponding to the previous value change signal, the execution end will no longer receive new value change signals. At this time, the newly generated value change signal is locked and put into a "queue" state to avoid signal loss caused by the execution end not accepting new value change signals but still sending value change signals to it.

[0092] Step S112, outputting the locked value change signal to the execution end, may further include:

[0093] After receiving feedback that the execution event has been completed from the execution end, the locked value change signal is then output to the execution end.

[0094] In other words, once the controller receives feedback from the execution end (i.e., the execution end can receive new value change signals), it outputs the value change signal to the execution end.

[0095] In addition, see Figure 5 This application also provides a programmable logic controller, including a processor and a memory, wherein the memory is used to store program instructions and the processor is used to call the program instructions to execute the methods described above.

[0096] The above are merely preferred embodiments of this application and are not intended to limit this application. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of some applications should be included within the protection scope of some applications.

Claims

1. A control method for a programmable logic controller, characterized in that, The method includes: Define the baseline acquisition value in the first scan cycle after initialization, and assign the initial acquisition value to the first register and the second register; A value change signal is generated in the first scan cycle when the acquired value of the event-generating signal is detected. The value change signal is output to the execution end; Starting from the second scan cycle after scanning the acquired value of the signal generated by the event, determine whether the acquired value of the current scan cycle is equal to the acquired value of the previous scan cycle; If the value acquired in the next scan cycle is equal to the value acquired in the previous scan cycle, no value change signal will be generated. At the start of the second scan cycle after initialization, the acquired value of the current scan cycle is stored in the second register; and After determining whether the acquired value in the current scan cycle is equal to the acquired value in the previous scan cycle, the acquired value in the second register is transferred to the first register.

2. The control method for a programmable logic controller as described in claim 1, characterized in that, The method further includes: Starting from the second scan cycle, determine whether the acquired value in the current scan cycle is equal to the acquired value in the previous scan cycle; If the value acquired in the current scan cycle is equal to the value acquired in the previous scan cycle, then maintain the initialization state; and If the value collected in the current scan cycle is not equal to the value collected in the previous scan cycle, it is determined that an event has been generated and a value change signal is generated in the current scan cycle.

3. The control method for a programmable logic controller as described in claim 2, characterized in that, The first relay generates the first scan cycle signal after initialization and assigns the initial acquisition value to the first register and the second register. The first relay is in the on state during the first scan cycle and in the off state at the beginning of the second scan cycle. The first relay is an M8002 relay.

4. The control method for a programmable logic controller as described in claim 3, characterized in that, The second relay is used to perform an AND operation with the reference acquisition value during the first scan cycle after initialization, wherein the second relay is in the off state during the first scan cycle and in the on state at the beginning of the second scan cycle; The second relay is an M8003 relay.

5. The control method for a programmable logic controller as described in claim 4, characterized in that, Also includes: At the start of the second scan cycle after initialization, within one scan cycle, the acquired value of the current scan cycle is stored in the second register, and it is determined whether the acquired value in the second register is equal to the acquired value in the first register. After the determination is completed, the acquired value in the second register is transferred to the first register, overwriting the acquired value in the first register.

6. The control method for a programmable logic controller as described in claim 2, characterized in that, Also includes: An initialization signal is defined in the first scan cycle after initialization, wherein the initialization signal keeps the controller in an initialized state.

7. The control method for a programmable logic controller as described in claim 1, characterized in that, After generating a value change signal during the scanning cycle of the acquired value of the event-generating signal, the method further includes: Locking the value change signal; and The locked value change signal is output to the execution end.

8. The control method for a programmable logic controller as described in claim 7, characterized in that, The step of outputting the locked value change signal to the execution end further includes: After receiving feedback that the execution event has been completed, the locked value change signal is then output to the execution end.

9. A programmable logic controller, characterized in that, It includes a processor and a memory, the memory being used to store program instructions, and the processor being used to invoke the program instructions to perform the method of any one of claims 1 to 8.

Citation Information

Patent Citations

  • Remote machine tool fault acquisition communication method

    CN104008637A

  • Data acquisition method and device

    CN112596463A