Method for improving PLC communication efficiency and storage medium
By presetting the communication interval and transmitting signal changes at the end of the interval, the blocking and loss problems caused by frequent signal transmission in PLC communication are solved, and communication efficiency and response speed are improved.
Patent Information
- Application Number
- CN202410973256.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-19
- Publication Date
- 2024-11-12
AI Technical Summary
When the PLC communicates with the device side, frequent signal transmission caused by periodic scanning will result in communication blockage, disconnection, loss and untimely response, which will affect communication efficiency.
The communication interval is preset, and within this interval, each signal point has a signal change of at most once. Only the signal point where the signal change occurs is transmitted to the outside world at the end of the interval. The transmission is carried out using a unified point of time to avoid signal coverage and real-time transmission.
It effectively improves the communication efficiency of PLC, avoids signal loss and response delay, and optimizes the communication process.
Smart Images

Figure CN118945202A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of PLC control technology, and more specifically, to a method and storage medium for improving PLC communication efficiency. Background Art
[0002] Programmable Logic Controller (PLC), hereinafter referred to as PLC, is a digital logic controller used for automated real-time control and is widely used in the current industrial control field. When PLC interacts with the device, it often changes the signal point from 0 to 1 to indicate the specific physical meaning of the signal point. For example, a signal point of 0 indicates a request for loading, and a signal point of 1 indicates that loading is completed. For example, a signal point of 0 indicates a successful code reading, and a signal point of 1 indicates a failed code reading.
[0003] The working mode of PLC adopts periodic scanning. Periodic scanning means that after the PLC is powered on, it scans the PLC system repeatedly. The speed of a scanning cycle is extremely short, that is, under the monitoring of the system program, various events inside the PLC system are queried, judged and executed in each cycle. Therefore, in each scanning cycle, the PLC needs to communicate with the device side continuously, that is, it needs to send signals to the device side in real time, regardless of whether the signal changes. However, when the functions of the device are more, the communication between the PLC and the device is more complicated, and the more signals need to be transmitted, which will cause a series of problems such as communication blockage, communication disconnection, communication loss, and untimely communication response, affecting the communication efficiency of the PLC. Summary of the invention
[0004] The present application provides a method for improving PLC communication efficiency, which makes the PLC communication efficiency higher.
[0005] The technical solution adopted in this application is a method for improving PLC communication efficiency, which comprises the following steps:
[0006] Determining signal points for communicating with the outside world, each of the signal points being used to generate a signal for transmission with the outside world;
[0007] A communication interval for transmitting signals to the outside world is preset, and a signal change occurs at most once at each signal point within the communication interval; and
[0008] After reaching the end time of the communication interval, at least a signal corresponding to each signal point where a signal change occurs is transmitted to the outside world.
[0009] It can be seen that in the present application, a communication interval is preset, and within the communication interval, it is guaranteed that each signal point can only undergo a signal change once at most, so as to avoid signal loss caused by signal coverage within the same communication interval. When the PLC communicates with the outside world, only after reaching the end time of the communication interval, the PLC transmits to the outside world at least the signal corresponding to each signal point where the signal change occurs. This method avoids the PLC from transmitting the signal corresponding to each signal point to the outside world at every moment, and instead adopts a method of transmitting at a unified time point, which can effectively improve the communication efficiency of the PLC.
[0010] Optionally, after reaching the end time of the communication interval, at least transmitting to the outside a signal corresponding to a signal point where a signal change occurs, further comprises:
[0011] Scanning each of the signal points at the end time of the communication interval, and reading the signal corresponding to each of the signal points;
[0012] The signal corresponding to each of the signal points is transmitted to the outside world.
[0013] Optionally, the transmitting to the outside at least a signal corresponding to a signal point where a signal change occurs further includes:
[0014] In the process of transmitting at least to the outside the signal corresponding to the signal point where the signal change occurs, the signal corresponding to the signal point where the signal change occurs in the next communication interval is cached.
[0015] Optionally, after the at least transmitting to the outside a signal corresponding to the signal point where the signal change occurs is completed, the method further includes:
[0016] Assign the buffered signal back to the corresponding signal point.
[0017] A method for improving PLC communication efficiency, the method comprising the following steps:
[0018] Determining signal points for communicating with the outside world, each of the signal points being used to generate a signal for transmission with the outside world;
[0019] A communication interval for transmitting signals to the outside world is preset, and a signal change occurs at most once at each signal point within the communication interval; and
[0020] After reaching the end time of the communication interval, the signal corresponding to each of the signal points is packaged into a signal unit;
[0021] The signal unit is transmitted to the outside world.
[0022] Optionally, the signal unit is transmitted in the form of a word, wherein the signal of the signal point is 0 or 1.
[0023] Optionally, when the number of the signal points is greater than 16, a maximum of 16 signal points are used to form a signal unit, and a plurality of the signal units are transmitted to the outside.
[0024] Optionally, before transmitting the signal unit to the outside, the method further includes:
[0025] Determine whether the signal unit of the current communication interval is the same as the signal unit of the previous communication interval;
[0026] If the signal unit of the current communication interval is different from the signal unit of the previous communication interval, transmitting the signal unit of the current communication interval to the outside world;
[0027] If the signal unit of the current communication interval is the same as the signal unit of the previous communication interval, the signal unit of the current communication interval is not transmitted to the outside.
[0028] A terminal device receives the signal unit and parses the signal unit to obtain a signal corresponding to each signal point contained in the signal unit.
[0029] A computer-readable storage medium stores instructions, and a data storage device executes the instructions so that the data storage device implements the method for improving PLC communication efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0031] Figure 1 This is one of the flow charts of the method for improving PLC communication efficiency in an embodiment of the present application;
[0032] Figure 2 This is a second flow chart of a method for improving PLC communication efficiency in an embodiment of the present application;
[0033] Figure 3 It is a schematic diagram of the first specific embodiment of the present application;
[0034] Figure 4 This is a schematic diagram of the second specific embodiment of the present application. Specific embodiments
[0035] In order to make the technical problems, technical solutions and beneficial effects to be solved by the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0036] It should be noted that when a metastructure is referred to as being "fixed to" or "set on" another metastructure, it can be directly on the other metastructure or indirectly on the other metastructure. When a metastructure is referred to as being "connected to" another metastructure, it can be directly connected to the other metastructure or indirectly connected to the other metastructure.
[0037] It should be understood that the terms "length", "width", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", etc., indicating the orientation or position relationship, are based on the orientation or position relationship shown in the drawings, and are only for the convenience of describing the present application and simplifying the description, and do not indicate or imply that the device or element structure referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as a limitation on the present application.
[0038] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of some applications, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.
[0039] When the PLC exchanges information with the terminal device, it often uses the change of 0 or 1 of the signal point to indicate the specific physical meaning of the signal point. For example, signal 0 of a signal point indicates a request for loading, and signal 1 of the signal point indicates that loading is completed. For example, signal 0 of a signal point indicates successful code reading, and signal 1 of the signal point indicates failed code reading, etc.
[0040] The working mode of PLC adopts periodic scanning. Periodic scanning means that after the PLC is powered on, it scans the PLC system repeatedly. The speed of a scanning cycle is extremely short, that is, under the monitoring of the system program, various events inside the PLC system are queried, judged and executed in each cycle. Therefore, in each scanning cycle, the PLC needs to continuously communicate with the device end, that is, it needs to send the signal corresponding to each scanned signal point to the terminal device in real time, and the terminal device determines whether the signal corresponding to each signal point has changed. However, the more functions the terminal device has, the more complicated the communication between the PLC and the terminal device, and the more signals need to be transmitted, which will cause a series of problems such as communication blockage, communication disconnection, communication loss, and untimely communication response, affecting the communication efficiency of the PLC.
[0041] To this end, the present application provides a method for improving PLC communication efficiency to solve a series of problems that are easily caused when the terminal device has more functions, such as communication blockage, communication disconnection, communication loss, and untimely communication response.
[0042] See also Figure 1 , a method for improving PLC communication efficiency, comprising the following steps:
[0043] Step S100, determining a signal point for communicating with the outside world, each signal point is used to generate a signal for transmission with the outside world.
[0044] Specifically, the PLC transmits the signal generated by each signal point to the outside world, such as an external device terminal, to achieve communication between the PLC and the device terminal.
[0045] That is, first of all, it is necessary to confirm every signal point in the PLC that needs to transmit signals to the outside world.
[0046] Step S300, preset a communication interval for transmitting signals to the outside world, and each signal point has at most one signal change within the communication interval.
[0047] Specifically, a time interval is preset for each communication between the PLC and the outside world. During this time interval, the PLC does not transmit the signal corresponding to the signal point to the outside world.
[0048] However, within the communication interval, each signal point will have at most one signal change to avoid signal coverage. In other words, the preset communication interval length needs to ensure that a signal point will have at most one signal change within this communication interval. For example, if the preset communication interval length is 30ms, there will be multiple signal changes at a signal point. At this time, the preset communication interval length needs to be readjusted. For example, after adjusting the communication interval length to 15ms, each signal point will have at most one signal change within the communication interval.
[0049] It can be understood that since the PLC does not transmit signals to the outside world within the communication interval, if the same signal point undergoes two signal changes within the communication interval, the second signal change will cover the first signal change, thereby causing signal loss.
[0050] For example, after the PLC is initialized, within the preset communication interval, even if the PLC cycle scans multiple times, the PLC does not immediately transmit signals to the outside world, and during the PLC cycle scan within the preset communication interval, each signal point has at most one signal change.
[0051] In some embodiments, a communication interval may include multiple scanning cycles.
[0052] Step S500, after reaching the end time of the communication interval, at least a signal corresponding to each signal point where a signal change occurs is transmitted to the outside world.
[0053] Specifically, since the PLC does not transmit signals to the outside world during the communication interval, the PLC transmits signals to the outside world only after reaching the end time of the communication interval.
[0054] In some implementations, at the end time of the communication interval, the PLC may only transmit to the outside world the signal corresponding to the signal point where the signal change occurs, that is, the signal corresponding to the signal point where the signal change does not occur may not be transmitted to the outside world.
[0055] Of course, in other implementations, at the end time of the communication interval, the PLC may transmit the signals corresponding to all signal points to the outside world respectively.
[0056] See also Figure 3 , take the PLC with 16 signal points that can generate signals and the preset communication interval as 15ms as an example. Within the communication interval:
[0057] At the time of 0 ms, the signals corresponding to the signal points 1 to 16 are all 0, that is, the signals corresponding to the signal points 1 to 16 at the initial time of the communication interval are all 0.
[0058] At the 1ms moment, the signal changes corresponding to signal points 1, 3 and 13 are 1, that is, signal points 1, 3 and 13 have undergone signal changes, while the other signal points are still 0, that is, the other signal points have not undergone signal changes relative to the previous moment.
[0059] At the 2 ms moment, the signals corresponding to signal points 11 and 14 change to 1, and the other signal points remain unchanged relative to the previous moment.
[0060] At the time between 3ms and 15ms, the signals corresponding to signal points 1 to 16 remain unchanged relative to the previous time.
[0061] At the 15 ms moment, the signals corresponding to signal points 5, 8, and 15 change to 1, and the other signal points remain unchanged relative to the previous moment.
[0062] It can be seen that within the communication interval, the signals corresponding to signal points 1, 3, 5, 8, 11, 13, 14 and 15 changed to 1, and the signals of other signal points did not change within the communication interval.
[0063] Since the preset communication interval is 15ms, when the end time of the communication interval, i.e. 15ms, is reached, the PLC needs to transmit signals to the outside world. At this time, in some implementations, the PLC can transmit the signals corresponding to signal points 1, 3, 5, 8, 11, 13, 14 and 15 where signal changes have occurred to the outside world.
[0064] In other implementations, after reaching the end time of the communication interval, the PLC may transmit the signals corresponding to all signal points to the outside world.
[0065] It can be seen that in the present application, a communication interval is preset, and within the communication interval, it is guaranteed that each signal point can only undergo a signal change once at most, so as to avoid signal loss caused by signal coverage within the same communication interval. When the PLC communicates with the outside world, only after reaching the end time of the communication interval, the PLC transmits to the outside world at least the signal corresponding to each signal point where the signal change occurs. This method avoids the PLC from transmitting the signal corresponding to each signal point to the outside world at every moment, and instead adopts a method of transmitting at a unified time point, which can effectively improve the communication efficiency of the PLC.
[0066] Specifically, step S500 may further include:
[0067] Step S510, scanning each signal point at the end time of the communication interval, and reading the signal corresponding to each signal point.
[0068] It can be understood that since the preset communication interval ensures that the signal corresponding to each signal point changes at most once, signal loss caused by signal coverage will not occur within the communication interval. Therefore, there is no need to scan in real time to obtain the signal of each signal point within the communication interval. After reaching the end time of the communication interval, each signal point is scanned again to obtain the signal corresponding to each signal point.
[0069] Step S530: Transmit the signal corresponding to each signal point to the outside world.
[0070] Furthermore, in the process of transmitting at least to the outside the signal corresponding to the signal point where the signal change occurs, the signal corresponding to the signal point where the signal change occurs in the next communication interval is cached.
[0071] It can be understood that the PLC needs a certain transmission time when transmitting signals with the outside world. During this transmission time, the signal point of the next communication interval may change its signal. At this time, if there are still signal points whose signals have not been transmitted, then in the next communication interval, the signal of the signal point where the signal change occurs will overwrite the signal corresponding to the signal point in the previous communication interval, causing the signal of the same signal point to be covered, thereby causing signal loss. Therefore, in the present application, in the process of signal transmission with the outside world, the signal corresponding to the signal point where the signal change occurs in the next communication interval is cached to avoid the signal covering the signal corresponding to the signal point in the previous communication interval.
[0072] Furthermore, after at least the signal corresponding to the signal point where the signal change occurs is transmitted to the outside world, the buffered signal is assigned back to the corresponding signal point.
[0073] It can be understood that after the signal transmission is completed, the cached signal is assigned back to the corresponding signal point, which is beneficial for the subsequent transmission of at least the signal corresponding to each signal point where the signal change occurs to the outside world at the end time of the next communication interval, thereby avoiding the loss of the cached signal.
[0074] See also Figure 2 In order to further improve the efficiency of PLC communication, a method for improving the efficiency of PLC communication is provided, comprising:
[0075] Step S100, determining a signal point for communicating with the outside world, each signal point is used to generate a signal for transmission with the outside world.
[0076] Step S300, preset a communication interval for transmitting signals to the outside world, and each signal point has at most one signal change within the communication interval.
[0077] Step S700: After reaching the end time of the communication interval, the signal corresponding to each signal point is packaged into a signal unit.
[0078] Step S900: transmitting the signal unit to the outside world.
[0079] That is to say, in the above implementation, after reaching the end time of the communication interval, the signal corresponding to each signal point is packaged into a signal unit and transmitted to the outside world in the form of a signal unit, instead of transmitting the signal corresponding to each signal point to the outside world separately. This method can further improve the efficiency of communication.
[0080] Specifically, in some implementations, the signal unit is transmitted in the form of a word (WORD), wherein the signal of the signal point is 0 or 1.
[0081] like Figure 4 As shown, at time 0ms, since the signal of each signal point is 0, the communication unit is 0 at this time.
[0082] At 1ms, the signals corresponding to signal points 1, 3, and 13 change to 1, while the other signal points remain at 0. At this time, the communication unit is 4101. That is, 4101 represents the signals corresponding to signal points 1 to 16 at 1ms.
[0083] Therefore, at the end of the communication interval, that is, at the 15ms moment, the signals corresponding to the signal points 1, 3, 5, 8, 11, 13, 14, and 15 in the communication interval have changed to 1, and the communication unit is 29845. That is, 29845 represents the signals corresponding to the signal points 1 to 16 at the end of the interval.
[0084] It can be seen that in the above method, transmitting the communication unit in the form of word (WORD) is more convenient and faster.
[0085] Furthermore, when the number of signal points is greater than 16, a signal unit is formed with a maximum of 16 signal points, and the multiple signal units are transmitted to the outside.
[0086] For example, when there are 20 signal points, 16 of them can form one signal unit, and the other 4 signal points can form another signal unit, that is, when there are 20 signal points, two signal units can be formed. At this time, the PLC transmits the two signal units to the outside world respectively.
[0087] It is understandable that since the word (WORD) form can only transmit information of 16 signal points at most, when the number of signal points is greater than 16, multiple signal units, namely multiple words, can be used for transmission.
[0088] Furthermore, in some implementations, step S900 transmits the signal unit to the outside world, which may specifically include:
[0089] Step S910, determining whether the signal unit of the current communication interval is the same as the signal unit of the previous communication interval;
[0090] Step S930, if the signal unit of the current communication interval is different from the signal unit of the previous communication interval, the signal unit of the current communication interval is transmitted to the outside; if the signal unit of the current communication interval is the same as the signal unit of the previous communication interval, the signal unit of the current communication interval is not transmitted to the outside.
[0091] It can be understood that if the signal unit of the current communication interval is different from the signal unit of the previous communication interval, it means that a signal change has occurred at one or more signal points in the current communication interval relative to the previous communication interval.
[0092] If the signal unit of the current communication interval is the same as the signal unit of the previous communication interval, it means that there is no signal change in the signal point of the current communication interval relative to the signal point of the previous communication interval.
[0093] That is, in the above implementation, if there is no signal change in the current communication interval relative to the previous communication interval, no signal is transmitted to the outside world. Only when there is a signal change in the current communication interval relative to the previous communication interval, a signal is transmitted to the outside world. This method can further improve the efficiency of communication.
[0094] The present application also provides a terminal device, which receives the signal unit in the above implementation mode, and parses the signal unit to obtain a signal corresponding to each signal point included in the signal unit.
[0095] Specifically, after the PLC sends the signal unit to the terminal device in the form of a word (WORD), the terminal device receives the signal unit and parses the signal unit to obtain the signal corresponding to each signal point contained in the signal unit, thereby realizing communication between the terminal device and the PLC.
[0096] The present application also provides a computer-readable storage medium, in which instructions are stored. A data storage device executes the instructions so that the data storage device implements the method for improving PLC communication efficiency in the above implementation.
[0097] The above are only preferred embodiments of the present application and are not intended to limit the present application. Any modifications, equivalent substitutions and improvements made within the spirit and principles of some applications should be included in the protection scope of some applications.
Claims
1. A method for improving PLC communication efficiency, characterized in that: The method comprises the following steps: Determining signal points for communicating with the outside world, each of the signal points being used to generate a signal for transmission with the outside world; A communication interval for transmitting signals to the outside world is preset, and a signal change occurs at most once at each signal point within the communication interval; and After reaching the end time of the communication interval, at least a signal corresponding to each signal point where a signal change occurs is transmitted to the outside world.
2. The method for improving PLC communication efficiency according to claim 1, characterized in that: After reaching the end time of the communication interval, at least transmitting to the outside a signal corresponding to the signal point where the signal change occurs, further includes: Scanning each of the signal points at the end time of the communication interval, and reading the signal corresponding to each of the signal points; The signal corresponding to each of the signal points is transmitted to the outside world.
3. The method for improving PLC communication efficiency according to claim 1 or 2, characterized in that: The step of transmitting at least to the outside a signal corresponding to a signal point where a signal change occurs also includes: In the process of transmitting at least to the outside the signal corresponding to the signal point where the signal change occurs, the signal corresponding to the signal point where the signal change occurs in the next communication interval is cached.
4. The method for improving PLC communication efficiency as claimed in claim 3, characterized in that: After the transmission of at least the signal corresponding to the signal point where the signal change occurs to the outside world is completed, the method further includes: Assign the buffered signal back to the corresponding signal point.
5. A method for improving PLC communication efficiency, characterized in that: The method comprises the following steps: Determining signal points for communicating with the outside world, each of the signal points being used to generate a signal for transmission with the outside world; A communication interval for transmitting signals to the outside world is preset, and a signal change occurs at most once at each signal point within the communication interval; and After reaching the end time of the communication interval, the signal corresponding to each of the signal points is packaged into a signal unit; The signal unit is transmitted to the outside world.
6. The method for improving PLC communication efficiency as claimed in claim 5, characterized in that: The signal unit is transmitted in the form of a word, wherein the signal of the signal point is 0 or 1.
7. The method for improving PLC communication efficiency as claimed in claim 6, characterized in that: When the number of the signal points is greater than 16, a signal unit is formed with at most every 16 signal points, and a plurality of the signal units are transmitted to the outside.
8. The method for improving PLC communication efficiency as claimed in claim 1, characterized in that: Before transmitting the signal unit to the outside, the method further includes: Determine whether the signal unit of the current communication interval is the same as the signal unit of the previous communication interval; If the signal unit of the current communication interval is different from the signal unit of the previous communication interval, transmitting the signal unit of the current communication interval to the outside world; If the signal unit of the current communication interval is the same as the signal unit of the previous communication interval, the signal unit of the current communication interval is not transmitted to the outside.
9. A terminal device, characterized in that: The terminal device receives the signal unit according to any one of claims 5 to 8, and the terminal device parses the signal unit to obtain a signal corresponding to each of the signal points contained in the signal unit.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, and the data storage device executes the instructions so that the data storage device implements the method for improving PLC communication efficiency as described in any one of claims 1 to 8.
